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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1799 - (show annotations)
Wed Sep 17 06:33:18 2008 UTC (11 years, 2 months ago) by jfenwick
File MIME type: text/plain
File size: 7144 byte(s)
Added Data::copySelf() [Note: this is exposed as copy() in python].
This method returns a pointer to a deep copy of the target.
There are c++ tests but no python tests for this yet.

All DataAbstracts now have a deepCopy() which simplifies the 
implementation of the compy methods.


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