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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2644 - (show annotations)
Wed Sep 2 04:14:03 2009 UTC (9 years, 11 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
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2009 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
14
15 #if !defined escript_DataConstant_20040323_H
16 #define escript_DataConstant_20040323_H
17 #include "system_dep.h"
18
19 #include "DataReady.h"
20 #include "WrappedArray.h"
21
22 #include <boost/python/numeric.hpp>
23
24 namespace escript {
25
26 /**
27 \brief
28 DataConstant stores a single data point which represents the entire
29 function space.
30
31 Description:
32 DataConstant stores a single data point which represents the entire
33 function space.
34 */
35 class DataConstant : public DataReady {
36 typedef DataReady parent;
37 public:
38
39 /**
40 \brief
41 Constructor for DataConstant objects.
42
43 Description:
44 Constructor for DataConstant objects.
45
46 \param value - Input - Data value for a single point.
47 \param what - Input - A description of what this data object represents.
48 */
49 ESCRIPT_DLL_API
50 DataConstant(const WrappedArray& value,
51 const FunctionSpace& what);
52
53
54 /**
55 \brief
56 Copy constructor. Performs a deep copy.
57 */
58 ESCRIPT_DLL_API
59 DataConstant(const DataConstant& other);
60
61
62 /**
63 \brief
64 Alternative constructor for DataConstant objects.
65
66 Description:
67 Alternative Constructor for DataConstant objects.
68 \param other - Input - Data object to copy from.
69 \param region - Input - region to copy.
70 */
71 ESCRIPT_DLL_API
72 DataConstant(const DataConstant& other,
73 const DataTypes::RegionType& region);
74
75 /**
76 \brief
77 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 ESCRIPT_DLL_API
86 DataConstant(const FunctionSpace& what,
87 const DataTypes::ShapeType &shape,
88 const DataTypes::ValueType &data);
89
90
91 ESCRIPT_DLL_API
92 bool
93 isConstant() const
94 {
95 return true;
96 };
97
98 /**
99 \brief
100 Write the data as a string.
101 */
102 ESCRIPT_DLL_API
103 std::string
104 toString() const;
105
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 /**
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
124 /**
125 \brief
126 sets all values to zero
127 */
128 ESCRIPT_DLL_API
129 virtual
130 void
131 setToZero();
132
133 /**
134 \brief
135 Return the offset for the given sample. This is a somewhat artificial notion
136 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 \param sampleNo - Input - sample number.
140 \param dataPointNo - Input - data point number for the sample.
141 */
142 ESCRIPT_DLL_API
143 virtual
144 DataTypes::ValueType::size_type
145 getPointOffset(int sampleNo,
146 int dataPointNo) const;
147
148 ESCRIPT_DLL_API
149 virtual
150 DataTypes::ValueType::size_type
151 getPointOffset(int sampleNo,
152 int dataPointNo);
153
154 /**
155 \brief
156 Return the number of doubles stored for the Data object.
157 */
158 ESCRIPT_DLL_API
159 virtual
160 DataTypes::ValueType::size_type
161 getLength() const;
162
163 /**
164 \brief
165 Factory method that returns a newly created DataConstant object
166 sliced from the specified region of this object.
167 The caller is reponsible for managing the object created.
168 \param region - Input - region to slice from this object.
169 */
170 ESCRIPT_DLL_API
171 virtual
172 DataAbstract*
173 getSlice(const DataTypes::RegionType& region) const;
174
175 /**
176 \brief
177 Copy the specified region from the given value.
178 \param value - Input - Data object to copy from.
179 \param region - Input - Region to copy.
180 */
181 ESCRIPT_DLL_API
182 virtual
183 void
184 setSlice(const DataAbstract* value,
185 const DataTypes::RegionType& region);
186
187
188 /**
189 \brief
190 Computes a symmetric matrix (A + AT) / 2
191
192 \param ev - Output - symmetric matrix
193
194 */
195 ESCRIPT_DLL_API
196 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 ESCRIPT_DLL_API
207 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 \param axis_offset
216
217 */
218 ESCRIPT_DLL_API
219 virtual void
220 trace(DataAbstract* ev, int axis_offset);
221
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 \param axis_offset
228 */
229 ESCRIPT_DLL_API
230 virtual void
231 transpose(DataAbstract* ev, int axis_offset);
232
233 /**
234 \brief
235 swaps components axis0 and axis1
236
237 \param ev - Output - swapped components
238 \param axis0
239 \param axis1
240 */
241 ESCRIPT_DLL_API
242 virtual void
243 swapaxes(DataAbstract* ev, int axis0, int axis1);
244
245
246 /**
247 \brief
248 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 ESCRIPT_DLL_API
254 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 ESCRIPT_DLL_API
269 virtual void
270 eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
271
272
273 /**
274 \brief
275 Return a reference to the underlying DataVector.
276 */
277 ESCRIPT_DLL_API
278 DataTypes::ValueType&
279 getVectorRW();
280
281
282 ESCRIPT_DLL_API
283 const DataTypes::ValueType&
284 getVectorRO() const;
285
286 protected:
287
288 private:
289 //
290 // the actual data
291 DataTypes::ValueType m_data;
292
293 };
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