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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2521 - (hide annotations)
Tue Jul 7 00:08:58 2009 UTC (10 years, 1 month ago) by jfenwick
File MIME type: text/plain
File size: 10184 byte(s)
Modified Lazy so that resolving a single sample uses the node cache method.
Fixed some doxygen problems.
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 jfenwick 2005 #include "DataReady.h"
20 jgs 82 #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 jfenwick 2005 class DataExpanded : public DataReady {
44 jgs 82
45 jfenwick 2005 typedef DataReady parent;
46    
47 jgs 82 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 jfenwick 2271 \param value - Input - The value of a single data point.
61 jgs 82 \param what - Input - A description of what this data represents.
62     */
63 woo409 757 ESCRIPT_DLL_API
64 jfenwick 2271 DataExpanded(const WrappedArray& value,
65 jgs 102 const FunctionSpace& what);
66 jgs 82
67     /**
68     \brief
69     Alternative constructor for DataExpanded that copies a slice from
70     another DataExpanded.
71    
72 jgs 102 \param other - Input - DataExpanded object to slice from.
73     \param region - Input - region to copy.
74 jgs 82 */
75 woo409 757 ESCRIPT_DLL_API
76 jgs 102 DataExpanded(const DataExpanded& other,
77 jfenwick 1796 const DataTypes::RegionType& region);
78 jgs 82
79     /**
80     \brief
81 jgs 119 Alternative constructor for DataExpanded objects.
82    
83     Description:
84     Alternative Constructor for DataExpanded objects.
85     \param what - Input - A description of what this data object represents.
86     \param shape - Input - the shape of each data-point.
87 jgs 122 \param data - the array of data values for the data-points.
88 jfenwick 1796
89     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.
90 jgs 119 */
91 woo409 757 ESCRIPT_DLL_API
92 jgs 119 DataExpanded(const FunctionSpace& what,
93 jfenwick 1796 const DataTypes::ShapeType &shape,
94     const DataTypes::ValueType &data);
95 jgs 119
96     /**
97     \brief
98 jgs 117 Copy constructor for DataExpanded.
99     Performs a deep copy from another DataExpanded.
100 jgs 82 */
101 woo409 757 ESCRIPT_DLL_API
102 jgs 117 DataExpanded(const DataExpanded& other);
103    
104     /**
105     \brief
106     Copy constructor for DataExpanded.
107     Construct a DataExpanded from a DataConstant.
108     */
109 woo409 757 ESCRIPT_DLL_API
110 jgs 117 DataExpanded(const DataConstant& other);
111    
112     /**
113     \brief
114     Copy constructor for DataExpanded.
115     Construct a DataExpanded from a DataTagged.
116     */
117 woo409 757 ESCRIPT_DLL_API
118 jgs 117 DataExpanded(const DataTagged& other);
119    
120     /**
121     \brief
122     Default destructor for DataExpanded.
123     */
124 woo409 757 ESCRIPT_DLL_API
125 jgs 102 virtual
126     ~DataExpanded();
127 jgs 82
128 jfenwick 2005 ESCRIPT_DLL_API
129     bool
130     isExpanded() const
131     {
132     return true;
133     };
134    
135 jfenwick 2271 ESCRIPT_DLL_API
136     bool
137     actsExpanded() const
138     {
139     return true;
140     }
141    
142 jgs 82 /**
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 jfenwick 1799
151     /**
152     \brief Return a deep copy of the current object.
153     */
154     ESCRIPT_DLL_API
155     virtual
156     DataAbstract*
157     deepCopy();
158    
159    
160 gross 950 /**
161     \brief
162     dumps the object into a netCDF file
163     */
164     ESCRIPT_DLL_API
165     virtual
166     void
167     dump(const std::string fileName) const;
168 jgs 82
169 gross 1118 /**
170     \brief
171     sets all values to zero
172     */
173     ESCRIPT_DLL_API
174     virtual
175     void
176     setToZero();
177    
178 jgs 82 /**
179     \brief
180 jgs 117 Return the offset for the given given data point. This returns
181     the offset in bytes for the given point into the container
182 jgs 82 holding the point data.
183 jgs 117
184     \param sampleNo - Input - sample number.
185     \param dataPointNo - Input - data point number.
186 jgs 82 */
187 woo409 757 ESCRIPT_DLL_API
188 jgs 102 virtual
189 jfenwick 1796 DataTypes::ValueType::size_type
190 jgs 102 getPointOffset(int sampleNo,
191     int dataPointNo) const;
192 jgs 82
193 jfenwick 2005 ESCRIPT_DLL_API
194     virtual
195     DataTypes::ValueType::size_type
196     getPointOffset(int sampleNo,
197     int dataPointNo);
198    
199 jfenwick 1796 /**
200     \brief
201     Return a a reference to the underlying DataVector.
202 jgs 82 */
203 jfenwick 1796
204 woo409 757 ESCRIPT_DLL_API
205 jfenwick 1796 DataTypes::ValueType&
206 jfenwick 2271 getVectorRW();
207 jgs 82
208 jfenwick 1796 ESCRIPT_DLL_API
209     const DataTypes::ValueType&
210 jfenwick 2271 getVectorRO() const;
211 jfenwick 1796
212    
213 jfenwick 2271
214 jgs 82 /**
215     \brief
216 jgs 102 Return the number of doubles stored for the Data.
217 jgs 82 */
218 woo409 757 ESCRIPT_DLL_API
219 jgs 102 virtual
220     ValueType::size_type
221     getLength() const;
222 jgs 82
223     /**
224     \brief
225     Factory method that returns a newly created DataExpanded.
226     The caller is reponsible for managing the object created.
227 jgs 117
228 jgs 82 \param region - Input - Region to copy.
229     */
230 woo409 757 ESCRIPT_DLL_API
231 jgs 102 virtual
232     DataAbstract*
233 jfenwick 1796 getSlice(const DataTypes::RegionType& region) const;
234 jgs 82
235     /**
236     \brief
237     Copy the specified region from the given value.
238 jgs 117
239     \param value - Input - Data object to copy from.
240 jgs 82 \param region - Input - Region to copy.
241     */
242 woo409 757 ESCRIPT_DLL_API
243 jgs 102 virtual
244     void
245     setSlice(const DataAbstract* value,
246 jfenwick 1796 const DataTypes::RegionType& region);
247 jgs 82
248 gross 580 /**
249     \brief
250 gross 1358 setTaggedValue
251    
252     Description:
253     uses tag to set a new value
254    
255     \param tagKey - Input - Integer key.
256 jfenwick 1796 \param pointshape - Input - The shape of the value parameter
257 jfenwick 2521 \param value - Input -
258     \param dataOffset - Input - where in the value parameter to start reading the data point value.
259 gross 1358 */
260 jfenwick 1796 void
261 gross 1358 setTaggedValue(int tagKey,
262 jfenwick 1796 const DataTypes::ShapeType& pointshape,
263     const DataTypes::ValueType& value,
264     int dataOffset=0);
265 gross 1358
266 jfenwick 1796
267    
268 gross 1358 /**
269     \brief
270 ksteube 775 Computes a symmetric matrix (A + AT) / 2
271    
272     \param ev - Output - symmetric matrix
273    
274     */
275 gross 800 ESCRIPT_DLL_API
276 ksteube 775 virtual void
277     symmetric(DataAbstract* ev);
278    
279     /**
280     \brief
281     Computes a nonsymmetric matrix (A - AT) / 2
282    
283     \param ev - Output - nonsymmetric matrix
284    
285     */
286 gross 800 ESCRIPT_DLL_API
287 ksteube 775 virtual void
288     nonsymmetric(DataAbstract* ev);
289    
290     /**
291     \brief
292     Computes the trace of a matrix
293    
294     \param ev - Output - trace of your matrix
295 jfenwick 2521 \param axis_offset -
296 ksteube 775
297     */
298 gross 800 ESCRIPT_DLL_API
299 ksteube 775 virtual void
300 gross 800 trace(DataAbstract* ev, int axis_offset);
301 ksteube 775
302     /**
303     \brief
304     Transpose each data point of this Data object around the given axis.
305    
306     \param ev - Output - transpose of your matrix
307 jfenwick 2521 \param axis_offset -
308 ksteube 775 */
309 gross 800 ESCRIPT_DLL_API
310 ksteube 775 virtual void
311     transpose(DataAbstract* ev, int axis_offset);
312    
313     /**
314     \brief
315 gross 804 swaps components axis0 and axis1
316 gross 800
317     \param ev - Output - swapped components
318 jfenwick 2521 \param axis0
319     \param axis1
320 gross 800 */
321     ESCRIPT_DLL_API
322     virtual void
323 gross 804 swapaxes(DataAbstract* ev, int axis0, int axis1);
324 gross 800
325    
326     /**
327     \brief
328 gross 580 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
329    
330     \param ev - Output - eigenvalues in increasing order at each data point
331    
332     */
333 woo409 757 ESCRIPT_DLL_API
334 gross 580 virtual void
335     eigenvalues(DataAbstract* ev);
336    
337     /**
338     \brief
339     solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
340    
341     \param ev - Output - eigenvalues in increasing order at each data point
342     \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
343     and the first nonzero component is positive.
344     \param tol - Input - eigenvalue with relative distance tol are treated as equal.
345    
346     */
347    
348 woo409 757 ESCRIPT_DLL_API
349 gross 580 virtual void
350     eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
351    
352 gross 1487 /**
353     * \brief
354     * reorders data sample ordered by reference_ids to the ordering of the functions space
355     *
356     * \param reference_ids - Input - reference_ids used for current ordering
357     * */
358     ESCRIPT_DLL_API
359     virtual void
360     reorderByReferenceIDs(int *reference_ids);
361 gross 580
362 gross 1487
363    
364 jgs 82 protected:
365    
366     private:
367    
368     /**
369     \brief
370 jgs 117 Common initialisation called from constructors.
371 jgs 82
372     Description:
373 jgs 117 Common initialisation called from constructors.
374    
375     Resizes the underlying data array to provide sufficient storage for the
376     given shape and number of data points, and creates the corresponding
377     DataArrayView of this data.
378    
379 jgs 82 \param noSamples - Input - number of samples.
380 jgs 117 \param noDataPointsPerSample - Input - number of data points per sample.
381 jgs 82 */
382 jgs 102 void
383 jfenwick 1796 initialise(int noSamples,
384 jgs 102 int noDataPointsPerSample);
385 jgs 82
386     /**
387     \brief
388 jgs 126 Copy the given data point value to all data points in this object.
389 jgs 82
390     Description:
391 jgs 117 Copy the given data point to all data points in this object.
392    
393     \param value Input - A single data point value.
394 jgs 82 */
395 jgs 102 void
396 jfenwick 1796 copy(const DataConstant& value);
397 jgs 82
398 jfenwick 1796
399    
400 jgs 126 /**
401     \brief
402 jfenwick 2458 Copy the given data point value to all data points in this object.
403 jgs 126
404     \param value Input - A single data point value.
405     */
406 jfenwick 2271
407 jgs 102 void
408 jfenwick 2271 copy(const WrappedArray& value);
409 jgs 102
410 jgs 126
411 gross 921 /**
412     \brief
413 gross 922 Copy a double value to the data point dataPointNo of sample sampleNo in this object.
414    
415     Description:
416     Copy a double value to the data point dataPointNo of sample sampleNo in this object.
417    
418     \param sampleNo Input - sample number
419     \param dataPointNo Input - data point of the sample
420     \param value Input - new values for the data point
421     */
422     ESCRIPT_DLL_API
423     virtual void
424     copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
425    
426    
427     /**
428     \brief
429 jfenwick 2458 Copy the value to the data point dataPointNo of sample sampleNo in this object.
430 gross 921
431     \param sampleNo Input - sample number
432     \param dataPointNo Input - data point of the sample
433     \param value Input - new values for the data point
434     */
435 jfenwick 2271 ESCRIPT_DLL_API
436     virtual void
437     copyToDataPoint(const int sampleNo, const int dataPointNo, const WrappedArray& value);
438 gross 921
439 jgs 82 //
440 jgs 117 // The main data storage array, a 2D array of data blocks.
441     // noSamples * noDataPointsPerSample
442 jgs 82 DataBlocks2D m_data;
443    
444     };
445    
446     } // end of namespace
447 jgs 102
448 jgs 100 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26