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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2119 - (show annotations)
Tue Dec 2 06:06:04 2008 UTC (11 years, 10 months ago) by jfenwick
File MIME type: text/plain
File size: 7054 byte(s)
Branch commit.
Threading Wrapped Array through the code.
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 #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 boost::python::numeric::array& value,
51 const FunctionSpace& what);
52
53 ESCRIPT_DLL_API
54 DataConstant(const WrappedArray& value,
55 const FunctionSpace& what);
56
57
58 /**
59 \brief
60 Copy constructor. Performs a deep copy.
61 */
62 ESCRIPT_DLL_API
63 DataConstant(const DataConstant& other);
64
65
66 /**
67 \brief
68 Alternative constructor for DataConstant objects.
69
70 Description:
71 Alternative Constructor for DataConstant objects.
72 \param other - Input - Data object to copy from.
73 \param region - Input - region to copy.
74 */
75 ESCRIPT_DLL_API
76 DataConstant(const DataConstant& other,
77 const DataTypes::RegionType& region);
78
79 /**
80 \brief
81 Alternative constructor for DataConstant objects.
82
83 Description:
84 Alternative Constructor for DataConstant objects.
85 \param what - Input - A description of what this data object represents.
86 \param shape - Input - the shape of each data-point.
87 \param data - the data values for each data-point.
88 */
89 ESCRIPT_DLL_API
90 DataConstant(const FunctionSpace& what,
91 const DataTypes::ShapeType &shape,
92 const DataTypes::ValueType &data);
93
94
95 ESCRIPT_DLL_API
96 bool
97 isConstant() const
98 {
99 return true;
100 };
101
102
103 /**
104 \brief
105 Write the data as a string.
106 */
107 ESCRIPT_DLL_API
108 std::string
109 toString() const;
110
111 /**
112 \brief Return a deep copy of the current object.
113 */
114 ESCRIPT_DLL_API
115 virtual
116 DataAbstract*
117 deepCopy();
118
119
120 /**
121 \brief
122 dumps the object into a netCDF file
123 */
124 ESCRIPT_DLL_API
125 virtual
126 void
127 dump(const std::string fileName) const;
128
129 /**
130 \brief
131 sets all values to zero
132 */
133 ESCRIPT_DLL_API
134 virtual
135 void
136 setToZero();
137
138 /**
139 \brief
140 Return the offset for the given sample. This is a somewhat artificial notion
141 but returns the offset in bytes for the given point into the container
142 holding the point data. Only really necessary to avoid many DataArrayView
143 objects.
144 \param sampleNo - Input - sample number.
145 \param dataPointNo - Input - data point number for the sample.
146 */
147 ESCRIPT_DLL_API
148 virtual
149 DataTypes::ValueType::size_type
150 getPointOffset(int sampleNo,
151 int dataPointNo) const;
152
153 ESCRIPT_DLL_API
154 virtual
155 DataTypes::ValueType::size_type
156 getPointOffset(int sampleNo,
157 int dataPointNo);
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