00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #if !defined escript_DataTagged_20040615_H
00016 #define escript_DataTagged_20040615_H
00017 #include "system_dep.h"
00018
00019 #include "DataReady.h"
00020 #include "DataTypes.h"
00021
00022 #include <vector>
00023 #include <map>
00024
00025 namespace escript {
00026
00027 class DataConstant;
00028
00040 class DataTagged : public DataReady {
00041 typedef DataReady parent;
00042 public:
00043
00044
00045
00046 typedef std::vector<int> TagListType;
00047
00048 typedef DataTypes::ValueType ValueType;
00049 typedef std::vector<ValueType::ElementType> ValueBatchType;
00050
00051
00052
00053 typedef std::map<int, int> DataMapType;
00054
00065 ESCRIPT_DLL_API
00066 DataTagged();
00067
00080 ESCRIPT_DLL_API
00081 DataTagged(const FunctionSpace& what,
00082 const DataTypes::ShapeType &shape,
00083 const int tags[],
00084 const ValueType& data);
00085
00098 ESCRIPT_DLL_API
00099 DataTagged(const FunctionSpace& what,
00100 const DataTypes::ShapeType &shape,
00101 const TagListType& tags,
00102 const ValueType& data);
00103
00110 ESCRIPT_DLL_API
00111 DataTagged(const DataTagged& other);
00112
00120 ESCRIPT_DLL_API
00121 DataTagged(const DataConstant& other);
00122
00133 ESCRIPT_DLL_API
00134 DataTagged(const FunctionSpace& what,
00135 const DataTypes::ShapeType& shape,
00136 const DataTypes::ValueType& defaultvalue,
00137 const DataTagged* tagsource=0);
00138
00143 ESCRIPT_DLL_API
00144 inline virtual
00145 ~DataTagged() {};
00146
00147 ESCRIPT_DLL_API
00148 bool
00149 isTagged() const
00150 {
00151 return true;
00152 };
00153
00154
00158 ESCRIPT_DLL_API
00159 virtual
00160 DataAbstract*
00161 deepCopy();
00162
00163
00176 ESCRIPT_DLL_API
00177 virtual
00178 double*
00179 getSampleDataByTag(int tag);
00180
00188 ESCRIPT_DLL_API
00189 virtual
00190 std::string
00191 toString() const;
00196 ESCRIPT_DLL_API
00197 virtual
00198 void
00199 dump(const std::string fileName) const;
00200
00205 ESCRIPT_DLL_API
00206 virtual
00207 void
00208 setToZero();
00209
00216 ESCRIPT_DLL_API
00217 virtual
00218 int
00219 getTagNumber(int dpno);
00220
00233 ESCRIPT_DLL_API
00234 virtual
00235 ValueType::size_type
00236 getPointOffset(int sampleNo,
00237 int dataPointNo) const;
00238
00239 ESCRIPT_DLL_API
00240 virtual
00241 ValueType::size_type
00242 getPointOffset(int sampleNo,
00243 int dataPointNo);
00244
00262 ESCRIPT_DLL_API
00263 void
00264 addTaggedValues(const TagListType& tagKeys,
00265 const ValueBatchType& values,
00266 const ShapeType& vShape);
00267
00268
00285 ESCRIPT_DLL_API
00286 void
00287 addTaggedValues(const TagListType& tagKeys,
00288 const ValueType& values,
00289 const ShapeType& vShape);
00290
00291
00292
00293
00306 ESCRIPT_DLL_API
00307 void
00308 addTaggedValue(int tagKey,
00309 const DataTypes::ShapeType& pointshape,
00310 const ValueType& value,
00311 int dataOffset=0);
00312
00323 ESCRIPT_DLL_API
00324 void
00325 addTag(int tagKey);
00326
00339 ESCRIPT_DLL_API
00340 void
00341 setTaggedValue(int tagKey,
00342 const DataTypes::ShapeType& pointshape,
00343 const ValueType& value,
00344 int dataOffset=0);
00345
00356 ESCRIPT_DLL_API
00357 DataTypes::ValueType::reference
00358 getDataByTagRW(int tag, DataTypes::ValueType::size_type i);
00359
00360 ESCRIPT_DLL_API
00361 DataTypes::ValueType::const_reference
00362 getDataByTagRO(int tag, DataTypes::ValueType::size_type i) const;
00363
00364
00365
00375 ESCRIPT_DLL_API
00376 DataTypes::ValueType::size_type
00377 getOffsetForTag(int tag) const;
00378
00379
00385 ESCRIPT_DLL_API
00386 DataTypes::ValueType&
00387 getVectorRW();
00388
00389 ESCRIPT_DLL_API
00390 const DataTypes::ValueType&
00391 getVectorRO() const;
00392
00393
00394
00403 ESCRIPT_DLL_API
00404 const DataMapType&
00405 getTagLookup() const;
00406
00418 ESCRIPT_DLL_API
00419 bool
00420 isCurrentTag(int tag) const;
00421
00431 ESCRIPT_DLL_API
00432 DataTypes::ValueType::reference
00433 getDefaultValueRW(DataTypes::ValueType::size_type i);
00434
00435 ESCRIPT_DLL_API
00436 DataTypes::ValueType::const_reference
00437 getDefaultValueRO(DataTypes::ValueType::size_type i) const;
00438
00439
00440
00441
00442
00451 ESCRIPT_DLL_API
00452 virtual
00453 ValueType::size_type
00454 getLength() const;
00455
00466 ESCRIPT_DLL_API
00467 virtual
00468 DataAbstract*
00469 getSlice(const DataTypes::RegionType& region) const;
00470
00482 ESCRIPT_DLL_API
00483 DataTagged(const DataTagged& other,
00484 const DataTypes::RegionType& region);
00485
00496 ESCRIPT_DLL_API
00497 virtual
00498 void
00499 setSlice(const DataAbstract* other,
00500 const DataTypes::RegionType& region);
00501
00502
00510 ESCRIPT_DLL_API
00511 virtual void
00512 symmetric(DataAbstract* ev);
00513
00521 ESCRIPT_DLL_API
00522 virtual void
00523 nonsymmetric(DataAbstract* ev);
00524
00532 ESCRIPT_DLL_API
00533 virtual void
00534 trace(DataAbstract* ev, int axis_offset);
00535
00544 ESCRIPT_DLL_API
00545 virtual void
00546 swapaxes(DataAbstract* ev, int axis0, int axis1);
00547
00555 ESCRIPT_DLL_API
00556 virtual void
00557 transpose(DataAbstract* ev, int axis_offset);
00558
00566 ESCRIPT_DLL_API
00567 virtual void
00568 eigenvalues(DataAbstract* ev);
00569
00581 ESCRIPT_DLL_API
00582 virtual void
00583 eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
00584
00585
00589 ESCRIPT_DLL_API
00590 DataTypes::ValueType::size_type
00591 getDefaultOffset() const;
00592
00593 protected:
00594
00595 private:
00596
00597
00598
00599 DataMapType m_offsetLookup;
00600
00601
00602
00603 static const int m_defaultValueOffset = 0;
00604
00605
00606
00607 ValueType m_data;
00608
00609 };
00610
00611 inline
00612 bool
00613 DataTagged::isCurrentTag(int tag) const
00614 {
00615 DataMapType::const_iterator pos(m_offsetLookup.find(tag));
00616 return (pos!=m_offsetLookup.end());
00617 }
00618
00619 inline
00620 DataTypes::ValueType::size_type
00621 DataTagged::getDefaultOffset() const
00622 {
00623 return m_defaultValueOffset;
00624 }
00625
00626 inline
00627 DataTypes::ValueType::reference
00628 DataTagged::getDefaultValueRW(DataTypes::ValueType::size_type i)
00629 {
00630 return getVectorRW()[i];
00631 }
00632
00633 inline
00634 DataTypes::ValueType::const_reference
00635 DataTagged::getDefaultValueRO(DataTypes::ValueType::size_type i) const
00636 {
00637 return getVectorRO()[i];
00638 }
00639
00640 inline
00641 const DataTagged::DataMapType&
00642 DataTagged::getTagLookup() const
00643 {
00644 return m_offsetLookup;
00645 }
00646
00647 inline
00648 DataTypes::ValueType::size_type
00649 DataTagged::getLength() const
00650 {
00651 return m_data.size();
00652 }
00653
00654 }
00655
00656 #endif