Changeset 894 in Sophya for trunk/SophyaLib/TArray/tarray.h
- Timestamp:
- Apr 12, 2000, 7:42:33 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/TArray/tarray.h
r813 r894 23 23 // ( See BaseArray class for data organisation in memory and related methods ) 24 24 25 //! Class for template arrays 26 /*! 27 This class implements arrays of dimensions up to 28 \ref BASEARRAY_MAXNDIMS "BASEARRAY_MAXNDIMS" 29 */ 25 30 template <class T> 26 31 class TArray : public BaseArray { … … 38 43 39 44 // A = B : partage les donnees si "a" est temporaire, clone sinon. 45 //! = operator between TArray 46 /*! \sa Set */ 40 47 inline TArray<T>& operator = (const TArray<T>& a) { return Set(a); } 41 48 virtual TArray<T>& Set(const TArray<T>& a); … … 54 61 55 62 // SubArrays - $CHECK$ Reza 03/2000 je ne sais pas s'il faut declarer ca const ?? 56 TArray<T> SubArray(Range rx, Range ry, Range rz, Range rt, Range ru) const ; 63 TArray<T> SubArray(Range rx, Range ry, Range rz, Range rt, Range ru) const ; 64 //! () operator for Sub arrays extraction 65 /*! \sa SubArray */ 57 66 inline TArray<T> operator () (Range rx, Range ry, Range rz, Range rt=0, Range ru=0) const 58 67 { return SubArray(rx, ry, rz, rt, ru); } … … 75 84 inline T& ElemCheckBound(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it=0, uint_4 iu=0); 76 85 86 //! Return pointer to first element adress 77 87 inline T* Data() {return mNDBlock.Begin()+offset_;} 88 //! Return pointer to first element adress 78 89 inline const T* Data() const {return mNDBlock.Begin()+offset_;} 90 //! Return reference to datablock NDataBlock 79 91 inline NDataBlock<T>& DataBlock() {return mNDBlock;} 92 //! Return reference to datablock NDataBlock 80 93 inline const NDataBlock<T>& DataBlock() const {return mNDBlock;} 81 94 82 95 // Temporaire? 96 //! Are the array temporay ? 83 97 inline bool IsTemp(void) const {return mNDBlock.IsTemp();} 98 //! Set the array as temporay 84 99 inline void SetTemp(bool temp=false) const {mNDBlock.SetTemp(temp);} 85 100 … … 89 104 // Met les elements a une suite de valeurs 90 105 virtual TArray<T>& SetSeq(Sequence seq); 106 //! Fill TArray with Sequence \b seq 91 107 inline TArray<T>& operator = (Sequence seq) { return SetSeq(seq); } 92 108 // A = x (tous les elements a x) 93 109 virtual TArray<T>& SetT(T x); 110 //! Fill TArray with all elements equal to \b x 94 111 inline TArray<T>& operator = (T x) { return SetT(x); } 95 112 // A += -= *= /= x (ajoute, soustrait, ... x a tous les elements) 96 113 virtual TArray<T>& Add(T x); 114 //! Add \b x to all elements 97 115 inline TArray<T>& operator += (T x) { return Add(x); } 98 116 virtual TArray<T>& Sub(T x); 117 //! Substract \b x to all elements 99 118 inline TArray<T>& operator -= (T x) { return Sub(x); } 100 119 virtual TArray<T>& Mul(T x); 120 //! Multiply all elements by \b x 101 121 inline TArray<T>& operator *= (T x) { return Mul(x); } 102 122 virtual TArray<T>& Div(T x); 123 //! Divide all elements by \b x 103 124 inline TArray<T>& operator /= (T x) { return Div(x); } 104 125 virtual TArray<T>& SubInv(T x); // A ---> x-A … … 107 128 // A += -= (ajoute, soustrait element par element les deux tableaux ) 108 129 virtual TArray<T>& AddElt(const TArray<T>& a); 130 //! Operator TArray += TArray 109 131 inline TArray<T>& operator += (const TArray<T>& a) { return AddElt(a); } 110 132 virtual TArray<T>& SubElt(const TArray<T>& a); 133 //! Operator TArray -= TArray 111 134 inline TArray<T>& operator -= (const TArray<T>& a) { return SubElt(a); } 112 135 // Multiplication, division element par element les deux tableaux … … 133 156 void Share(const TArray<T>& a); 134 157 135 NDataBlock<T> mNDBlock; // Le bloc des donnees158 NDataBlock<T> mNDBlock; //!< Block for datas 136 159 }; 137 160 138 161 //////////////////////////////////////////////////////////////// 139 162 // Surcharge d'operateur << 163 //! Print TArray \b a on stream \b os 140 164 template <class T> 141 165 inline ostream& operator << (ostream& os, const TArray<T>& a) … … 145 169 // Surcharge d'operateurs A (+,-,*,/) (T) x 146 170 171 //! Operator TArray = TArray + constant 147 172 template <class T> inline TArray<T> operator + (const TArray<T>& a, T b) 148 173 {TArray<T> result(a); result.SetTemp(true); result.Add(b); return result;} 149 174 175 //! Operator TArray = constant + TArray 150 176 template <class T> inline TArray<T> operator + (T b,const TArray<T>& a) 151 177 {TArray<T> result(a); result.SetTemp(true); result.Add(b); return result;} 152 178 179 //! Operator TArray = TArray - constant 153 180 template <class T> inline TArray<T> operator - (const TArray<T>& a, T b) 154 181 {TArray<T> result(a); result.SetTemp(true); result.Sub(b); return result;} 155 182 183 //! Operator TArray = constant - TArray 156 184 template <class T> inline TArray<T> operator - (T b,const TArray<T>& a) 157 185 {TArray<T> result(a); result.SetTemp(true); result.SubInv(b); return result;} 158 186 187 //! Operator TArray = TArray * constant 159 188 template <class T> inline TArray<T> operator * (const TArray<T>& a, T b) 160 189 {TArray<T> result(a); result.SetTemp(true); result.Mul(b); return result;} 161 190 191 //! Operator TArray = constant * TArray 162 192 template <class T> inline TArray<T> operator * (T b,const TArray<T>& a) 163 193 {TArray<T> result(a); result.SetTemp(true); result.Mul(b); return result;} 164 194 195 //! Operator TArray = TArray / constant 165 196 template <class T> inline TArray<T> operator / (const TArray<T>& a, T b) 166 197 {TArray<T> result(a); result.SetTemp(true); result.DivInv(b); return result;} … … 169 200 // Surcharge d'operateurs C = A (+,-) B 170 201 202 //! Operator TArray = TArray + TArray 171 203 template <class T> 172 204 inline TArray<T> operator + (const TArray<T>& a,const TArray<T>& b) 173 205 {TArray<T> result(a); result.SetTemp(true); result.AddElt(b); return result;} 174 206 207 //! Operator TArray = TArray - TArray 175 208 template <class T> 176 209 inline TArray<T> operator - (const TArray<T>& a,const TArray<T>& b) … … 181 214 // inline element acces methods 182 215 // -------------------------------------------------- 216 217 //! Return element (ix,iy,iz,it,iu) value 183 218 template <class T> 184 219 inline T const& TArray<T>::Elem(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) const … … 189 224 } 190 225 226 //! Return element (ix,iy,iz,it,iu) value 191 227 template <class T> 192 228 inline T & TArray<T>::Elem(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) … … 197 233 } 198 234 235 //! Return element (ix,iy,iz,it,iu) value with Check of indexes bound first 199 236 template <class T> 200 237 inline T const& TArray<T>::ElemCheckBound(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) const … … 204 241 } 205 242 243 //! Return element (ix,iy,iz,it,iu) value with Check of indexes bound first 206 244 template <class T> 207 245 inline T & TArray<T>::ElemCheckBound(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) … … 211 249 } 212 250 251 //! Return element (ix,iy,iz) value 213 252 template <class T> 214 253 inline T const& TArray<T>::operator()(uint_4 ix, uint_4 iy, uint_4 iz) const … … 221 260 } 222 261 262 //! Return element (ix,iy,iz) value 223 263 template <class T> 224 264 inline T & TArray<T>::operator()(uint_4 ix, uint_4 iy, uint_4 iz) … … 231 271 } 232 272 273 //! Operator () : return element (ix,iy,iz,it,iu) value 233 274 template <class T> 234 275 inline T const& TArray<T>::operator()(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) const … … 242 283 } 243 284 285 //! Operator () : return element (ix,iy,iz,it,iu) value 244 286 template <class T> 245 287 inline T & TArray<T>::operator()(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) … … 254 296 255 297 298 //! Operator [] : return element at positon ip 256 299 template <class T> 257 300 inline T const& TArray<T>::operator[](uint_8 ip) const … … 263 306 } 264 307 308 //! Operator [] : return element at positon ip 265 309 template <class T> 266 310 inline T & TArray<T>::operator[](uint_8 ip) … … 273 317 274 318 319 //! Return the value of first element 275 320 template <class T> 276 321 inline T TArray<T>::toScalar() … … 281 326 282 327 // Typedef pour simplifier 328 //! To simplify, Array \<==\> TArray<r_8> 283 329 typedef TArray<r_8> Array; 284 330
Note:
See TracChangeset
for help on using the changeset viewer.