escript Revision_
DataTagged.h
Go to the documentation of this file.
1
2/*****************************************************************************
3*
4* Copyright (c) 2003-2020 by The University of Queensland
5* http://www.uq.edu.au
6*
7* Primary Business: Queensland, Australia
8* Licensed under the Apache License, version 2.0
9* http://www.apache.org/licenses/LICENSE-2.0
10*
11* Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12* Development 2012-2013 by School of Earth Sciences
13* Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
14* Development from 2019 by School of Earth and Environmental Sciences
15**
16*****************************************************************************/
17
18
19#ifndef __ESCRIPT_DATATAGGED_H__
20#define __ESCRIPT_DATATAGGED_H__
21
22#include "system_dep.h"
23
24#include "DataReady.h"
25#include "DataTypes.h"
26
27#include <map>
28#include <vector>
29
30namespace escript {
31
32class DataConstant;
33
46{
48 public:
49
50 //
51 // Types for the lists of tags and values.
52 typedef std::vector<int> TagListType;
53 typedef std::vector<DataTypes::RealVectorType::ElementType> FloatBatchType;
54 typedef std::vector<DataTypes::CplxVectorType::ElementType> CplxBatchType;
55
56 //
57 // Map from a tag to an offset into the data array.
58 typedef std::map<int, int> DataMapType;
59
72 explicit DataTagged(const FunctionSpace& what,
73 const DataTypes::ShapeType &shape,
74 const int tags[],
75 const DataTypes::RealVectorType& data);
76
77
78 explicit DataTagged(const FunctionSpace& what,
79 const DataTypes::ShapeType &shape,
80 const int tags[],
81 const DataTypes::CplxVectorType& data);
82
83
96 explicit DataTagged(const FunctionSpace& what,
97 const DataTypes::ShapeType &shape,
98 const TagListType& tags,
99 const DataTypes::RealVectorType& data);
100
101 explicit DataTagged(const FunctionSpace& what,
102 const DataTypes::ShapeType &shape,
103 const TagListType& tags,
104 const DataTypes::CplxVectorType& data);
105
106
113 DataTagged(const DataTagged& other);
114
122 explicit DataTagged(const DataConstant& other);
123
134 explicit DataTagged(const FunctionSpace& what,
135 const DataTypes::ShapeType& shape,
136 const DataTypes::RealVectorType& defaultvalue,
137 const DataTagged* tagsource=0);
138
139 explicit DataTagged(const FunctionSpace& what,
140 const DataTypes::ShapeType& shape,
141 const DataTypes::CplxVectorType& defaultvalue,
142 const DataTagged* tagsource=0);
143
144
149 inline virtual
151
152 bool
153 isTagged() const
154 {
155 return true;
156 };
157
161 bool
162 hasNaN() const;
163
167 void
168 replaceNaN(DataTypes::real_t value);
169
173 void
174 replaceNaN(DataTypes::cplx_t value);
175
179 // ESCRIPT_DLL_API class already exported
180 virtual bool
181 hasInf() const;
182
186 // ESCRIPT_DLL_API class already exported
187 virtual void
188 replaceInf(DataTypes::real_t value);
189
193 // ESCRIPT_DLL_API class already exported
194 virtual void
195 replaceInf(DataTypes::cplx_t value);
196
197
201 virtual
203 deepCopy() const;
204
205
210 // ESCRIPT_DLL_API class already exported
211 virtual
213 zeroedCopy() const;
214
215
228 virtual
230 getSampleDataByTag(int tag, DataTypes::real_t dummy=0);
231
232 virtual
234 getSampleDataByTag(int tag, DataTypes::cplx_t dummy);
235
236
244 virtual
245 std::string
246 toString() const;
251 virtual
252 void
253 dump(const std::string fileName) const;
254
260 virtual int
261 matrixInverse(DataAbstract* out) const;
262
267 virtual
268 void
269 setToZero();
270
277 virtual
278 int
279 getTagNumber(int dpno);
280
293 virtual
295 getPointOffset(int sampleNo,
296 int dataPointNo) const;
297
315 void
316 addTaggedValues(const TagListType& tagKeys,
317 const FloatBatchType& values,
318 const ShapeType& vShape);
319
320
337 void
338 addTaggedValues(const TagListType& tagKeys,
339 const DataTypes::RealVectorType& values,
340 const ShapeType& vShape);
341
342
343
344
357 void
358 addTaggedValue(int tagKey,
359 const DataTypes::ShapeType& pointshape,
360 const DataTypes::RealVectorType& value,
361 int dataOffset=0);
362
363 void
364 addTaggedValue(int tagKey,
365 const DataTypes::ShapeType& pointshape,
366 const DataTypes::CplxVectorType& value,
367 int dataOffset=0);
368
369
380 void
381 addTag(int tagKey);
382
395 void
396 setTaggedValue(int tagKey,
397 const DataTypes::ShapeType& pointshape,
398 const DataTypes::RealVectorType& value,
399 int dataOffset=0);
400
401 void
402 setTaggedValue(int tagKey,
403 const DataTypes::ShapeType& pointshape,
404 const DataTypes::CplxVectorType& value,
405 int dataOffset=0);
406
407
419 getDataByTagRW(int tag, DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy=0);
420
422 getDataByTagRO(int tag, DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy=0) const;
423
424
426 getDataByTagRW(int tag, DataTypes::CplxVectorType::size_type i, DataTypes::cplx_t dummy);
427
429 getDataByTagRO(int tag, DataTypes::CplxVectorType::size_type i, DataTypes::cplx_t dummy) const;
430
440 DataTypes::RealVectorType::size_type
441 getOffsetForTag(int tag) const;
442
443
450 getVectorRW();
451
453 getVectorRO() const;
454
455
457 getVectorRWC();
458
460 getVectorROC() const;
461
462
464 getTypedVectorRW(DataTypes::real_t dummy);
465
466 virtual const DataTypes::RealVectorType&
467 getTypedVectorRO(DataTypes::real_t dummy) const;
468
470 getTypedVectorRW(DataTypes::cplx_t dummy);
471
472 virtual const DataTypes::CplxVectorType&
473 getTypedVectorRO(DataTypes::cplx_t dummy) const;
474
475
476
477
478
487 const DataMapType&
488 getTagLookup() const;
489
501 bool
502 isCurrentTag(int tag) const;
503
514 getDefaultValueRW(DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy=0);
515
517 getDefaultValueRO(DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy=0) const;
518
520 getDefaultValueRW(DataTypes::CplxVectorType::size_type i, DataTypes::cplx_t dummy);
521
523 getDefaultValueRO(DataTypes::CplxVectorType::size_type i, DataTypes::cplx_t dummy) const;
524
525
526
527
536 virtual
537 DataTypes::RealVectorType::size_type
538 getLength() const;
539
550 virtual
552 getSlice(const DataTypes::RegionType& region) const;
553
565 DataTagged(const DataTagged& other,
566 const DataTypes::RegionType& region);
567
578 virtual
579 void
580 setSlice(const DataAbstract* other,
581 const DataTypes::RegionType& region);
582
583
591 virtual void
593
601 virtual void
603
611 virtual void
613
621 virtual void
623
631 virtual void
632 trace(DataAbstract* ev, int axis_offset);
633
642 virtual void
643 swapaxes(DataAbstract* ev, int axis0, int axis1);
644
652 virtual void
653 transpose(DataAbstract* ev, int axis_offset);
654
662 virtual void
664
676 virtual void
677 eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
678
679
683 DataTypes::RealVectorType::size_type
684 getDefaultOffset() const;
685
689 size_t
690 getTagCount() const;
691
692 void
693 complicate();
694
695 protected:
696
697 private:
698
699 //
700 // The offset lookup table
702
703 //
704 // the offset to the default value
705 static const int m_defaultValueOffset = 0;
706
707 // the actual data
710
711
712};
713
714inline
715bool
717{
718 DataMapType::const_iterator pos(m_offsetLookup.find(tag));
719 return (pos!=m_offsetLookup.end());
720}
721
722inline
728
729inline
732{
733 return getVectorRW()[i]; // getVectorRW has exclusive write checks
734}
735
736inline
742
743inline
746{
747 return getVectorRWC()[i]; // getVectorRW has exclusive write checks
748}
749
750inline
756
757
758
759
760inline
763{
764 return m_offsetLookup;
765}
766
767inline
770{
771 return std::max(m_data_c.size(), m_data_r.size());
772}
773
774} // end of namespace
775
776#endif // __ESCRIPT_DATATAGGED_H__
777
#define V(_K_, _I_)
Definition ShapeFunctions.cpp:121
Definition DataAbstract.h:63
DataConstant stores a single data point which represents the entire function space.
Definition DataConstant.h:38
Definition DataReady.h:37
Simulates a full dataset accessible via sampleNo and dataPointNo.
Definition DataTagged.h:46
DataTypes::RealVectorType::const_reference getDefaultValueRO(DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy=0) const
Definition DataTagged.h:738
bool isTagged() const
Definition DataTagged.h:153
DataTypes::CplxVectorType::const_reference getDataByTagRO(int tag, DataTypes::CplxVectorType::size_type i, DataTypes::cplx_t dummy) const
virtual ~DataTagged()
Destructor.
Definition DataTagged.h:150
std::vector< DataTypes::CplxVectorType::ElementType > CplxBatchType
Definition DataTagged.h:54
bool isCurrentTag(int tag) const
isCurrentTag
Definition DataTagged.h:716
DataMapType m_offsetLookup
Definition DataTagged.h:701
DataTypes::RealVectorType::size_type getDefaultOffset() const
Returns the offset in the structure which stores the default value.
Definition DataTagged.h:724
std::vector< DataTypes::RealVectorType::ElementType > FloatBatchType
Definition DataTagged.h:53
DataReady parent
Definition DataTagged.h:47
std::map< int, int > DataMapType
Definition DataTagged.h:58
DataTypes::CplxVectorType::reference getDataByTagRW(int tag, DataTypes::CplxVectorType::size_type i, DataTypes::cplx_t dummy)
static const int m_defaultValueOffset
Definition DataTagged.h:705
virtual DataTypes::RealVectorType::size_type getLength() const
getLength
Definition DataTagged.h:769
DataTypes::CplxVectorType m_data_c
Definition DataTagged.h:709
DataTypes::CplxVectorType::reference getDefaultValueRW(DataTypes::CplxVectorType::size_type i, DataTypes::cplx_t dummy)
std::vector< int > TagListType
Definition DataTagged.h:52
DataTypes::RealVectorType m_data_r
Definition DataTagged.h:708
DataTypes::RealVectorType::reference getDefaultValueRW(DataTypes::RealVectorType::size_type i, DataTypes::real_t dummy=0)
getDefaultValue
Definition DataTagged.h:731
const DataMapType & getTagLookup() const
getTagLookup
Definition DataTagged.h:762
const DataTypes::CplxVectorType & getVectorROC() const
Definition DataTagged.cpp:1663
DataTypes::RealVectorType & getVectorRW()
Return a reference to the underlying DataVector.
Definition DataTagged.cpp:1643
const DataTypes::RealVectorType & getVectorRO() const
Definition DataTagged.cpp:1650
DataTypes::CplxVectorType & getVectorRWC()
Definition DataTagged.cpp:1656
size_type size() const
Return the number of elements in this DataVectorAlt.
Definition DataVectorAlt.h:215
const ElementType & const_reference
Definition DataVectorAlt.h:52
ElementType & reference
Definition DataVectorAlt.h:51
DataTypes::vec_size_type size_type
Definition DataVectorAlt.h:50
Definition FunctionSpace.h:36
#define ESCRIPT_DLL_API
Definition escriptcore/src/system_dep.h:30
std::complex< real_t > cplx_t
complex data type
Definition DataTypes.h:55
std::vector< std::pair< int, int > > RegionType
Definition DataTypes.h:45
double real_t
type of all real-valued scalars in escript
Definition DataTypes.h:52
std::vector< int > ShapeType
The shape of a single datapoint.
Definition DataTypes.h:44
Definition AbstractContinuousDomain.cpp:23
void eigenvalues_and_eigenvectors(const DataTypes::RealVectorType &in, const DataTypes::ShapeType &inShape, DataTypes::RealVectorType::size_type inOffset, DataTypes::RealVectorType &ev, const DataTypes::ShapeType &evShape, DataTypes::RealVectorType::size_type evOffset, DataTypes::RealVectorType &V, const DataTypes::ShapeType &VShape, DataTypes::RealVectorType::size_type VOffset, const double tol=1.e-13)
solves a local eigenvalue problem
Definition DataVectorOps.h:750
void eigenvalues(const DataTypes::RealVectorType &in, const DataTypes::ShapeType &inShape, typename DataTypes::RealVectorType::size_type inOffset, DataTypes::RealVectorType &ev, const DataTypes::ShapeType &evShape, typename DataTypes::RealVectorType::size_type evOffset)
solves a local eigenvalue problem
Definition DataVectorOps.h:639
void symmetric(const VEC &in, const DataTypes::ShapeType &inShape, typename VEC::size_type inOffset, VEC &ev, const DataTypes::ShapeType &evShape, typename VEC::size_type evOffset)
computes a symmetric matrix from your square matrix A: (A + transpose(A)) / 2
Definition DataVectorOps.h:103
void swapaxes(const VEC &in, const DataTypes::ShapeType &inShape, typename VEC::size_type inOffset, VEC &ev, const DataTypes::ShapeType &evShape, typename VEC::size_type evOffset, int axis0, int axis1)
swaps the components axis0 and axis1.
Definition DataVectorOps.h:488
void transpose(const VEC &in, const DataTypes::ShapeType &inShape, typename VEC::size_type inOffset, VEC &ev, const DataTypes::ShapeType &evShape, typename VEC::size_type evOffset, int axis_offset)
Transpose each data point of this Data object around the given axis.
Definition DataVectorOps.h:343
void antisymmetric(const VEC &in, const DataTypes::ShapeType &inShape, typename VEC::size_type inOffset, VEC &ev, const DataTypes::ShapeType &evShape, typename VEC::size_type evOffset)
computes a antisymmetric matrix from your square matrix A: (A - transpose(A)) / 2
Definition DataVectorOps.h:152
void antihermitian(const DataTypes::CplxVectorType &in, const DataTypes::ShapeType &inShape, typename DataTypes::CplxVectorType::size_type inOffset, DataTypes::CplxVectorType &ev, const DataTypes::ShapeType &evShape, typename DataTypes::CplxVectorType::size_type evOffset)
computes a antihermitian matrix from your square matrix A: (A - adjoint(A)) / 2
Definition DataVectorOps.cpp:963
void trace(const VEC &in, const DataTypes::ShapeType &inShape, typename VEC::size_type inOffset, VEC &ev, const DataTypes::ShapeType &evShape, typename VEC::size_type evOffset, int axis_offset)
computes the trace of a matrix
Definition DataVectorOps.h:242
void hermitian(const DataTypes::CplxVectorType &in, const DataTypes::ShapeType &inShape, DataTypes::CplxVectorType::size_type inOffset, DataTypes::CplxVectorType &ev, const DataTypes::ShapeType &evShape, DataTypes::CplxVectorType::size_type evOffset)
computes an hermitian matrix from your square matrix A: (A + adjoint(A)) / 2
Definition DataVectorOps.cpp:916