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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1796 - (hide annotations)
Wed Sep 17 01:45:46 2008 UTC (11 years, 2 months ago) by jfenwick
File MIME type: text/plain
File size: 11553 byte(s)
Merged noarrayview branch onto trunk.


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26