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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26