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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26