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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2644 - (hide annotations)
Wed Sep 2 04:14:03 2009 UTC (10 years, 4 months ago) by jfenwick
File MIME type: text/plain
File size: 6521 byte(s)
Add unit tests for saveDataCSV which should be ready for use now.
Keyword args are now output in sorted order.

Removed some unneeded functions.
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_DataConstant_20040323_H
16 jgs 82 #define escript_DataConstant_20040323_H
17 woo409 757 #include "system_dep.h"
18 jgs 82
19 jfenwick 2005 #include "DataReady.h"
20 jfenwick 2271 #include "WrappedArray.h"
21 jgs 82
22     #include <boost/python/numeric.hpp>
23    
24     namespace escript {
25 jgs 102
26 jgs 82 /**
27     \brief
28 jgs 102 DataConstant stores a single data point which represents the entire
29 jgs 82 function space.
30    
31     Description:
32 jgs 102 DataConstant stores a single data point which represents the entire
33 jgs 82 function space.
34     */
35 jfenwick 2005 class DataConstant : public DataReady {
36     typedef DataReady parent;
37 jgs 82 public:
38    
39     /**
40     \brief
41 jgs 102 Constructor for DataConstant objects.
42 jgs 82
43     Description:
44 jgs 102 Constructor for DataConstant objects.
45 jgs 82
46 jgs 102 \param value - Input - Data value for a single point.
47     \param what - Input - A description of what this data object represents.
48     */
49 woo409 757 ESCRIPT_DLL_API
50 jfenwick 2271 DataConstant(const WrappedArray& value,
51 jgs 102 const FunctionSpace& what);
52 jgs 100
53 jfenwick 2271
54 jgs 82 /**
55     \brief
56     Copy constructor. Performs a deep copy.
57     */
58 woo409 757 ESCRIPT_DLL_API
59 jgs 82 DataConstant(const DataConstant& other);
60 jgs 102
61 jgs 82
62     /**
63     \brief
64 jgs 102 Alternative constructor for DataConstant objects.
65 jgs 82
66     Description:
67 jgs 102 Alternative Constructor for DataConstant objects.
68     \param other - Input - Data object to copy from.
69     \param region - Input - region to copy.
70 jgs 82 */
71 woo409 757 ESCRIPT_DLL_API
72 jgs 102 DataConstant(const DataConstant& other,
73 jfenwick 1796 const DataTypes::RegionType& region);
74 jgs 102
75 jgs 82 /**
76     \brief
77 jgs 119 Alternative constructor for DataConstant objects.
78    
79     Description:
80     Alternative Constructor for DataConstant objects.
81     \param what - Input - A description of what this data object represents.
82     \param shape - Input - the shape of each data-point.
83     \param data - the data values for each data-point.
84     */
85 woo409 757 ESCRIPT_DLL_API
86 jgs 119 DataConstant(const FunctionSpace& what,
87 jfenwick 1796 const DataTypes::ShapeType &shape,
88     const DataTypes::ValueType &data);
89 jgs 119
90 jfenwick 2005
91     ESCRIPT_DLL_API
92     bool
93     isConstant() const
94     {
95     return true;
96     };
97    
98 jgs 119 /**
99     \brief
100 jgs 82 Write the data as a string.
101     */
102 woo409 757 ESCRIPT_DLL_API
103 jgs 102 std::string
104     toString() const;
105 jfenwick 1799
106     /**
107     \brief Return a deep copy of the current object.
108     */
109     ESCRIPT_DLL_API
110     virtual
111     DataAbstract*
112     deepCopy();
113    
114    
115 gross 950 /**
116     \brief
117     dumps the object into a netCDF file
118     */
119     ESCRIPT_DLL_API
120     virtual
121     void
122     dump(const std::string fileName) const;
123 jgs 102
124 gross 1118 /**
125     \brief
126     sets all values to zero
127     */
128     ESCRIPT_DLL_API
129     virtual
130     void
131     setToZero();
132 gross 950
133 jgs 82 /**
134     \brief
135 jgs 102 Return the offset for the given sample. This is a somewhat artificial notion
136 jgs 82 but returns the offset in bytes for the given point into the container
137     holding the point data. Only really necessary to avoid many DataArrayView
138     objects.
139 jgs 102 \param sampleNo - Input - sample number.
140     \param dataPointNo - Input - data point number for the sample.
141 jgs 82 */
142 woo409 757 ESCRIPT_DLL_API
143 jgs 102 virtual
144 jfenwick 1796 DataTypes::ValueType::size_type
145 jgs 102 getPointOffset(int sampleNo,
146     int dataPointNo) const;
147    
148 jfenwick 2005 ESCRIPT_DLL_API
149     virtual
150     DataTypes::ValueType::size_type
151     getPointOffset(int sampleNo,
152     int dataPointNo);
153    
154 jgs 82 /**
155     \brief
156 jgs 102 Return the number of doubles stored for the Data object.
157 jgs 82 */
158 woo409 757 ESCRIPT_DLL_API
159 jgs 102 virtual
160 jfenwick 1796 DataTypes::ValueType::size_type
161 jgs 102 getLength() const;
162    
163 jgs 82 /**
164     \brief
165 jgs 102 Factory method that returns a newly created DataConstant object
166     sliced from the specified region of this object.
167 jgs 82 The caller is reponsible for managing the object created.
168 jgs 102 \param region - Input - region to slice from this object.
169 jgs 82 */
170 woo409 757 ESCRIPT_DLL_API
171 jgs 102 virtual
172     DataAbstract*
173 jfenwick 1796 getSlice(const DataTypes::RegionType& region) const;
174 jgs 102
175     /**
176 jgs 82 \brief
177     Copy the specified region from the given value.
178 jgs 102 \param value - Input - Data object to copy from.
179     \param region - Input - Region to copy.
180 jgs 82 */
181 woo409 757 ESCRIPT_DLL_API
182 jgs 102 virtual
183     void
184     setSlice(const DataAbstract* value,
185 jfenwick 1796 const DataTypes::RegionType& region);
186 jgs 102
187 jgs 123
188     /**
189 gross 580 \brief
190 ksteube 775 Computes a symmetric matrix (A + AT) / 2
191    
192     \param ev - Output - symmetric matrix
193    
194     */
195 gross 800 ESCRIPT_DLL_API
196 ksteube 775 virtual void
197     symmetric(DataAbstract* ev);
198    
199     /**
200     \brief
201     Computes a nonsymmetric matrix (A - AT) / 2
202    
203     \param ev - Output - nonsymmetric matrix
204    
205     */
206 gross 800 ESCRIPT_DLL_API
207 ksteube 775 virtual void
208     nonsymmetric(DataAbstract* ev);
209    
210     /**
211     \brief
212     Computes the trace of a matrix
213    
214     \param ev - Output - trace of matrix
215 jfenwick 2519 \param axis_offset
216 ksteube 775
217     */
218 gross 800 ESCRIPT_DLL_API
219 ksteube 775 virtual void
220 gross 800 trace(DataAbstract* ev, int axis_offset);
221 ksteube 775
222     /**
223     \brief
224     Transpose each data point of this Data object around the given axis.
225    
226     \param ev - Output - transpose of matrix
227 jfenwick 2519 \param axis_offset
228 ksteube 775 */
229 gross 800 ESCRIPT_DLL_API
230 ksteube 775 virtual void
231     transpose(DataAbstract* ev, int axis_offset);
232    
233     /**
234     \brief
235 gross 804 swaps components axis0 and axis1
236 gross 800
237     \param ev - Output - swapped components
238 jfenwick 2519 \param axis0
239     \param axis1
240 gross 800 */
241     ESCRIPT_DLL_API
242     virtual void
243 gross 804 swapaxes(DataAbstract* ev, int axis0, int axis1);
244 gross 800
245    
246     /**
247     \brief
248 gross 580 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
249    
250     \param ev - Output - eigenvalues in increasing order at each data point
251    
252     */
253 woo409 757 ESCRIPT_DLL_API
254 gross 580 virtual void
255     eigenvalues(DataAbstract* ev);
256    
257     /**
258     \brief
259     solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
260    
261     \param ev - Output - eigenvalues in increasing order at each data point
262     \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
263     and the first nonzero component is positive.
264     \param tol - Input - eigenvalue with relative distance tol are treated as equal.
265    
266     */
267    
268 woo409 757 ESCRIPT_DLL_API
269 gross 580 virtual void
270     eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
271    
272    
273 jfenwick 1796 /**
274     \brief
275     Return a reference to the underlying DataVector.
276     */
277     ESCRIPT_DLL_API
278     DataTypes::ValueType&
279 jfenwick 2271 getVectorRW();
280 jfenwick 1796
281 jfenwick 2271
282 jfenwick 1796 ESCRIPT_DLL_API
283     const DataTypes::ValueType&
284 jfenwick 2271 getVectorRO() const;
285 jfenwick 1796
286 jgs 82 protected:
287    
288     private:
289     //
290 jgs 102 // the actual data
291 jfenwick 1796 DataTypes::ValueType m_data;
292 jgs 102
293 jgs 82 };
294    
295     } // end of namespace
296     #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26