/[escript]/trunk/escript/src/DataExpanded.h
ViewVC logotype

Annotation of /trunk/escript/src/DataExpanded.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 964 - (hide annotations)
Tue Feb 13 05:10:26 2007 UTC (12 years, 6 months ago) by gross
File MIME type: text/plain
File size: 10958 byte(s)
The set/getRefVal functions of Data objects have been removed (mainly to avoid later problems with MPI).
Moreover, a faster access to the reference id of samples has been introduced. I don't think that anybody will
profit form this at this stage but it will allow a faster dump of data objects.


1 jgs 102 // $Id$
2 jgs 82 /*
3 elspeth 615 ************************************************************
4     * Copyright 2006 by ACcESS MNRF *
5     * *
6     * http://www.access.edu.au *
7     * Primary Business: Queensland, Australia *
8     * Licensed under the Open Software License version 3.0 *
9     * http://www.opensource.org/licenses/osl-3.0.php *
10     * *
11     ************************************************************
12 jgs 82 */
13 jgs 480
14 jgs 102 #if !defined escript_DataExpanded_20040323_H
15 jgs 82 #define escript_DataExpanded_20040323_H
16 woo409 757 #include "system_dep.h"
17 jgs 82
18     #include "DataAbstract.h"
19     #include "DataBlocks2D.h"
20     #include "DataArrayView.h"
21    
22     #include <boost/python/numeric.hpp>
23    
24     namespace escript {
25    
26 jgs 117 //
27     // Forward declarations of other Data types.
28 jgs 102 class DataConstant;
29     class DataTagged;
30 jgs 82
31     /**
32     \brief
33     Give a short description of what DataExpanded does.
34    
35     Description:
36 jgs 117 Give a detailed description of DataExpanded.
37 jgs 82
38     Template Parameters:
39     For templates describe any conditions that the parameters used in the
40 jgs 117 template must satisfy.
41 jgs 82 */
42    
43 jgs 117 class DataExpanded : public DataAbstract {
44 jgs 82
45     public:
46    
47     /**
48     \brief
49 jgs 117 Constructor for DataExpanded.
50 jgs 82
51 jgs 117 Description:
52     Constructor for DataExpanded.
53 jgs 82
54 jgs 117 The given single data value is copied to all the data points in
55     this data object, where the number of data points is defined by
56     the given function space.
57 jgs 82
58 jgs 117 \param value - Input - A single data value.
59 jgs 82 \param what - Input - A description of what this data represents.
60     */
61 woo409 757 ESCRIPT_DLL_API
62 jgs 102 DataExpanded(const boost::python::numeric::array& value,
63     const FunctionSpace& what);
64 jgs 82
65     /**
66     \brief
67 jgs 117 Alternative constructor for DataExpanded.
68 jgs 82
69     Description:
70 jgs 102 Alternative Constructor for DataExpanded.
71 jgs 117
72     The given single data value is copied to all the data points in
73     this data object, where the number of data points is defined by
74     the given function space.
75    
76     \param value - Input - A single data value.
77 jgs 82 \param what - Input - A description of what this data represents.
78     */
79 woo409 757 ESCRIPT_DLL_API
80 jgs 102 DataExpanded(const DataArrayView& value,
81     const FunctionSpace& what);
82 jgs 82
83     /**
84     \brief
85     Alternative constructor for DataExpanded that copies a slice from
86     another DataExpanded.
87    
88 jgs 102 \param other - Input - DataExpanded object to slice from.
89     \param region - Input - region to copy.
90 jgs 82 */
91 woo409 757 ESCRIPT_DLL_API
92 jgs 102 DataExpanded(const DataExpanded& other,
93     const DataArrayView::RegionType& region);
94 jgs 82
95     /**
96     \brief
97 jgs 119 Alternative constructor for DataExpanded objects.
98    
99     Description:
100     Alternative Constructor for DataExpanded objects.
101     \param what - Input - A description of what this data object represents.
102     \param shape - Input - the shape of each data-point.
103 jgs 122 \param data - the array of data values for the data-points.
104 jgs 119 */
105 woo409 757 ESCRIPT_DLL_API
106 jgs 119 DataExpanded(const FunctionSpace& what,
107     const DataArrayView::ShapeType &shape,
108     const DataArrayView::ValueType &data);
109    
110     /**
111     \brief
112 jgs 117 Copy constructor for DataExpanded.
113     Performs a deep copy from another DataExpanded.
114 jgs 82 */
115 woo409 757 ESCRIPT_DLL_API
116 jgs 117 DataExpanded(const DataExpanded& other);
117    
118     /**
119     \brief
120     Copy constructor for DataExpanded.
121     Construct a DataExpanded from a DataConstant.
122     */
123 woo409 757 ESCRIPT_DLL_API
124 jgs 117 DataExpanded(const DataConstant& other);
125    
126     /**
127     \brief
128     Copy constructor for DataExpanded.
129     Construct a DataExpanded from a DataTagged.
130     */
131 woo409 757 ESCRIPT_DLL_API
132 jgs 117 DataExpanded(const DataTagged& other);
133    
134     /**
135     \brief
136     Default destructor for DataExpanded.
137     */
138 woo409 757 ESCRIPT_DLL_API
139 jgs 102 virtual
140     ~DataExpanded();
141 jgs 82
142     /**
143     \brief
144 jgs 117 Return a textual representation of the data.
145 jgs 82 */
146 woo409 757 ESCRIPT_DLL_API
147 jgs 102 virtual
148     std::string
149     toString() const;
150 gross 950 /**
151     \brief
152     dumps the object into a netCDF file
153     */
154     ESCRIPT_DLL_API
155     virtual
156     void
157     dump(const std::string fileName) const;
158 jgs 82
159     /**
160     \brief
161 jgs 117 Return the offset for the given given data point. This returns
162     the offset in bytes for the given point into the container
163 jgs 82 holding the point data.
164 jgs 117
165     \param sampleNo - Input - sample number.
166     \param dataPointNo - Input - data point number.
167 jgs 82 */
168 woo409 757 ESCRIPT_DLL_API
169 jgs 102 virtual
170     DataArrayView::ValueType::size_type
171     getPointOffset(int sampleNo,
172     int dataPointNo) const;
173 jgs 82
174     /**
175     \brief
176 jgs 117 Return a view into the data array for the data point specified.
177    
178 jgs 82 NOTE: Construction of the DataArrayView is a relatively expensive
179 jgs 102 operation.
180 jgs 117
181     \param sampleNo - Input - sample number.
182     \param dataPointNo - Input - data point number.
183     \return DataArrayView for the data point.
184 jgs 82 */
185 woo409 757 ESCRIPT_DLL_API
186 jgs 102 DataArrayView
187     getDataPoint(int sampleNo,
188     int dataPointNo);
189 jgs 82
190     /**
191     \brief
192 jgs 102 Return the number of doubles stored for the Data.
193 jgs 82 */
194 woo409 757 ESCRIPT_DLL_API
195 jgs 102 virtual
196     ValueType::size_type
197     getLength() const;
198 jgs 82
199     /**
200     \brief
201     Factory method that returns a newly created DataExpanded.
202     The caller is reponsible for managing the object created.
203 jgs 117
204 jgs 82 \param region - Input - Region to copy.
205     */
206 woo409 757 ESCRIPT_DLL_API
207 jgs 102 virtual
208     DataAbstract*
209     getSlice(const DataArrayView::RegionType& region) const;
210 jgs 82
211     /**
212     \brief
213     Copy the specified region from the given value.
214 jgs 117
215     \param value - Input - Data object to copy from.
216 jgs 82 \param region - Input - Region to copy.
217     */
218 woo409 757 ESCRIPT_DLL_API
219 jgs 102 virtual
220     void
221     setSlice(const DataAbstract* value,
222     const DataArrayView::RegionType& region);
223 jgs 82
224 jgs 110 /**
225 jgs 123 \brief
226     Archive the underlying data values to the file referenced
227     by ofstream. A count of the number of values expected to be written
228     is provided as a cross-check.
229    
230     The return value indicates success (0) or otherwise (1).
231     */
232 woo409 757 ESCRIPT_DLL_API
233 jgs 123 int
234     archiveData(std::ofstream& archiveFile,
235     const DataArrayView::ValueType::size_type noValues) const;
236    
237     /**
238     \brief
239     Extract the number of values specified by noValues from the file
240     referenced by ifstream to the underlying data structure.
241    
242     The return value indicates success (0) or otherwise (1).
243     */
244 woo409 757 ESCRIPT_DLL_API
245 jgs 123 int
246     extractData(std::ifstream& archiveFile,
247     const DataArrayView::ValueType::size_type noValues);
248    
249 gross 580 /**
250     \brief
251 ksteube 775 Computes a symmetric matrix (A + AT) / 2
252    
253     \param ev - Output - symmetric matrix
254    
255     */
256 gross 800 ESCRIPT_DLL_API
257 ksteube 775 virtual void
258     symmetric(DataAbstract* ev);
259    
260     /**
261     \brief
262     Computes a nonsymmetric matrix (A - AT) / 2
263    
264     \param ev - Output - nonsymmetric matrix
265    
266     */
267 gross 800 ESCRIPT_DLL_API
268 ksteube 775 virtual void
269     nonsymmetric(DataAbstract* ev);
270    
271     /**
272     \brief
273     Computes the trace of a matrix
274    
275     \param ev - Output - trace of your matrix
276    
277     */
278 gross 800 ESCRIPT_DLL_API
279 ksteube 775 virtual void
280 gross 800 trace(DataAbstract* ev, int axis_offset);
281 ksteube 775
282     /**
283     \brief
284     Transpose each data point of this Data object around the given axis.
285    
286     \param ev - Output - transpose of your matrix
287    
288     */
289 gross 800 ESCRIPT_DLL_API
290 ksteube 775 virtual void
291     transpose(DataAbstract* ev, int axis_offset);
292    
293     /**
294     \brief
295 gross 804 swaps components axis0 and axis1
296 gross 800
297     \param ev - Output - swapped components
298    
299     */
300     ESCRIPT_DLL_API
301     virtual void
302 gross 804 swapaxes(DataAbstract* ev, int axis0, int axis1);
303 gross 800
304    
305     /**
306     \brief
307 gross 580 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
308    
309     \param ev - Output - eigenvalues in increasing order at each data point
310    
311     */
312 woo409 757 ESCRIPT_DLL_API
313 gross 580 virtual void
314     eigenvalues(DataAbstract* ev);
315    
316     /**
317     \brief
318     solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
319    
320     \param ev - Output - eigenvalues in increasing order at each data point
321     \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
322     and the first nonzero component is positive.
323     \param tol - Input - eigenvalue with relative distance tol are treated as equal.
324    
325     */
326    
327 woo409 757 ESCRIPT_DLL_API
328 gross 580 virtual void
329     eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
330    
331    
332 jgs 82 protected:
333    
334     private:
335    
336     /**
337     \brief
338 jgs 117 Common initialisation called from constructors.
339 jgs 82
340     Description:
341 jgs 117 Common initialisation called from constructors.
342    
343     Resizes the underlying data array to provide sufficient storage for the
344     given shape and number of data points, and creates the corresponding
345     DataArrayView of this data.
346    
347 jgs 82 \param shape - Input - The shape of the point data.
348     \param noSamples - Input - number of samples.
349 jgs 117 \param noDataPointsPerSample - Input - number of data points per sample.
350 jgs 82 */
351 jgs 102 void
352     initialise(const DataArrayView::ShapeType& shape,
353     int noSamples,
354     int noDataPointsPerSample);
355 jgs 82
356     /**
357     \brief
358 jgs 126 Copy the given data point value to all data points in this object.
359 jgs 82
360     Description:
361 jgs 117 Copy the given data point to all data points in this object.
362    
363     \param value Input - A single data point value.
364 jgs 82 */
365 jgs 102 void
366     copy(const DataArrayView& value);
367 jgs 82
368 jgs 126 /**
369     \brief
370     Copy the given data point value given a numarray object to all data points in this object.
371    
372     Description:
373     Copy the given data point value given a numarray object to all data points in this object.
374    
375     \param value Input - A single data point value.
376     */
377 jgs 102 void
378     copy(const boost::python::numeric::array& value);
379    
380 jgs 126 /**
381     \brief
382     Copy the numarray object to the data points in this object.
383    
384     Description:
385     Copy the numarray object to the data points in this object.
386    
387     \param value Input - new values for the data points
388     */
389     void
390     copyAll(const boost::python::numeric::array& value);
391    
392 gross 921 /**
393     \brief
394 gross 922 Copy a double value to the data point dataPointNo of sample sampleNo in this object.
395    
396     Description:
397     Copy a double value to the data point dataPointNo of sample sampleNo in this object.
398    
399     \param sampleNo Input - sample number
400     \param dataPointNo Input - data point of the sample
401     \param value Input - new values for the data point
402     */
403     ESCRIPT_DLL_API
404     virtual void
405     copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
406    
407    
408     /**
409     \brief
410 gross 921 Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
411    
412     Description:
413     Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
414    
415     \param sampleNo Input - sample number
416     \param dataPointNo Input - data point of the sample
417     \param value Input - new values for the data point
418     */
419     void
420     copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value);
421    
422 jgs 82 //
423 jgs 117 // The main data storage array, a 2D array of data blocks.
424     // noSamples * noDataPointsPerSample
425 jgs 82 DataBlocks2D m_data;
426    
427     };
428    
429     } // end of namespace
430 jgs 102
431 jgs 100 #endif

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26