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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2742 - (hide annotations)
Thu Nov 12 06:03:37 2009 UTC (9 years, 9 months ago) by jfenwick
File MIME type: text/plain
File size: 10314 byte(s)
Merging changes from the lapack branch.

The inverse() operation has been moved into c++. [No lazy support for this operation yet.]
Optional Lapack support has been added for matrices larger than 3x3. 
service0 is set to use mkl_lapack.



1 jgs 480
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4 jfenwick 2548 * Copyright (c) 2003-2009 by University of Queensland
5 ksteube 1811 * 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     namespace escript {
23    
24 jgs 117 //
25     // Forward declarations of other Data types.
26 jgs 102 class DataConstant;
27     class DataTagged;
28 jgs 82
29     /**
30     \brief
31     Give a short description of what DataExpanded does.
32    
33     Description:
34 jgs 117 Give a detailed description of DataExpanded.
35 jgs 82
36     Template Parameters:
37     For templates describe any conditions that the parameters used in the
38 jgs 117 template must satisfy.
39 jgs 82 */
40    
41 jfenwick 2005 class DataExpanded : public DataReady {
42 jgs 82
43 jfenwick 2005 typedef DataReady parent;
44    
45 jgs 82 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 jfenwick 2271 \param value - Input - The value of a single data point.
59 jgs 82 \param what - Input - A description of what this data represents.
60     */
61 woo409 757 ESCRIPT_DLL_API
62 jfenwick 2271 DataExpanded(const WrappedArray& value,
63 jgs 102 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 jfenwick 2005 ESCRIPT_DLL_API
127     bool
128     isExpanded() const
129     {
130     return true;
131     };
132    
133 jfenwick 2271 ESCRIPT_DLL_API
134     bool
135     actsExpanded() const
136     {
137     return true;
138     }
139    
140 jgs 82 /**
141     \brief
142 jgs 117 Return a textual representation of the data.
143 jgs 82 */
144 woo409 757 ESCRIPT_DLL_API
145 jgs 102 virtual
146     std::string
147     toString() const;
148 jfenwick 1799
149     /**
150     \brief Return a deep copy of the current object.
151     */
152     ESCRIPT_DLL_API
153     virtual
154     DataAbstract*
155     deepCopy();
156    
157    
158 gross 950 /**
159     \brief
160     dumps the object into a netCDF file
161     */
162     ESCRIPT_DLL_API
163     virtual
164     void
165     dump(const std::string fileName) const;
166 jgs 82
167 jfenwick 2742
168     /**
169     \brief invert square matricies
170     \param out - Where to store the results
171     */
172     ESCRIPT_DLL_API
173     virtual void
174     matrixInverse(DataAbstract* out) const;
175    
176 gross 1118 /**
177     \brief
178     sets all values to zero
179     */
180     ESCRIPT_DLL_API
181     virtual
182     void
183     setToZero();
184    
185 jgs 82 /**
186     \brief
187 jgs 117 Return the offset for the given given data point. This returns
188     the offset in bytes for the given point into the container
189 jgs 82 holding the point data.
190 jgs 117
191     \param sampleNo - Input - sample number.
192     \param dataPointNo - Input - data point number.
193 jgs 82 */
194 woo409 757 ESCRIPT_DLL_API
195 jgs 102 virtual
196 jfenwick 1796 DataTypes::ValueType::size_type
197 jgs 102 getPointOffset(int sampleNo,
198     int dataPointNo) const;
199 jgs 82
200 jfenwick 2005 ESCRIPT_DLL_API
201     virtual
202     DataTypes::ValueType::size_type
203     getPointOffset(int sampleNo,
204     int dataPointNo);
205    
206 jfenwick 1796 /**
207     \brief
208     Return a a reference to the underlying DataVector.
209 jgs 82 */
210 jfenwick 1796
211 woo409 757 ESCRIPT_DLL_API
212 jfenwick 1796 DataTypes::ValueType&
213 jfenwick 2271 getVectorRW();
214 jgs 82
215 jfenwick 1796 ESCRIPT_DLL_API
216     const DataTypes::ValueType&
217 jfenwick 2271 getVectorRO() const;
218 jfenwick 1796
219    
220 jfenwick 2271
221 jgs 82 /**
222     \brief
223 jgs 102 Return the number of doubles stored for the Data.
224 jgs 82 */
225 woo409 757 ESCRIPT_DLL_API
226 jgs 102 virtual
227     ValueType::size_type
228     getLength() const;
229 jgs 82
230     /**
231     \brief
232     Factory method that returns a newly created DataExpanded.
233     The caller is reponsible for managing the object created.
234 jgs 117
235 jgs 82 \param region - Input - Region to copy.
236     */
237 woo409 757 ESCRIPT_DLL_API
238 jgs 102 virtual
239     DataAbstract*
240 jfenwick 1796 getSlice(const DataTypes::RegionType& region) const;
241 jgs 82
242     /**
243     \brief
244     Copy the specified region from the given value.
245 jgs 117
246     \param value - Input - Data object to copy from.
247 jgs 82 \param region - Input - Region to copy.
248     */
249 woo409 757 ESCRIPT_DLL_API
250 jgs 102 virtual
251     void
252     setSlice(const DataAbstract* value,
253 jfenwick 1796 const DataTypes::RegionType& region);
254 jgs 82
255 gross 580 /**
256     \brief
257 gross 1358 setTaggedValue
258    
259     Description:
260     uses tag to set a new value
261    
262     \param tagKey - Input - Integer key.
263 jfenwick 1796 \param pointshape - Input - The shape of the value parameter
264 jfenwick 2521 \param value - Input -
265     \param dataOffset - Input - where in the value parameter to start reading the data point value.
266 gross 1358 */
267 jfenwick 1796 void
268 gross 1358 setTaggedValue(int tagKey,
269 jfenwick 1796 const DataTypes::ShapeType& pointshape,
270     const DataTypes::ValueType& value,
271     int dataOffset=0);
272 gross 1358
273 jfenwick 1796
274    
275 gross 1358 /**
276     \brief
277 ksteube 775 Computes a symmetric matrix (A + AT) / 2
278    
279     \param ev - Output - symmetric matrix
280    
281     */
282 gross 800 ESCRIPT_DLL_API
283 ksteube 775 virtual void
284     symmetric(DataAbstract* ev);
285    
286     /**
287     \brief
288     Computes a nonsymmetric matrix (A - AT) / 2
289    
290     \param ev - Output - nonsymmetric matrix
291    
292     */
293 gross 800 ESCRIPT_DLL_API
294 ksteube 775 virtual void
295     nonsymmetric(DataAbstract* ev);
296    
297     /**
298     \brief
299     Computes the trace of a matrix
300    
301     \param ev - Output - trace of your matrix
302 jfenwick 2521 \param axis_offset -
303 ksteube 775
304     */
305 gross 800 ESCRIPT_DLL_API
306 ksteube 775 virtual void
307 gross 800 trace(DataAbstract* ev, int axis_offset);
308 ksteube 775
309     /**
310     \brief
311     Transpose each data point of this Data object around the given axis.
312    
313     \param ev - Output - transpose of your matrix
314 jfenwick 2521 \param axis_offset -
315 ksteube 775 */
316 gross 800 ESCRIPT_DLL_API
317 ksteube 775 virtual void
318     transpose(DataAbstract* ev, int axis_offset);
319    
320     /**
321     \brief
322 gross 804 swaps components axis0 and axis1
323 gross 800
324     \param ev - Output - swapped components
325 jfenwick 2521 \param axis0
326     \param axis1
327 gross 800 */
328     ESCRIPT_DLL_API
329     virtual void
330 gross 804 swapaxes(DataAbstract* ev, int axis0, int axis1);
331 gross 800
332    
333     /**
334     \brief
335 gross 580 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
336    
337     \param ev - Output - eigenvalues in increasing order at each data point
338    
339     */
340 woo409 757 ESCRIPT_DLL_API
341 gross 580 virtual void
342     eigenvalues(DataAbstract* ev);
343    
344     /**
345     \brief
346     solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
347    
348     \param ev - Output - eigenvalues in increasing order at each data point
349     \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
350     and the first nonzero component is positive.
351     \param tol - Input - eigenvalue with relative distance tol are treated as equal.
352    
353     */
354    
355 woo409 757 ESCRIPT_DLL_API
356 gross 580 virtual void
357     eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
358    
359 gross 1487 /**
360     * \brief
361     * reorders data sample ordered by reference_ids to the ordering of the functions space
362     *
363     * \param reference_ids - Input - reference_ids used for current ordering
364     * */
365     ESCRIPT_DLL_API
366     virtual void
367     reorderByReferenceIDs(int *reference_ids);
368 gross 580
369 gross 1487
370    
371 jgs 82 protected:
372    
373     private:
374    
375     /**
376     \brief
377 jgs 117 Common initialisation called from constructors.
378 jgs 82
379     Description:
380 jgs 117 Common initialisation called from constructors.
381    
382     Resizes the underlying data array to provide sufficient storage for the
383     given shape and number of data points, and creates the corresponding
384     DataArrayView of this data.
385    
386 jgs 82 \param noSamples - Input - number of samples.
387 jgs 117 \param noDataPointsPerSample - Input - number of data points per sample.
388 jgs 82 */
389 jgs 102 void
390 jfenwick 1796 initialise(int noSamples,
391 jgs 102 int noDataPointsPerSample);
392 jgs 82
393     /**
394     \brief
395 jgs 126 Copy the given data point value to all data points in this object.
396 jgs 82
397     Description:
398 jgs 117 Copy the given data point to all data points in this object.
399    
400     \param value Input - A single data point value.
401 jgs 82 */
402 jgs 102 void
403 jfenwick 1796 copy(const DataConstant& value);
404 jgs 82
405 jfenwick 1796
406    
407 jgs 126 /**
408     \brief
409 jfenwick 2458 Copy the given data point value to all data points in this object.
410 jgs 126
411     \param value Input - A single data point value.
412     */
413 jfenwick 2271
414 jgs 102 void
415 jfenwick 2271 copy(const WrappedArray& value);
416 jgs 102
417 jgs 126
418 gross 921 /**
419     \brief
420 gross 922 Copy a double value to the data point dataPointNo of sample sampleNo in this object.
421    
422     Description:
423     Copy a double value to the data point dataPointNo of sample sampleNo in this object.
424    
425     \param sampleNo Input - sample number
426     \param dataPointNo Input - data point of the sample
427     \param value Input - new values for the data point
428     */
429     ESCRIPT_DLL_API
430     virtual void
431     copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
432    
433    
434     /**
435     \brief
436 jfenwick 2458 Copy the value to the data point dataPointNo of sample sampleNo in this object.
437 gross 921
438     \param sampleNo Input - sample number
439     \param dataPointNo Input - data point of the sample
440     \param value Input - new values for the data point
441     */
442 jfenwick 2271 ESCRIPT_DLL_API
443     virtual void
444     copyToDataPoint(const int sampleNo, const int dataPointNo, const WrappedArray& value);
445 gross 921
446 jgs 82 //
447 jgs 117 // The main data storage array, a 2D array of data blocks.
448     // noSamples * noDataPointsPerSample
449 jgs 82 DataBlocks2D m_data;
450    
451     };
452    
453     } // end of namespace
454 jgs 102
455 jgs 100 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26