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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26