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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2881 - (show annotations)
Thu Jan 28 02:03:15 2010 UTC (9 years, 6 months ago) by jfenwick
File MIME type: text/plain
File size: 6800 byte(s)
Don't panic.
Updating copyright stamps

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26