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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1808 - (show annotations)
Thu Sep 25 03:14:56 2008 UTC (11 years, 1 month ago) by jfenwick
File MIME type: text/plain
File size: 10294 byte(s)
Removed some commented out lines.
Modified DataExpanded to not throw when creating objects with zero 
samples.
Modified toString() to report "(data contains no samples)" rather than 
printing a blank line.
Modified DataExpanded::dump() and load so that they do not attempt so 
save/load the ids and data fields if the data object contains no 
samples.



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_DataExpanded_20040323_H
17 #define escript_DataExpanded_20040323_H
18 #include "system_dep.h"
19
20 #include "DataAbstract.h"
21 #include "DataBlocks2D.h"
22
23 #include <boost/python/numeric.hpp>
24
25 namespace escript {
26
27 //
28 // Forward declarations of other Data types.
29 class DataConstant;
30 class DataTagged;
31
32 /**
33 \brief
34 Give a short description of what DataExpanded does.
35
36 Description:
37 Give a detailed description of DataExpanded.
38
39 Template Parameters:
40 For templates describe any conditions that the parameters used in the
41 template must satisfy.
42 */
43
44 class DataExpanded : public DataAbstract {
45
46 public:
47
48 /**
49 \brief
50 Constructor for DataExpanded.
51
52 Description:
53 Constructor for DataExpanded.
54
55 The given single data value is copied to all the data points in
56 this data object, where the number of data points is defined by
57 the given function space.
58
59 \param value - Input - A single data value.
60 \param what - Input - A description of what this data represents.
61 */
62 ESCRIPT_DLL_API
63 DataExpanded(const boost::python::numeric::array& value,
64 const FunctionSpace& what);
65
66 /**
67 \brief
68 Alternative constructor for DataExpanded that copies a slice from
69 another DataExpanded.
70
71 \param other - Input - DataExpanded object to slice from.
72 \param region - Input - region to copy.
73 */
74 ESCRIPT_DLL_API
75 DataExpanded(const DataExpanded& other,
76 const DataTypes::RegionType& region);
77
78 /**
79 \brief
80 Alternative constructor for DataExpanded objects.
81
82 Description:
83 Alternative Constructor for DataExpanded objects.
84 \param what - Input - A description of what this data object represents.
85 \param shape - Input - the shape of each data-point.
86 \param data - the array of data values for the data-points.
87
88 TODO Note that this constructor will also copy data to all points if it only contains enough elements to hold a single point. ie this is the merge of two separate constructors.
89 */
90 ESCRIPT_DLL_API
91 DataExpanded(const FunctionSpace& what,
92 const DataTypes::ShapeType &shape,
93 const DataTypes::ValueType &data);
94
95 /**
96 \brief
97 Copy constructor for DataExpanded.
98 Performs a deep copy from another DataExpanded.
99 */
100 ESCRIPT_DLL_API
101 DataExpanded(const DataExpanded& other);
102
103 /**
104 \brief
105 Copy constructor for DataExpanded.
106 Construct a DataExpanded from a DataConstant.
107 */
108 ESCRIPT_DLL_API
109 DataExpanded(const DataConstant& other);
110
111 /**
112 \brief
113 Copy constructor for DataExpanded.
114 Construct a DataExpanded from a DataTagged.
115 */
116 ESCRIPT_DLL_API
117 DataExpanded(const DataTagged& other);
118
119 /**
120 \brief
121 Default destructor for DataExpanded.
122 */
123 ESCRIPT_DLL_API
124 virtual
125 ~DataExpanded();
126
127 /**
128 \brief
129 Return a textual representation of the data.
130 */
131 ESCRIPT_DLL_API
132 virtual
133 std::string
134 toString() const;
135
136 /**
137 \brief Return a deep copy of the current object.
138 */
139 ESCRIPT_DLL_API
140 virtual
141 DataAbstract*
142 deepCopy();
143
144
145 /**
146 \brief
147 dumps the object into a netCDF file
148 */
149 ESCRIPT_DLL_API
150 virtual
151 void
152 dump(const std::string fileName) const;
153
154 /**
155 \brief
156 sets all values to zero
157 */
158 ESCRIPT_DLL_API
159 virtual
160 void
161 setToZero();
162
163 /**
164 \brief
165 Return the offset for the given given data point. This returns
166 the offset in bytes for the given point into the container
167 holding the point data.
168
169 \param sampleNo - Input - sample number.
170 \param dataPointNo - Input - data point number.
171 */
172 ESCRIPT_DLL_API
173 virtual
174 DataTypes::ValueType::size_type
175 getPointOffset(int sampleNo,
176 int dataPointNo) const;
177
178 /**
179 \brief
180 Return a a reference to the underlying DataVector.
181 */
182
183 ESCRIPT_DLL_API
184 DataTypes::ValueType&
185 getVector();
186
187 ESCRIPT_DLL_API
188 const DataTypes::ValueType&
189 getVector() const;
190
191
192 /**
193 \brief
194 Return the number of doubles stored for the Data.
195 */
196 ESCRIPT_DLL_API
197 virtual
198 ValueType::size_type
199 getLength() const;
200
201 /**
202 \brief
203 Factory method that returns a newly created DataExpanded.
204 The caller is reponsible for managing the object created.
205
206 \param region - Input - Region to copy.
207 */
208 ESCRIPT_DLL_API
209 virtual
210 DataAbstract*
211 getSlice(const DataTypes::RegionType& region) const;
212
213 /**
214 \brief
215 Copy the specified region from the given value.
216
217 \param value - Input - Data object to copy from.
218 \param region - Input - Region to copy.
219 */
220 ESCRIPT_DLL_API
221 virtual
222 void
223 setSlice(const DataAbstract* value,
224 const DataTypes::RegionType& region);
225
226 /**
227 \brief
228 setTaggedValue
229
230 Description:
231 uses tag to set a new value
232
233 \param tagKey - Input - Integer key.
234 \param pointshape - Input - The shape of the value parameter
235 \param value - Input - .
236 */
237 void
238 setTaggedValue(int tagKey,
239 const DataTypes::ShapeType& pointshape,
240 const DataTypes::ValueType& value,
241 int dataOffset=0);
242
243
244
245 /**
246 \brief
247 Computes a symmetric matrix (A + AT) / 2
248
249 \param ev - Output - symmetric matrix
250
251 */
252 ESCRIPT_DLL_API
253 virtual void
254 symmetric(DataAbstract* ev);
255
256 /**
257 \brief
258 Computes a nonsymmetric matrix (A - AT) / 2
259
260 \param ev - Output - nonsymmetric matrix
261
262 */
263 ESCRIPT_DLL_API
264 virtual void
265 nonsymmetric(DataAbstract* ev);
266
267 /**
268 \brief
269 Computes the trace of a matrix
270
271 \param ev - Output - trace of your matrix
272
273 */
274 ESCRIPT_DLL_API
275 virtual void
276 trace(DataAbstract* ev, int axis_offset);
277
278 /**
279 \brief
280 Transpose each data point of this Data object around the given axis.
281
282 \param ev - Output - transpose of your matrix
283
284 */
285 ESCRIPT_DLL_API
286 virtual void
287 transpose(DataAbstract* ev, int axis_offset);
288
289 /**
290 \brief
291 swaps components axis0 and axis1
292
293 \param ev - Output - swapped components
294
295 */
296 ESCRIPT_DLL_API
297 virtual void
298 swapaxes(DataAbstract* ev, int axis0, int axis1);
299
300
301 /**
302 \brief
303 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev
304
305 \param ev - Output - eigenvalues in increasing order at each data point
306
307 */
308 ESCRIPT_DLL_API
309 virtual void
310 eigenvalues(DataAbstract* ev);
311
312 /**
313 \brief
314 solves the eigenvalue problem this*V=ev*V for the eigenvalues ev and eigenvectors V
315
316 \param ev - Output - eigenvalues in increasing order at each data point
317 \param V - Output - corresponding eigenvectors. They are normalized such that their length is one
318 and the first nonzero component is positive.
319 \param tol - Input - eigenvalue with relative distance tol are treated as equal.
320
321 */
322
323 ESCRIPT_DLL_API
324 virtual void
325 eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
326
327 /**
328 * \brief
329 * reorders data sample ordered by reference_ids to the ordering of the functions space
330 *
331 * \param reference_ids - Input - reference_ids used for current ordering
332 * */
333 ESCRIPT_DLL_API
334 virtual void
335 reorderByReferenceIDs(int *reference_ids);
336
337
338
339 protected:
340
341 private:
342
343 /**
344 \brief
345 Common initialisation called from constructors.
346
347 Description:
348 Common initialisation called from constructors.
349
350 Resizes the underlying data array to provide sufficient storage for the
351 given shape and number of data points, and creates the corresponding
352 DataArrayView of this data.
353
354 \param noSamples - Input - number of samples.
355 \param noDataPointsPerSample - Input - number of data points per sample.
356 */
357 void
358 initialise(int noSamples,
359 int noDataPointsPerSample);
360
361 /**
362 \brief
363 Copy the given data point value to all data points in this object.
364
365 Description:
366 Copy the given data point to all data points in this object.
367
368 \param value Input - A single data point value.
369 */
370 void
371 copy(const DataConstant& value);
372
373
374
375 /**
376 \brief
377 Copy the given data point value given a numarray object to all data points in this object.
378
379 Description:
380 Copy the given data point value given a numarray object to all data points in this object.
381
382 \param value Input - A single data point value.
383 */
384 void
385 copy(const boost::python::numeric::array& value);
386
387 /**
388 \brief
389 Copy the numarray object to the data points in this object.
390
391 Description:
392 Copy the numarray object to the data points in this object.
393
394 \param value Input - new values for the data points
395 */
396 void
397 copyAll(const boost::python::numeric::array& value);
398
399 /**
400 \brief
401 Copy a double value to the data point dataPointNo of sample sampleNo in this object.
402
403 Description:
404 Copy a double value to the data point dataPointNo of sample sampleNo in this object.
405
406 \param sampleNo Input - sample number
407 \param dataPointNo Input - data point of the sample
408 \param value Input - new values for the data point
409 */
410 ESCRIPT_DLL_API
411 virtual void
412 copyToDataPoint(const int sampleNo, const int dataPointNo, const double value);
413
414
415 /**
416 \brief
417 Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
418
419 Description:
420 Copy the numarray object to the data point dataPointNo of sample sampleNo in this object.
421
422 \param sampleNo Input - sample number
423 \param dataPointNo Input - data point of the sample
424 \param value Input - new values for the data point
425 */
426 void
427 copyToDataPoint(const int sampleNo, const int dataPointNo, const boost::python::numeric::array& value);
428
429 //
430 // The main data storage array, a 2D array of data blocks.
431 // noSamples * noDataPointsPerSample
432 DataBlocks2D m_data;
433
434 };
435
436 } // end of namespace
437
438 #endif

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26