|
// $Id$ |
|
1 |
|
|
2 |
/* |
/* $Id$ */ |
3 |
****************************************************************************** |
|
4 |
* * |
/******************************************************* |
5 |
* COPYRIGHT ACcESS 2004 - All Rights Reserved * |
* |
6 |
* * |
* Copyright 2003-2007 by ACceSS MNRF |
7 |
* This software is the property of ACcESS. No part of this code * |
* Copyright 2007 by University of Queensland |
8 |
* may be copied in any form or by any means without the expressed written * |
* |
9 |
* consent of ACcESS. Copying, use or modification of this software * |
* http://esscc.uq.edu.au |
10 |
* by any unauthorised person is illegal unless that person has a software * |
* Primary Business: Queensland, Australia |
11 |
* license agreement with ACcESS. * |
* 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_DataTagged_20040615_H |
#if !defined escript_DataTagged_20040615_H |
17 |
#define escript_DataTagged_20040615_H |
#define escript_DataTagged_20040615_H |
18 |
|
#include "system_dep.h" |
19 |
|
|
20 |
#include "DataAbstract.h" |
#include "DataAbstract.h" |
21 |
#include "DataArrayView.h" |
#include "DataArrayView.h" |
62 |
tag values are stored. |
tag values are stored. |
63 |
T |
T |
64 |
*/ |
*/ |
65 |
|
ESCRIPT_DLL_API |
66 |
DataTagged(); |
DataTagged(); |
67 |
|
|
68 |
/** |
/** |
83 |
\param what - Input - A description of what this data represents. |
\param what - Input - A description of what this data represents. |
84 |
T |
T |
85 |
*/ |
*/ |
86 |
|
ESCRIPT_DLL_API |
87 |
DataTagged(const TagListType& tagKeys, |
DataTagged(const TagListType& tagKeys, |
88 |
const ValueListType& values, |
const ValueListType& values, |
89 |
const DataArrayView& defaultValue, |
const DataArrayView& defaultValue, |
101 |
\param data - The data values for each tag. |
\param data - The data values for each tag. |
102 |
NB: no unit testing yet |
NB: no unit testing yet |
103 |
*/ |
*/ |
104 |
|
ESCRIPT_DLL_API |
105 |
DataTagged(const FunctionSpace& what, |
DataTagged(const FunctionSpace& what, |
106 |
const DataArrayView::ShapeType &shape, |
const DataArrayView::ShapeType &shape, |
107 |
const int tags[], |
const int tags[], |
109 |
|
|
110 |
/** |
/** |
111 |
\brief |
\brief |
112 |
|
Alternative Constructor for DataTagged. |
113 |
|
|
114 |
|
Description: |
115 |
|
Alternative Constructor for DataTagged. |
116 |
|
\param what - Input - A description of what this data object represents. |
117 |
|
\param shape - Input - The shape of each data-point. |
118 |
|
\param tags - Input - An vector of tags, one for each sample number. |
119 |
|
\param data - The data values for each tag. |
120 |
|
NB: no unit testing yet |
121 |
|
*/ |
122 |
|
ESCRIPT_DLL_API |
123 |
|
DataTagged(const FunctionSpace& what, |
124 |
|
const DataArrayView::ShapeType &shape, |
125 |
|
const TagListType& tags, |
126 |
|
const ValueType& data); |
127 |
|
|
128 |
|
/** |
129 |
|
\brief |
130 |
Copy Constructor for DataTagged. |
Copy Constructor for DataTagged. |
131 |
Performs a deep copy from the given DataTagged object. |
Performs a deep copy from the given DataTagged object. |
132 |
T |
T |
133 |
*/ |
*/ |
134 |
|
ESCRIPT_DLL_API |
135 |
DataTagged(const DataTagged& other); |
DataTagged(const DataTagged& other); |
136 |
|
|
137 |
/** |
/** |
141 |
The default value will be the value of the DataConstant object. |
The default value will be the value of the DataConstant object. |
142 |
T |
T |
143 |
*/ |
*/ |
144 |
|
ESCRIPT_DLL_API |
145 |
DataTagged(const DataConstant& other); |
DataTagged(const DataConstant& other); |
146 |
|
|
147 |
/** |
/** |
156 |
** NB: need to do array bounds checking when accessing returned value! |
** NB: need to do array bounds checking when accessing returned value! |
157 |
T |
T |
158 |
*/ |
*/ |
159 |
|
ESCRIPT_DLL_API |
160 |
virtual |
virtual |
161 |
double* |
double* |
162 |
getSampleDataByTag(int tag); |
getSampleDataByTag(int tag); |
168 |
associated with each tag. |
associated with each tag. |
169 |
T |
T |
170 |
*/ |
*/ |
171 |
|
ESCRIPT_DLL_API |
172 |
virtual |
virtual |
173 |
std::string |
std::string |
174 |
toString() const; |
toString() const; |
175 |
|
/** |
176 |
|
\brief |
177 |
|
dumps the object into a netCDF file |
178 |
|
*/ |
179 |
|
ESCRIPT_DLL_API |
180 |
|
virtual |
181 |
|
void |
182 |
|
dump(const std::string fileName) const; |
183 |
|
|
184 |
|
/** |
185 |
|
\brief |
186 |
|
sets all values to zero |
187 |
|
*/ |
188 |
|
ESCRIPT_DLL_API |
189 |
|
virtual |
190 |
|
void |
191 |
|
setToZero(); |
192 |
|
|
193 |
/** |
/** |
194 |
\brief |
\brief |
196 |
according to the associated function space. |
according to the associated function space. |
197 |
T |
T |
198 |
*/ |
*/ |
199 |
|
ESCRIPT_DLL_API |
200 |
virtual |
virtual |
201 |
int |
int |
202 |
getTagNumber(int dpno); |
getTagNumber(int dpno); |
213 |
\param dataPointNo - Input - data-point number. |
\param dataPointNo - Input - data-point number. |
214 |
T |
T |
215 |
*/ |
*/ |
216 |
|
ESCRIPT_DLL_API |
217 |
virtual |
virtual |
218 |
ValueType::size_type |
ValueType::size_type |
219 |
getPointOffset(int sampleNo, |
getPointOffset(int sampleNo, |
235 |
will be generated. |
will be generated. |
236 |
T |
T |
237 |
*/ |
*/ |
238 |
|
ESCRIPT_DLL_API |
239 |
void |
void |
240 |
addTaggedValues(const TagListType& tagKeys, |
addTaggedValues(const TagListType& tagKeys, |
241 |
const ValueListType& values); |
const ValueListType& values); |
251 |
\param value - Input - Single DataArrayView value to be assigned to the tag. |
\param value - Input - Single DataArrayView value to be assigned to the tag. |
252 |
T |
T |
253 |
*/ |
*/ |
254 |
|
ESCRIPT_DLL_API |
255 |
void |
void |
256 |
addTaggedValue(int tagKey, |
addTaggedValue(int tagKey, |
257 |
const DataArrayView& value); |
const DataArrayView& value); |
272 |
will be generated. |
will be generated. |
273 |
T |
T |
274 |
*/ |
*/ |
275 |
|
ESCRIPT_DLL_API |
276 |
void |
void |
277 |
setTaggedValues(const TagListType& tagKeys, |
setTaggedValues(const TagListType& tagKeys, |
278 |
const ValueListType& values); |
const ValueListType& values); |
287 |
\param value - Input - Single DataArrayView value to be assigned to the tag. |
\param value - Input - Single DataArrayView value to be assigned to the tag. |
288 |
T |
T |
289 |
*/ |
*/ |
290 |
|
ESCRIPT_DLL_API |
291 |
virtual |
virtual |
292 |
void |
void |
293 |
setTaggedValue(int tagKey, |
setTaggedValue(int tagKey, |
302 |
\param tag - Input - Integer key. |
\param tag - Input - Integer key. |
303 |
T |
T |
304 |
*/ |
*/ |
305 |
|
ESCRIPT_DLL_API |
306 |
DataArrayView |
DataArrayView |
307 |
getDataPointByTag(int tag) const; |
getDataPointByTag(int tag) const; |
308 |
|
|
317 |
\param dataPointNo - Input. |
\param dataPointNo - Input. |
318 |
T |
T |
319 |
*/ |
*/ |
320 |
|
ESCRIPT_DLL_API |
321 |
virtual |
virtual |
322 |
DataArrayView |
DataArrayView |
323 |
getDataPoint(int sampleNo, |
getDataPoint(int sampleNo, |
324 |
int dataPointNo); |
int dataPointNo); |
325 |
|
|
326 |
/** |
/** |
327 |
|
\brief |
328 |
|
getData |
329 |
|
|
330 |
|
Description: |
331 |
|
Return pointer to the data |
332 |
|
T |
333 |
|
*/ |
334 |
|
ESCRIPT_DLL_API |
335 |
|
const DataArrayView::ValueType::ElementType* |
336 |
|
getData() const; |
337 |
|
|
338 |
|
/** |
339 |
\brief |
\brief |
340 |
getTagLookup |
getTagLookup |
341 |
|
|
343 |
Return a reference to the tag offset lookup table. |
Return a reference to the tag offset lookup table. |
344 |
T |
T |
345 |
*/ |
*/ |
346 |
|
ESCRIPT_DLL_API |
347 |
const DataMapType& |
const DataMapType& |
348 |
getTagLookup() const; |
getTagLookup() const; |
349 |
|
|
358 |
keys in the associated function space. |
keys in the associated function space. |
359 |
T |
T |
360 |
*/ |
*/ |
361 |
|
ESCRIPT_DLL_API |
362 |
bool |
bool |
363 |
isCurrentTag(int tag) const; |
isCurrentTag(int tag) const; |
364 |
|
|
371 |
is not explicitly recorded in this DataTagged object's tag map. |
is not explicitly recorded in this DataTagged object's tag map. |
372 |
T |
T |
373 |
*/ |
*/ |
374 |
|
ESCRIPT_DLL_API |
375 |
DataArrayView& |
DataArrayView& |
376 |
getDefaultValue(); |
getDefaultValue(); |
377 |
|
|
378 |
|
ESCRIPT_DLL_API |
379 |
const DataArrayView& |
const DataArrayView& |
380 |
getDefaultValue() const; |
getDefaultValue() const; |
381 |
|
|
387 |
Return the total number of doubles stored for this DataTagged object. |
Return the total number of doubles stored for this DataTagged object. |
388 |
T |
T |
389 |
*/ |
*/ |
390 |
|
ESCRIPT_DLL_API |
391 |
virtual |
virtual |
392 |
ValueType::size_type |
ValueType::size_type |
393 |
getLength() const; |
getLength() const; |
402 |
The caller is reponsible for managing the returned object. |
The caller is reponsible for managing the returned object. |
403 |
T |
T |
404 |
*/ |
*/ |
405 |
|
ESCRIPT_DLL_API |
406 |
virtual |
virtual |
407 |
DataAbstract* |
DataAbstract* |
408 |
getSlice(const DataArrayView::RegionType& region) const; |
getSlice(const DataArrayView::RegionType& region) const; |
418 |
\param region - Input - Region to slice. |
\param region - Input - Region to slice. |
419 |
T |
T |
420 |
*/ |
*/ |
421 |
|
ESCRIPT_DLL_API |
422 |
DataTagged(const DataTagged& other, |
DataTagged(const DataTagged& other, |
423 |
const DataArrayView::RegionType& region); |
const DataArrayView::RegionType& region); |
424 |
|
|
432 |
\param region - Input - Region to copy into (NB: must have same shape as other!). |
\param region - Input - Region to copy into (NB: must have same shape as other!). |
433 |
T |
T |
434 |
*/ |
*/ |
435 |
|
ESCRIPT_DLL_API |
436 |
virtual |
virtual |
437 |
void |
void |
438 |
setSlice(const DataAbstract* other, |
setSlice(const DataAbstract* other, |
440 |
|
|
441 |
/** |
/** |
442 |
\brief |
\brief |
|
reshapeDataPoint |
|
|
|
|
|
Description: |
|
|
Reshape each data-point in this object to the given shape, only |
|
|
if current data-points are scalars. An exception is thrown if |
|
|
the current data-points have rank other than 0. |
|
|
The original values of the data-points are used for all values |
|
|
of the new data-points. |
|
|
T |
|
|
*/ |
|
|
void |
|
|
reshapeDataPoint(const DataArrayView::ShapeType& shape); |
|
|
|
|
|
/** |
|
|
\brief |
|
443 |
Archive the underlying data values to the file referenced |
Archive the underlying data values to the file referenced |
444 |
by ofstream. A count of the number of values expected to be written |
by ofstream. A count of the number of values expected to be written |
445 |
is provided as a cross-check. |
is provided as a cross-check. |
446 |
|
|
447 |
The return value indicates success (0) or otherwise (1). |
The return value indicates success (0) or otherwise (1). |
448 |
*/ |
*/ |
449 |
|
ESCRIPT_DLL_API |
450 |
int |
int |
451 |
archiveData(std::ofstream& archiveFile, |
archiveData(std::ofstream& archiveFile, |
452 |
const DataArrayView::ValueType::size_type noValues) const; |
const DataArrayView::ValueType::size_type noValues) const; |
458 |
|
|
459 |
The return value indicates success (0) or otherwise (1). |
The return value indicates success (0) or otherwise (1). |
460 |
*/ |
*/ |
461 |
|
ESCRIPT_DLL_API |
462 |
int |
int |
463 |
extractData(std::ifstream& archiveFile, |
extractData(std::ifstream& archiveFile, |
464 |
const DataArrayView::ValueType::size_type noValues); |
const DataArrayView::ValueType::size_type noValues); |
465 |
|
|
466 |
/** |
/** |
467 |
\brief |
\brief |
468 |
|
Computes a symmetric matrix (A + AT) / 2 |
469 |
|
|
470 |
|
\param ev - Output - symmetric matrix |
471 |
|
|
472 |
|
*/ |
473 |
|
ESCRIPT_DLL_API |
474 |
|
virtual void |
475 |
|
symmetric(DataAbstract* ev); |
476 |
|
|
477 |
|
/** |
478 |
|
\brief |
479 |
|
Computes a nonsymmetric matrix (A - AT) / 2 |
480 |
|
|
481 |
|
\param ev - Output - nonsymmetric matrix |
482 |
|
|
483 |
|
*/ |
484 |
|
ESCRIPT_DLL_API |
485 |
|
virtual void |
486 |
|
nonsymmetric(DataAbstract* ev); |
487 |
|
|
488 |
|
/** |
489 |
|
\brief |
490 |
|
Computes the trace of a matrix |
491 |
|
|
492 |
|
\param ev - Output - the trace of a matrix |
493 |
|
|
494 |
|
*/ |
495 |
|
ESCRIPT_DLL_API |
496 |
|
virtual void |
497 |
|
trace(DataAbstract* ev, int axis_offset); |
498 |
|
|
499 |
|
/** |
500 |
|
\brief |
501 |
|
swaps components axis0 and axis1 |
502 |
|
|
503 |
|
\param ev - Output - swapped components |
504 |
|
|
505 |
|
*/ |
506 |
|
ESCRIPT_DLL_API |
507 |
|
virtual void |
508 |
|
swapaxes(DataAbstract* ev, int axis0, int axis1); |
509 |
|
|
510 |
|
/** |
511 |
|
\brief |
512 |
|
Transpose each data point of this Data object around the given axis. |
513 |
|
|
514 |
|
\param ev - Output - the transpose of a matrix |
515 |
|
|
516 |
|
*/ |
517 |
|
ESCRIPT_DLL_API |
518 |
|
virtual void |
519 |
|
transpose(DataAbstract* ev, int axis_offset); |
520 |
|
|
521 |
|
/** |
522 |
|
\brief |
523 |
solves the eigenvalue problem this*V=ev*V for the eigenvalues ev |
solves the eigenvalue problem this*V=ev*V for the eigenvalues ev |
524 |
|
|
525 |
\param ev - Output - eigenvalues in increasing order at each data point |
\param ev - Output - eigenvalues in increasing order at each data point |
526 |
|
|
527 |
*/ |
*/ |
528 |
|
ESCRIPT_DLL_API |
529 |
virtual void |
virtual void |
530 |
eigenvalues(DataAbstract* ev); |
eigenvalues(DataAbstract* ev); |
531 |
|
|
540 |
|
|
541 |
*/ |
*/ |
542 |
|
|
543 |
|
ESCRIPT_DLL_API |
544 |
virtual void |
virtual void |
545 |
eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13); |
eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13); |
546 |
|
|
588 |
} |
} |
589 |
|
|
590 |
inline |
inline |
591 |
|
const DataArrayView::ValueType::ElementType* |
592 |
|
DataTagged::getData() const |
593 |
|
{ |
594 |
|
return &(m_data[0]); |
595 |
|
} |
596 |
|
|
597 |
|
inline |
598 |
const DataTagged::DataMapType& |
const DataTagged::DataMapType& |
599 |
DataTagged::getTagLookup() const |
DataTagged::getTagLookup() const |
600 |
{ |
{ |