Changeset 785 in Sophya for trunk/SophyaLib/TArray/tarray.h
- Timestamp:
- Mar 16, 2000, 7:36:24 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/TArray/tarray.h
r772 r785 14 14 #include "ndatablock.h" 15 15 #include "dvlist.h" 16 #include "utilarr.h" 16 17 17 18 … … 20 21 21 22 namespace SOPHYA { 22 23 /* Quelques utilitaires */24 typedef double (* Arr_DoubleFunctionOfX) (double x);25 typedef float (* Arr_FloatFunctionOfX) (float x);26 27 class Sequence {28 public:29 Sequence (double start=0., double step=1.);30 inline double & Start() { return start_; }31 inline double & Step() { return step_; }32 inline double operator () (uint_4 k) { return(start_+(double)k*step_); }33 protected:34 double start_, step_;35 };36 23 37 24 // Forward declaration … … 56 43 virtual TArray<T>& operator = (const TArray<T>& a); 57 44 58 // Extraction de sous-tableau59 virtual TArray<T> SubArray(uint_4 ndim, uint_4 * siz, uint_4 * pos);60 45 61 46 // Gestion taille/Remplissage … … 65 50 // Returns true if ndim and sizes are equal 66 51 virtual bool CompareSizes(const TArray<T>& a); 67 52 // Compacts size=1 array dimensions 53 virtual TArray<T>& CompactDim(); 54 68 55 // Array dimensions 69 56 inline uint_4 NbDimensions() const { return( ndim_ ); } … … 75 62 inline uint_4 Size(int ka) const { return(size_[CheckDI(ka,1)]); } 76 63 64 uint_4 MaxSizeKA() const ; 65 77 66 // memory organisation - packing information 78 inline bool IsPacked() const { return(m instep_ == 1); }67 inline bool IsPacked() const { return(moystep_ == 1); } 79 68 inline bool IsPackedX() const { return(step_[0] == 1); } 80 69 inline bool IsPackedY() const { return(step_[1] == 1); } … … 82 71 inline bool IsPacked(int ka) const { return(step_[CheckDI(ka,2)] == 1); } 83 72 84 inline uint_4 Step() const { return(minstep_); } 73 inline uint_4 MinStep() const { return(minstep_); } 74 inline uint_4 AvgStep() const { return(moystep_); } 85 75 inline uint_4 StepX() const { return(step_[0]); } 86 76 inline uint_4 StepZ() const { return(step_[1]); } … … 88 78 inline uint_4 Step(int ka) const { return(step_[CheckDI(ka,3)]); } 89 79 90 inline uint_8 Offset() const { return(offset_); } 80 uint_4 MinStepKA() const ; 81 82 uint_8 Offset(uint_8 ip=0) const ; 91 83 92 84 … … 94 86 inline bool IsTemp(void) const {return mNDBlock.IsTemp();} 95 87 inline void SetTemp(bool temp=false) const {mNDBlock.SetTemp(temp);} 88 89 // SubArrays 90 virtual TArray<T> operator () (Range rx, Range ry, Range rz=0, Range rt=0, Range ru=0); 96 91 97 92 // Acces to data … … 100 95 inline T const& operator()(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu=0) const ; 101 96 inline T& operator()(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu=0); 102 inline T const& operator[](uint_ 4ip) const ;103 inline T& operator[](uint_ 4ip);97 inline T const& operator[](uint_8 ip) const ; 98 inline T& operator[](uint_8 ip); 104 99 105 100 inline T const& Elem(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it=0, uint_4 iu=0) const ; … … 117 112 inline operator T(); 118 113 // Met les elements a une suite de valeurs 119 virtual TArray<T>& operator = (Sequence &seq);114 virtual TArray<T>& operator = (Sequence seq); 120 115 // A = x (tous les elements a x) 121 116 virtual TArray<T>& operator = (T x); … … 162 157 // Share: partage les donnees de "a" 163 158 void Share(const TArray<T>& a); 159 // Extraction de sous-tableau 160 virtual void SubArray(TArray<T> & ra, uint_4 ndim, uint_4 * siz, uint_4 * pos, uint_4 * step); 164 161 165 162 uint_4 ndim_; // nb of dimensions … … 168 165 uint_4 step_[TARRAY_MAXNDIMS]; // two consecutive elements distance in a given dimension 169 166 uint_4 minstep_; // minimal step (in any axes) 167 uint_4 moystep_; // mean step 0 non regular steps 170 168 uint_8 offset_; // global offset -> position of elem[0] in DataBlock 171 169 NDataBlock<T> mNDBlock; // Le bloc des donnees … … 254 252 } 255 253 254 256 255 // -------------------------------------------------- 257 256 // inline element acces methods … … 329 328 } 330 329 331 template <class T> 332 inline T const& TArray<T>::operator[](uint_4 ip) const 330 331 template <class T> 332 inline T const& TArray<T>::operator[](uint_8 ip) const 333 333 { 334 334 #ifdef SO_BOUNDCHECKING 335 335 if (ip >= totsize_) throw( ParmError("TArray<T>::operator[] Out-of-bound Error") ); 336 336 #endif 337 return *(mNDBlock.Begin()+ offset_+ip*minstep_);338 } 339 340 template <class T> 341 inline T & TArray<T>::operator[](uint_ 4ip)337 return *(mNDBlock.Begin()+Offset(ip)); 338 } 339 340 template <class T> 341 inline T & TArray<T>::operator[](uint_8 ip) 342 342 { 343 343 #ifdef SO_BOUNDCHECKING 344 344 if (ip >= totsize_) throw( ParmError("TArray<T>::operator[] Out-of-bound Error") ); 345 345 #endif 346 return *(mNDBlock.Begin()+offset_+ip*minstep_); 347 } 346 return *(mNDBlock.Begin()+Offset(ip)); 347 } 348 348 349 349 350 template <class T>
Note:
See TracChangeset
for help on using the changeset viewer.