/[escript]/trunk-mpi-branch/escript/src/DataExpanded.h
ViewVC logotype

Annotation of /trunk-mpi-branch/escript/src/DataExpanded.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1306 - (hide annotations)
Tue Sep 18 05:51:09 2007 UTC (12 years ago) by ksteube
File MIME type: text/plain
File size: 10925 byte(s)
New Copyright in each .c .h .cpp and .py file

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26