Go to the documentation of this file.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
00157 ESCRIPT_DLL_API
00158 bool
00159 hasNaN() const;
00160
00164 ESCRIPT_DLL_API
00165 virtual
00166 DataAbstract*
00167 deepCopy();
00168
00169
00182 ESCRIPT_DLL_API
00183 virtual
00184 double*
00185 getSampleDataByTag(int tag);
00186
00194 ESCRIPT_DLL_API
00195 virtual
00196 std::string
00197 toString() const;
00202 ESCRIPT_DLL_API
00203 virtual
00204 void
00205 dump(const std::string fileName) const;
00206
00212 ESCRIPT_DLL_API
00213 virtual int
00214 matrixInverse(DataAbstract* out) const;
00215
00220 ESCRIPT_DLL_API
00221 virtual
00222 void
00223 setToZero();
00224
00231 ESCRIPT_DLL_API
00232 virtual
00233 int
00234 getTagNumber(int dpno);
00235
00248 ESCRIPT_DLL_API
00249 virtual
00250 ValueType::size_type
00251 getPointOffset(int sampleNo,
00252 int dataPointNo) const;
00253
00254 ESCRIPT_DLL_API
00255 virtual
00256 ValueType::size_type
00257 getPointOffset(int sampleNo,
00258 int dataPointNo);
00259
00277 ESCRIPT_DLL_API
00278 void
00279 addTaggedValues(const TagListType& tagKeys,
00280 const ValueBatchType& values,
00281 const ShapeType& vShape);
00282
00283
00300 ESCRIPT_DLL_API
00301 void
00302 addTaggedValues(const TagListType& tagKeys,
00303 const ValueType& values,
00304 const ShapeType& vShape);
00305
00306
00307
00308
00321 ESCRIPT_DLL_API
00322 void
00323 addTaggedValue(int tagKey,
00324 const DataTypes::ShapeType& pointshape,
00325 const ValueType& value,
00326 int dataOffset=0);
00327
00338 ESCRIPT_DLL_API
00339 void
00340 addTag(int tagKey);
00341
00354 ESCRIPT_DLL_API
00355 void
00356 setTaggedValue(int tagKey,
00357 const DataTypes::ShapeType& pointshape,
00358 const ValueType& value,
00359 int dataOffset=0);
00360
00371 ESCRIPT_DLL_API
00372 DataTypes::ValueType::reference
00373 getDataByTagRW(int tag, DataTypes::ValueType::size_type i);
00374
00375 ESCRIPT_DLL_API
00376 DataTypes::ValueType::const_reference
00377 getDataByTagRO(int tag, DataTypes::ValueType::size_type i) const;
00378
00379
00380
00390 ESCRIPT_DLL_API
00391 DataTypes::ValueType::size_type
00392 getOffsetForTag(int tag) const;
00393
00394
00400 ESCRIPT_DLL_API
00401 DataTypes::ValueType&
00402 getVectorRW();
00403
00404 ESCRIPT_DLL_API
00405 const DataTypes::ValueType&
00406 getVectorRO() const;
00407
00408
00409
00418 ESCRIPT_DLL_API
00419 const DataMapType&
00420 getTagLookup() const;
00421
00433 ESCRIPT_DLL_API
00434 bool
00435 isCurrentTag(int tag) const;
00436
00446 ESCRIPT_DLL_API
00447 DataTypes::ValueType::reference
00448 getDefaultValueRW(DataTypes::ValueType::size_type i);
00449
00450 ESCRIPT_DLL_API
00451 DataTypes::ValueType::const_reference
00452 getDefaultValueRO(DataTypes::ValueType::size_type i) const;
00453
00454
00455
00456
00457
00466 ESCRIPT_DLL_API
00467 virtual
00468 ValueType::size_type
00469 getLength() const;
00470
00481 ESCRIPT_DLL_API
00482 virtual
00483 DataAbstract*
00484 getSlice(const DataTypes::RegionType& region) const;
00485
00497 ESCRIPT_DLL_API
00498 DataTagged(const DataTagged& other,
00499 const DataTypes::RegionType& region);
00500
00511 ESCRIPT_DLL_API
00512 virtual
00513 void
00514 setSlice(const DataAbstract* other,
00515 const DataTypes::RegionType& region);
00516
00517
00525 ESCRIPT_DLL_API
00526 virtual void
00527 symmetric(DataAbstract* ev);
00528
00536 ESCRIPT_DLL_API
00537 virtual void
00538 nonsymmetric(DataAbstract* ev);
00539
00547 ESCRIPT_DLL_API
00548 virtual void
00549 trace(DataAbstract* ev, int axis_offset);
00550
00559 ESCRIPT_DLL_API
00560 virtual void
00561 swapaxes(DataAbstract* ev, int axis0, int axis1);
00562
00570 ESCRIPT_DLL_API
00571 virtual void
00572 transpose(DataAbstract* ev, int axis_offset);
00573
00581 ESCRIPT_DLL_API
00582 virtual void
00583 eigenvalues(DataAbstract* ev);
00584
00596 ESCRIPT_DLL_API
00597 virtual void
00598 eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol=1.e-13);
00599
00600
00604 ESCRIPT_DLL_API
00605 DataTypes::ValueType::size_type
00606 getDefaultOffset() const;
00607
00608 protected:
00609
00610 private:
00611
00612
00613
00614 DataMapType m_offsetLookup;
00615
00616
00617
00618 static const int m_defaultValueOffset = 0;
00619
00620
00621
00622 ValueType m_data;
00623
00624 };
00625
00626 inline
00627 bool
00628 DataTagged::isCurrentTag(int tag) const
00629 {
00630 DataMapType::const_iterator pos(m_offsetLookup.find(tag));
00631 return (pos!=m_offsetLookup.end());
00632 }
00633
00634 inline
00635 DataTypes::ValueType::size_type
00636 DataTagged::getDefaultOffset() const
00637 {
00638 return m_defaultValueOffset;
00639 }
00640
00641 inline
00642 DataTypes::ValueType::reference
00643 DataTagged::getDefaultValueRW(DataTypes::ValueType::size_type i)
00644 {
00645 return getVectorRW()[i];
00646 }
00647
00648 inline
00649 DataTypes::ValueType::const_reference
00650 DataTagged::getDefaultValueRO(DataTypes::ValueType::size_type i) const
00651 {
00652 return getVectorRO()[i];
00653 }
00654
00655 inline
00656 const DataTagged::DataMapType&
00657 DataTagged::getTagLookup() const
00658 {
00659 return m_offsetLookup;
00660 }
00661
00662 inline
00663 DataTypes::ValueType::size_type
00664 DataTagged::getLength() const
00665 {
00666 return m_data.size();
00667 }
00668
00669 }
00670
00671 #endif