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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1796 - (show annotations)
Wed Sep 17 01:45:46 2008 UTC (10 years, 11 months ago) by jfenwick
File MIME type: text/plain
File size: 7018 byte(s)
Merged noarrayview branch onto trunk.


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 \brief
110 dumps the object into a netCDF file
111 */
112 ESCRIPT_DLL_API
113 virtual
114 void
115 dump(const std::string fileName) const;
116
117 /**
118 \brief
119 sets all values to zero
120 */
121 ESCRIPT_DLL_API
122 virtual
123 void
124 setToZero();
125
126 /**
127 \brief
128 Return the offset for the given sample. This is a somewhat artificial notion
129 but returns the offset in bytes for the given point into the container
130 holding the point data. Only really necessary to avoid many DataArrayView
131 objects.
132 \param sampleNo - Input - sample number.
133 \param dataPointNo - Input - data point number for the sample.
134 */
135 ESCRIPT_DLL_API
136 virtual
137 DataTypes::ValueType::size_type
138 getPointOffset(int sampleNo,
139 int dataPointNo) const;
140
141 // /**
142 /* \brief
143 Return a view into the data for the data point specified.
144 \param sampleNo - Input - sample number.
145 \param dataPointNo - Input - data point number for the sample.*/
146 // */
147 // ESCRIPT_DLL_API
148 // virtual
149 // DataArrayView
150 // getDataPoint(int sampleNo,
151 // int dataPointNo);
152
153 /**
154 \brief
155 Return the number of doubles stored for the Data object.
156 */
157 ESCRIPT_DLL_API
158 virtual
159 DataTypes::ValueType::size_type
160 getLength() const;
161
162 /**
163 \brief
164 Factory method that returns a newly created DataConstant object
165 sliced from the specified region of this object.
166 The caller is reponsible for managing the object created.
167 \param region - Input - region to slice from this object.
168 */
169 ESCRIPT_DLL_API
170 virtual
171 DataAbstract*
172 getSlice(const DataTypes::RegionType& region) const;
173
174 /**
175 \brief
176 Copy the specified region from the given value.
177 \param value - Input - Data object to copy from.
178 \param region - Input - Region to copy.
179 */
180 ESCRIPT_DLL_API
181 virtual
182 void
183 setSlice(const DataAbstract* value,
184 const DataTypes::RegionType& region);
185
186
187 /**
188 \brief
189 Computes a symmetric matrix (A + AT) / 2
190
191 \param ev - Output - symmetric matrix
192
193 */
194 ESCRIPT_DLL_API
195 virtual void
196 symmetric(DataAbstract* ev);
197
198 /**
199 \brief
200 Computes a nonsymmetric matrix (A - AT) / 2
201
202 \param ev - Output - nonsymmetric matrix
203
204 */
205 ESCRIPT_DLL_API
206 virtual void
207 nonsymmetric(DataAbstract* ev);
208
209 /**
210 \brief
211 Computes the trace of a matrix
212
213 \param ev - Output - trace of matrix
214
215 */
216 ESCRIPT_DLL_API
217 virtual void
218 trace(DataAbstract* ev, int axis_offset);
219
220 /**
221 \brief
222 Transpose each data point of this Data object around the given axis.
223
224 \param ev - Output - transpose of matrix
225
226 */
227 ESCRIPT_DLL_API
228 virtual void
229 transpose(DataAbstract* ev, int axis_offset);
230
231 /**
232 \brief
233 swaps components axis0 and axis1
234
235 \param ev - Output - swapped components
236
237 */
238 ESCRIPT_DLL_API
239 virtual void
240 swapaxes(DataAbstract* ev, int axis0, int axis1);
241
242
243 /**
244 \brief
245 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
246
247 \param ev - Output - eigenvalues in increasing order at each data point
248
249 */
250 ESCRIPT_DLL_API
251 virtual void
252 eigenvalues(DataAbstract* ev);
253
254 /**
255 \brief
256 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
257
258 \param ev - Output - eigenvalues in increasing order at each data point
259 \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
260 and the first nonzero component is positive.
261 \param tol - Input - eigenvalue with relative distance tol are treated as equal.
262
263 */
264
265 ESCRIPT_DLL_API
266 virtual void
267 eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
268
269
270 /**
271 \brief
272 Return a reference to the underlying DataVector.
273 */
274 ESCRIPT_DLL_API
275 DataTypes::ValueType&
276 getVector();
277
278 ESCRIPT_DLL_API
279 const DataTypes::ValueType&
280 getVector() const;
281
282
283 protected:
284
285 private:
286 //
287 // the actual data
288 DataTypes::ValueType m_data;
289
290 };
291
292 inline
293 DataTypes::ValueType&
294 DataConstant::getVector()
295 {
296 return m_data;
297 }
298
299 inline
300 const DataTypes::ValueType&
301 DataConstant::getVector() const
302 {
303 return m_data;
304 }
305
306
307 } // end of namespace
308 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26