/[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 1889 - (show annotations)
Thu Oct 16 05:57:09 2008 UTC (10 years, 11 months ago) by jfenwick
File MIME type: text/plain
File size: 7204 byte(s)
Branch commit
Rewrote resolve to take into account Tagged and Constant Data.
Mixing expanded and Tagged does not work yet.

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 // /**
160 /* \brief
161 Return a view into the data for the data point specified.
162 \param sampleNo - Input - sample number.
163 \param dataPointNo - Input - data point number for the sample.*/
164 // */
165 // ESCRIPT_DLL_API
166 // virtual
167 // DataArrayView
168 // getDataPoint(int sampleNo,
169 // int dataPointNo);
170
171 /**
172 \brief
173 Return the number of doubles stored for the Data object.
174 */
175 ESCRIPT_DLL_API
176 virtual
177 DataTypes::ValueType::size_type
178 getLength() const;
179
180 /**
181 \brief
182 Factory method that returns a newly created DataConstant object
183 sliced from the specified region of this object.
184 The caller is reponsible for managing the object created.
185 \param region - Input - region to slice from this object.
186 */
187 ESCRIPT_DLL_API
188 virtual
189 DataAbstract*
190 getSlice(const DataTypes::RegionType& region) const;
191
192 /**
193 \brief
194 Copy the specified region from the given value.
195 \param value - Input - Data object to copy from.
196 \param region - Input - Region to copy.
197 */
198 ESCRIPT_DLL_API
199 virtual
200 void
201 setSlice(const DataAbstract* value,
202 const DataTypes::RegionType& region);
203
204
205 /**
206 \brief
207 Computes a symmetric matrix (A + AT) / 2
208
209 \param ev - Output - symmetric matrix
210
211 */
212 ESCRIPT_DLL_API
213 virtual void
214 symmetric(DataAbstract* ev);
215
216 /**
217 \brief
218 Computes a nonsymmetric matrix (A - AT) / 2
219
220 \param ev - Output - nonsymmetric matrix
221
222 */
223 ESCRIPT_DLL_API
224 virtual void
225 nonsymmetric(DataAbstract* ev);
226
227 /**
228 \brief
229 Computes the trace of a matrix
230
231 \param ev - Output - trace of matrix
232
233 */
234 ESCRIPT_DLL_API
235 virtual void
236 trace(DataAbstract* ev, int axis_offset);
237
238 /**
239 \brief
240 Transpose each data point of this Data object around the given axis.
241
242 \param ev - Output - transpose of matrix
243
244 */
245 ESCRIPT_DLL_API
246 virtual void
247 transpose(DataAbstract* ev, int axis_offset);
248
249 /**
250 \brief
251 swaps components axis0 and axis1
252
253 \param ev - Output - swapped components
254
255 */
256 ESCRIPT_DLL_API
257 virtual void
258 swapaxes(DataAbstract* ev, int axis0, int axis1);
259
260
261 /**
262 \brief
263 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
264
265 \param ev - Output - eigenvalues in increasing order at each data point
266
267 */
268 ESCRIPT_DLL_API
269 virtual void
270 eigenvalues(DataAbstract* ev);
271
272 /**
273 \brief
274 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
275
276 \param ev - Output - eigenvalues in increasing order at each data point
277 \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
278 and the first nonzero component is positive.
279 \param tol - Input - eigenvalue with relative distance tol are treated as equal.
280
281 */
282
283 ESCRIPT_DLL_API
284 virtual void
285 eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
286
287
288 /**
289 \brief
290 Return a reference to the underlying DataVector.
291 */
292 ESCRIPT_DLL_API
293 DataTypes::ValueType&
294 getVector();
295
296 ESCRIPT_DLL_API
297 const DataTypes::ValueType&
298 getVector() const;
299
300
301 protected:
302
303 private:
304 //
305 // the actual data
306 DataTypes::ValueType m_data;
307
308 };
309
310 inline
311 DataTypes::ValueType&
312 DataConstant::getVector()
313 {
314 return m_data;
315 }
316
317 inline
318 const DataTypes::ValueType&
319 DataConstant::getVector() const
320 {
321 return m_data;
322 }
323
324
325 } // end of namespace
326 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26