/[escript]/branches/schroedinger/escript/src/DataConstant.h
ViewVC logotype

Contents of /branches/schroedinger/escript/src/DataConstant.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1935 - (show annotations)
Mon Oct 27 06:06:39 2008 UTC (10 years, 5 months ago) by jfenwick
File MIME type: text/plain
File size: 7333 byte(s)
Branch commit
More cleanup of DataTestCase - still don't have all the LazyTests in 
there yet.
Added tests to make sure the resolve() operation does what it is 
supposed to.
Added non-constant versions of getPointOffset to DataAbstract 
classes.
Fixed a bug in deepCopy on DataLazy.
Changed setToZero to not check the type of the data.

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26