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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1811 - (hide annotations)
Thu Sep 25 23:11:13 2008 UTC (10 years, 10 months ago) by ksteube
File MIME type: text/plain
File size: 10259 byte(s)
Copyright updated in all files

1 jgs 480
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4     * Copyright (c) 2003-2008 by University of Queensland
5     * Earth Systems Science Computational Center (ESSCC)
6     * http://www.uq.edu.au/esscc
7     *
8     * Primary Business: Queensland, Australia
9     * Licensed under the Open Software License version 3.0
10     * http://www.opensource.org/licenses/osl-3.0.php
11     *
12     *******************************************************/
13 ksteube 1312
14 ksteube 1811
15 jgs 102 #if !defined escript_DataExpanded_20040323_H
16 jgs 82 #define escript_DataExpanded_20040323_H
17 woo409 757 #include "system_dep.h"
18 jgs 82
19     #include "DataAbstract.h"
20     #include "DataBlocks2D.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     Alternative constructor for DataExpanded that copies a slice from
68     another DataExpanded.
69    
70 jgs 102 \param other - Input - DataExpanded object to slice from.
71     \param region - Input - region to copy.
72 jgs 82 */
73 woo409 757 ESCRIPT_DLL_API
74 jgs 102 DataExpanded(const DataExpanded& other,
75 jfenwick 1796 const DataTypes::RegionType& region);
76 jgs 82
77     /**
78     \brief
79 jgs 119 Alternative constructor for DataExpanded objects.
80    
81     Description:
82     Alternative Constructor for DataExpanded objects.
83     \param what - Input - A description of what this data object represents.
84     \param shape - Input - the shape of each data-point.
85 jgs 122 \param data - the array of data values for the data-points.
86 jfenwick 1796
87     TODO Note that this constructor will also copy data to all points if it only contains enough elements to hold a single point. ie this is the merge of two separate constructors.
88 jgs 119 */
89 woo409 757 ESCRIPT_DLL_API
90 jgs 119 DataExpanded(const FunctionSpace& what,
91 jfenwick 1796 const DataTypes::ShapeType &shape,
92     const DataTypes::ValueType &data);
93 jgs 119
94     /**
95     \brief
96 jgs 117 Copy constructor for DataExpanded.
97     Performs a deep copy from another DataExpanded.
98 jgs 82 */
99 woo409 757 ESCRIPT_DLL_API
100 jgs 117 DataExpanded(const DataExpanded& other);
101    
102     /**
103     \brief
104     Copy constructor for DataExpanded.
105     Construct a DataExpanded from a DataConstant.
106     */
107 woo409 757 ESCRIPT_DLL_API
108 jgs 117 DataExpanded(const DataConstant& other);
109    
110     /**
111     \brief
112     Copy constructor for DataExpanded.
113     Construct a DataExpanded from a DataTagged.
114     */
115 woo409 757 ESCRIPT_DLL_API
116 jgs 117 DataExpanded(const DataTagged& other);
117    
118     /**
119     \brief
120     Default destructor for DataExpanded.
121     */
122 woo409 757 ESCRIPT_DLL_API
123 jgs 102 virtual
124     ~DataExpanded();
125 jgs 82
126     /**
127     \brief
128 jgs 117 Return a textual representation of the data.
129 jgs 82 */
130 woo409 757 ESCRIPT_DLL_API
131 jgs 102 virtual
132     std::string
133     toString() const;
134 jfenwick 1799
135     /**
136     \brief Return a deep copy of the current object.
137     */
138     ESCRIPT_DLL_API
139     virtual
140     DataAbstract*
141     deepCopy();
142    
143    
144 gross 950 /**
145     \brief
146     dumps the object into a netCDF file
147     */
148     ESCRIPT_DLL_API
149     virtual
150     void
151     dump(const std::string fileName) const;
152 jgs 82
153 gross 1118 /**
154     \brief
155     sets all values to zero
156     */
157     ESCRIPT_DLL_API
158     virtual
159     void
160     setToZero();
161    
162 jgs 82 /**
163     \brief
164 jgs 117 Return the offset for the given given data point. This returns
165     the offset in bytes for the given point into the container
166 jgs 82 holding the point data.
167 jgs 117
168     \param sampleNo - Input - sample number.
169     \param dataPointNo - Input - data point number.
170 jgs 82 */
171 woo409 757 ESCRIPT_DLL_API
172 jgs 102 virtual
173 jfenwick 1796 DataTypes::ValueType::size_type
174 jgs 102 getPointOffset(int sampleNo,
175     int dataPointNo) const;
176 jgs 82
177 jfenwick 1796 /**
178     \brief
179     Return a a reference to the underlying DataVector.
180 jgs 82 */
181 jfenwick 1796
182 woo409 757 ESCRIPT_DLL_API
183 jfenwick 1796 DataTypes::ValueType&
184     getVector();
185 jgs 82
186 jfenwick 1796 ESCRIPT_DLL_API
187     const DataTypes::ValueType&
188     getVector() const;
189    
190    
191 jgs 82 /**
192     \brief
193 jgs 102 Return the number of doubles stored for the Data.
194 jgs 82 */
195 woo409 757 ESCRIPT_DLL_API
196 jgs 102 virtual
197     ValueType::size_type
198     getLength() const;
199 jgs 82
200     /**
201     \brief
202     Factory method that returns a newly created DataExpanded.
203     The caller is reponsible for managing the object created.
204 jgs 117
205 jgs 82 \param region - Input - Region to copy.
206     */
207 woo409 757 ESCRIPT_DLL_API
208 jgs 102 virtual
209     DataAbstract*
210 jfenwick 1796 getSlice(const DataTypes::RegionType& region) const;
211 jgs 82
212     /**
213     \brief
214     Copy the specified region from the given value.
215 jgs 117
216     \param value - Input - Data object to copy from.
217 jgs 82 \param region - Input - Region to copy.
218     */
219 woo409 757 ESCRIPT_DLL_API
220 jgs 102 virtual
221     void
222     setSlice(const DataAbstract* value,
223 jfenwick 1796 const DataTypes::RegionType& region);
224 jgs 82
225 gross 580 /**
226     \brief
227 gross 1358 setTaggedValue
228    
229     Description:
230     uses tag to set a new value
231    
232     \param tagKey - Input - Integer key.
233 jfenwick 1796 \param pointshape - Input - The shape of the value parameter
234     \param value - Input - .
235 gross 1358 */
236 jfenwick 1796 void
237 gross 1358 setTaggedValue(int tagKey,
238 jfenwick 1796 const DataTypes::ShapeType& pointshape,
239     const DataTypes::ValueType& value,
240     int dataOffset=0);
241 gross 1358
242 jfenwick 1796
243    
244 gross 1358 /**
245     \brief
246 ksteube 775 Computes a symmetric matrix (A + AT) / 2
247    
248     \param ev - Output - symmetric matrix
249    
250     */
251 gross 800 ESCRIPT_DLL_API
252 ksteube 775 virtual void
253     symmetric(DataAbstract* ev);
254    
255     /**
256     \brief
257     Computes a nonsymmetric matrix (A - AT) / 2
258    
259     \param ev - Output - nonsymmetric matrix
260    
261     */
262 gross 800 ESCRIPT_DLL_API
263 ksteube 775 virtual void
264     nonsymmetric(DataAbstract* ev);
265    
266     /**
267     \brief
268     Computes the trace of a matrix
269    
270     \param ev - Output - trace of your matrix
271    
272     */
273 gross 800 ESCRIPT_DLL_API
274 ksteube 775 virtual void
275 gross 800 trace(DataAbstract* ev, int axis_offset);
276 ksteube 775
277     /**
278     \brief
279     Transpose each data point of this Data object around the given axis.
280    
281     \param ev - Output - transpose of your matrix
282    
283     */
284 gross 800 ESCRIPT_DLL_API
285 ksteube 775 virtual void
286     transpose(DataAbstract* ev, int axis_offset);
287    
288     /**
289     \brief
290 gross 804 swaps components axis0 and axis1
291 gross 800
292     \param ev - Output - swapped components
293    
294     */
295     ESCRIPT_DLL_API
296     virtual void
297 gross 804 swapaxes(DataAbstract* ev, int axis0, int axis1);
298 gross 800
299    
300     /**
301     \brief
302 gross 580 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
303    
304     \param ev - Output - eigenvalues in increasing order at each data point
305    
306     */
307 woo409 757 ESCRIPT_DLL_API
308 gross 580 virtual void
309     eigenvalues(DataAbstract* ev);
310    
311     /**
312     \brief
313     solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
314    
315     \param ev - Output - eigenvalues in increasing order at each data point
316     \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
317     and the first nonzero component is positive.
318     \param tol - Input - eigenvalue with relative distance tol are treated as equal.
319    
320     */
321    
322 woo409 757 ESCRIPT_DLL_API
323 gross 580 virtual void
324     eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
325    
326 gross 1487 /**
327     * \brief
328     * reorders data sample ordered by reference_ids to the ordering of the functions space
329     *
330     * \param reference_ids - Input - reference_ids used for current ordering
331     * */
332     ESCRIPT_DLL_API
333     virtual void
334     reorderByReferenceIDs(int *reference_ids);
335 gross 580
336 gross 1487
337    
338 jgs 82 protected:
339    
340     private:
341    
342     /**
343     \brief
344 jgs 117 Common initialisation called from constructors.
345 jgs 82
346     Description:
347 jgs 117 Common initialisation called from constructors.
348    
349     Resizes the underlying data array to provide sufficient storage for the
350     given shape and number of data points, and creates the corresponding
351     DataArrayView of this data.
352    
353 jgs 82 \param noSamples - Input - number of samples.
354 jgs 117 \param noDataPointsPerSample - Input - number of data points per sample.
355 jgs 82 */
356 jgs 102 void
357 jfenwick 1796 initialise(int noSamples,
358 jgs 102 int noDataPointsPerSample);
359 jgs 82
360     /**
361     \brief
362 jgs 126 Copy the given data point value to all data points in this object.
363 jgs 82
364     Description:
365 jgs 117 Copy the given data point to all data points in this object.
366    
367     \param value Input - A single data point value.
368 jgs 82 */
369 jgs 102 void
370 jfenwick 1796 copy(const DataConstant& value);
371 jgs 82
372 jfenwick 1796
373    
374 jgs 126 /**
375     \brief
376     Copy the given data point value given a numarray object to all data points in this object.
377    
378     Description:
379     Copy the given data point value given a numarray object to all data points in this object.
380    
381     \param value Input - A single data point value.
382     */
383 jgs 102 void
384     copy(const boost::python::numeric::array& value);
385    
386 jgs 126 /**
387     \brief
388     Copy the numarray object to the data points in this object.
389    
390     Description:
391     Copy the numarray object to the data points in this object.
392    
393     \param value Input - new values for the data points
394     */
395     void
396     copyAll(const boost::python::numeric::array& value);
397    
398 gross 921 /**
399     \brief
400 gross 922 Copy a double value to the data point dataPointNo of sample sampleNo in this object.
401    
402     Description:
403     Copy a double value to the data point dataPointNo of sample sampleNo in this object.
404    
405     \param sampleNo Input - sample number
406     \param dataPointNo Input - data point of the sample
407     \param value Input - new values for the data point
408     */
409     ESCRIPT_DLL_API
410     virtual void
411     copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
412    
413    
414     /**
415     \brief
416 gross 921 Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
417    
418     Description:
419     Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
420    
421     \param sampleNo Input - sample number
422     \param dataPointNo Input - data point of the sample
423     \param value Input - new values for the data point
424     */
425     void
426     copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value);
427    
428 jgs 82 //
429 jgs 117 // The main data storage array, a 2D array of data blocks.
430     // noSamples * noDataPointsPerSample
431 jgs 82 DataBlocks2D m_data;
432    
433     };
434    
435     } // end of namespace
436 jgs 102
437 jgs 100 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26