[772] | 1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
| 2 | // template array class for numerical types
|
---|
| 3 | // R. Ansari, C.Magneville 03/2000
|
---|
| 4 |
|
---|
| 5 | #ifndef TArray_SEEN
|
---|
| 6 | #define TArray_SEEN
|
---|
| 7 |
|
---|
| 8 | #include "machdefs.h"
|
---|
| 9 | #include <math.h>
|
---|
| 10 | #include <iostream.h>
|
---|
[787] | 11 | #include "basarr.h"
|
---|
[772] | 12 | #include "ndatablock.h"
|
---|
| 13 | #include <complex>
|
---|
[785] | 14 | #include "utilarr.h"
|
---|
[772] | 15 |
|
---|
| 16 |
|
---|
| 17 | namespace SOPHYA {
|
---|
| 18 |
|
---|
| 19 | // Forward declaration
|
---|
| 20 | template <class T> class FIO_TArray;
|
---|
| 21 |
|
---|
[787] | 22 | // --------------------------- classe template Array -----------------------
|
---|
| 23 | // ( See BaseArray class for data organisation in memory and related methods )
|
---|
| 24 |
|
---|
[894] | 25 | //! Class for template arrays
|
---|
[772] | 26 | template <class T>
|
---|
[787] | 27 | class TArray : public BaseArray {
|
---|
[772] | 28 | public:
|
---|
| 29 | // Creation / destruction
|
---|
| 30 | TArray();
|
---|
[804] | 31 | TArray(uint_4 ndim, const uint_4 * siz, uint_4 step =1);
|
---|
| 32 | TArray(uint_4 nx, uint_4 ny=0, uint_4 nz=0, uint_4 nt=0, uint_4 nu=0);
|
---|
| 33 | TArray(uint_4 ndim, const uint_4 * siz, NDataBlock<T> & db, bool share=false, uint_4 step=1, uint_8 offset=0);
|
---|
| 34 | TArray(uint_4 ndim, const uint_4 * siz, T* values, uint_4 step=1, uint_8 offset=0, Bridge* br=NULL);
|
---|
[772] | 35 | TArray(const TArray<T>& a);
|
---|
| 36 | TArray(const TArray<T>& a, bool share);
|
---|
| 37 |
|
---|
| 38 | virtual ~TArray();
|
---|
| 39 |
|
---|
[967] | 40 | // A = B
|
---|
[894] | 41 | //! = operator between TArray
|
---|
[976] | 42 | /*! \warning Datas are copied (cloned) from \b a.
|
---|
| 43 | \sa Set \sa NDataBlock::operator=(const NDataBlock<T>&) */
|
---|
[804] | 44 | inline TArray<T>& operator = (const TArray<T>& a) { return Set(a); }
|
---|
| 45 | virtual TArray<T>& Set(const TArray<T>& a);
|
---|
[772] | 46 |
|
---|
| 47 | // Gestion taille/Remplissage
|
---|
| 48 | virtual void Clone(const TArray<T>& a);
|
---|
[970] | 49 | // partage les donnees si "a" temporaire, clone sinon.
|
---|
| 50 | void CloneOrShare(const TArray<T>& a);
|
---|
| 51 | // Share: partage les donnees de "a"
|
---|
| 52 |
|
---|
| 53 | void Share(const TArray<T>& a);
|
---|
[804] | 54 | void ReSize(uint_4 ndim, uint_4 * siz, uint_4 step=1);
|
---|
| 55 | void Realloc(uint_4 ndim, uint_4 * siz, uint_4 step=1, bool force=false);
|
---|
[787] | 56 |
|
---|
[785] | 57 | // Compacts size=1 array dimensions
|
---|
[787] | 58 | virtual TArray<T>& CompactAllDimensions();
|
---|
| 59 | virtual TArray<T>& CompactTrailingDimensions();
|
---|
[785] | 60 |
|
---|
[804] | 61 | // Packing array elements in memory
|
---|
| 62 | virtual TArray<T> PackElements(bool force=false) const ;
|
---|
[772] | 63 |
|
---|
[804] | 64 | // SubArrays - $CHECK$ Reza 03/2000 je ne sais pas s'il faut declarer ca const ??
|
---|
[894] | 65 | TArray<T> SubArray(Range rx, Range ry, Range rz, Range rt, Range ru) const ;
|
---|
[963] | 66 | #if !defined(__GNUG__)
|
---|
[894] | 67 | //! () operator for Sub arrays extraction
|
---|
| 68 | /*! \sa SubArray */
|
---|
[804] | 69 | inline TArray<T> operator () (Range rx, Range ry, Range rz, Range rt=0, Range ru=0) const
|
---|
| 70 | { return SubArray(rx, ry, rz, rt, ru); }
|
---|
[963] | 71 | #else
|
---|
| 72 | // g++ (2.95) se melange les pinceaux avec les arguments par defaut !
|
---|
| 73 | //! () operator for Sub arrays extraction
|
---|
| 74 | /*! \sa SubArray */
|
---|
| 75 | inline TArray<T> operator () (Range rx, Range ry, Range rz) const
|
---|
| 76 | { return SubArray(rx, ry, rz, Range(0), Range(0)); }
|
---|
| 77 | inline TArray<T> operator () (Range rx, Range ry, Range rz, Range rt) const
|
---|
| 78 | { return SubArray(rx, ry, rz, rt, Range(0)); }
|
---|
| 79 | inline TArray<T> operator () (Range rx, Range ry, Range rz, Range rt, Range ru) const
|
---|
| 80 | { return SubArray(rx, ry, rz, rt, ru); }
|
---|
| 81 | #endif
|
---|
[772] | 82 |
|
---|
[787] | 83 | // ---- Access to data
|
---|
| 84 | // Definition of virtual element acces method inherited from BaseArray class
|
---|
| 85 | virtual double ValueAtPosition(uint_8 ip) const;
|
---|
[785] | 86 |
|
---|
[787] | 87 | // Data Access: operator overloaded inline acces methods
|
---|
[772] | 88 | inline T const& operator()(uint_4 ix, uint_4 iy, uint_4 iz) const ;
|
---|
| 89 | inline T& operator()(uint_4 ix, uint_4 iy, uint_4 iz);
|
---|
| 90 | inline T const& operator()(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu=0) const ;
|
---|
| 91 | inline T& operator()(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu=0);
|
---|
[785] | 92 | inline T const& operator[](uint_8 ip) const ;
|
---|
| 93 | inline T& operator[](uint_8 ip);
|
---|
[772] | 94 |
|
---|
| 95 | inline T const& Elem(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it=0, uint_4 iu=0) const ;
|
---|
| 96 | inline T& Elem(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it=0, uint_4 iu=0);
|
---|
| 97 | inline T const& ElemCheckBound(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it=0, uint_4 iu=0) const ;
|
---|
| 98 | inline T& ElemCheckBound(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it=0, uint_4 iu=0);
|
---|
| 99 |
|
---|
[894] | 100 | //! Return pointer to first element adress
|
---|
[772] | 101 | inline T* Data() {return mNDBlock.Begin()+offset_;}
|
---|
[894] | 102 | //! Return pointer to first element adress
|
---|
[772] | 103 | inline const T* Data() const {return mNDBlock.Begin()+offset_;}
|
---|
[894] | 104 | //! Return reference to datablock NDataBlock
|
---|
[772] | 105 | inline NDataBlock<T>& DataBlock() {return mNDBlock;}
|
---|
[894] | 106 | //! Return reference to datablock NDataBlock
|
---|
[772] | 107 | inline const NDataBlock<T>& DataBlock() const {return mNDBlock;}
|
---|
| 108 |
|
---|
[787] | 109 | // Temporaire?
|
---|
[894] | 110 | //! Are the array temporay ?
|
---|
[787] | 111 | inline bool IsTemp(void) const {return mNDBlock.IsTemp();}
|
---|
[894] | 112 | //! Set the array as temporay
|
---|
[787] | 113 | inline void SetTemp(bool temp=false) const {mNDBlock.SetTemp(temp);}
|
---|
| 114 |
|
---|
[772] | 115 | // Operations diverses = , +=, ...
|
---|
| 116 | // Conversion en type T, if Size() == 1
|
---|
[787] | 117 | inline T toScalar();
|
---|
[772] | 118 | // Met les elements a une suite de valeurs
|
---|
[813] | 119 | virtual TArray<T>& SetSeq(Sequence seq);
|
---|
[894] | 120 | //! Fill TArray with Sequence \b seq
|
---|
[813] | 121 | inline TArray<T>& operator = (Sequence seq) { return SetSeq(seq); }
|
---|
[772] | 122 | // A = x (tous les elements a x)
|
---|
[813] | 123 | virtual TArray<T>& SetT(T x);
|
---|
[894] | 124 | //! Fill TArray with all elements equal to \b x
|
---|
[813] | 125 | inline TArray<T>& operator = (T x) { return SetT(x); }
|
---|
[772] | 126 | // A += -= *= /= x (ajoute, soustrait, ... x a tous les elements)
|
---|
[804] | 127 | virtual TArray<T>& Add(T x);
|
---|
[894] | 128 | //! Add \b x to all elements
|
---|
[804] | 129 | inline TArray<T>& operator += (T x) { return Add(x); }
|
---|
[970] | 130 | virtual TArray<T>& Sub(T x, bool fginv=false);
|
---|
[894] | 131 | //! Substract \b x to all elements
|
---|
[804] | 132 | inline TArray<T>& operator -= (T x) { return Sub(x); }
|
---|
| 133 | virtual TArray<T>& Mul(T x);
|
---|
[894] | 134 | //! Multiply all elements by \b x
|
---|
[804] | 135 | inline TArray<T>& operator *= (T x) { return Mul(x); }
|
---|
[970] | 136 | virtual TArray<T>& Div(T x, bool fginv=false);
|
---|
[894] | 137 | //! Divide all elements by \b x
|
---|
[804] | 138 | inline TArray<T>& operator /= (T x) { return Div(x); }
|
---|
| 139 |
|
---|
[772] | 140 | // A += -= (ajoute, soustrait element par element les deux tableaux )
|
---|
[804] | 141 | virtual TArray<T>& AddElt(const TArray<T>& a);
|
---|
[894] | 142 | //! Operator TArray += TArray
|
---|
[804] | 143 | inline TArray<T>& operator += (const TArray<T>& a) { return AddElt(a); }
|
---|
[970] | 144 | virtual TArray<T>& SubElt(const TArray<T>& a, bool fginv=false);
|
---|
[894] | 145 | //! Operator TArray -= TArray
|
---|
[804] | 146 | inline TArray<T>& operator -= (const TArray<T>& a) { return SubElt(a); }
|
---|
[787] | 147 | // Multiplication, division element par element les deux tableaux
|
---|
[804] | 148 | virtual TArray<T>& MulElt(const TArray<T>& a);
|
---|
[970] | 149 | virtual TArray<T>& DivElt(const TArray<T>& a, bool fginv=false);
|
---|
[804] | 150 | // Recopie des valeurs, element par element
|
---|
| 151 | virtual TArray<T>& CopyElt(const TArray<T>& a);
|
---|
[772] | 152 |
|
---|
[804] | 153 | // Somme et produit des elements
|
---|
| 154 | virtual T Sum() const ;
|
---|
| 155 | virtual T Product() const ;
|
---|
| 156 |
|
---|
[772] | 157 | // Impression, I/O, ...
|
---|
[813] | 158 | virtual string InfoString() const;
|
---|
| 159 | virtual void Print(ostream& os, int_4 maxprt=-1, bool si=false) const ;
|
---|
[772] | 160 |
|
---|
| 161 | // Pour la gestion de persistance
|
---|
| 162 | friend class FIO_TArray<T>;
|
---|
| 163 |
|
---|
| 164 | protected:
|
---|
| 165 |
|
---|
[894] | 166 | NDataBlock<T> mNDBlock; //!< Block for datas
|
---|
[772] | 167 | };
|
---|
| 168 |
|
---|
| 169 | ////////////////////////////////////////////////////////////////
|
---|
| 170 | // Surcharge d'operateur <<
|
---|
[894] | 171 | //! Print TArray \b a on stream \b os
|
---|
[772] | 172 | template <class T>
|
---|
| 173 | inline ostream& operator << (ostream& os, const TArray<T>& a)
|
---|
| 174 | { a.Print(os); return(os); }
|
---|
| 175 |
|
---|
| 176 | ////////////////////////////////////////////////////////////////
|
---|
| 177 | // Surcharge d'operateurs A (+,-,*,/) (T) x
|
---|
| 178 |
|
---|
[958] | 179 | /*! \ingroup TArray \fn operator+(const TArray<T>&,T)
|
---|
| 180 | \brief Operator TArray = TArray + constant */
|
---|
[772] | 181 | template <class T> inline TArray<T> operator + (const TArray<T>& a, T b)
|
---|
[970] | 182 | {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
---|
| 183 | result.Add(b); return result;}
|
---|
[772] | 184 |
|
---|
[958] | 185 | /*! \ingroup TArray \fn operator+(T,const TArray<T>&)
|
---|
| 186 | \brief Operator TArray = constant + TArray */
|
---|
[772] | 187 | template <class T> inline TArray<T> operator + (T b,const TArray<T>& a)
|
---|
[970] | 188 | {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
---|
| 189 | result.Add(b); return result;}
|
---|
[772] | 190 |
|
---|
[958] | 191 | /*! \ingroup TArray \fn operator-(const TArray<T>&,T)
|
---|
| 192 | \brief Operator TArray = TArray - constant */
|
---|
[772] | 193 | template <class T> inline TArray<T> operator - (const TArray<T>& a, T b)
|
---|
[970] | 194 | {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
---|
| 195 | result.Sub(b); return result;}
|
---|
[772] | 196 |
|
---|
[958] | 197 | /*! \ingroup TArray \fn operator-(T,const TArray<T>&)
|
---|
| 198 | \brief Operator TArray = constant - TArray */
|
---|
[772] | 199 | template <class T> inline TArray<T> operator - (T b,const TArray<T>& a)
|
---|
[970] | 200 | {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
---|
| 201 | result.Sub(b,true); return result;}
|
---|
[772] | 202 |
|
---|
[958] | 203 | /*! \ingroup TArray \fn operator*(const TArray<T>&,T)
|
---|
| 204 | \brief Operator TArray = TArray * constant */
|
---|
[772] | 205 | template <class T> inline TArray<T> operator * (const TArray<T>& a, T b)
|
---|
[970] | 206 | {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
---|
| 207 | result.Mul(b); return result;}
|
---|
[772] | 208 |
|
---|
[958] | 209 | /*! \ingroup TArray \fn operator*(T,const TArray<T>&)
|
---|
| 210 | \brief Operator TArray = constant * TArray */
|
---|
[772] | 211 | template <class T> inline TArray<T> operator * (T b,const TArray<T>& a)
|
---|
[970] | 212 | {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
---|
| 213 | result.Mul(b); return result;}
|
---|
[772] | 214 |
|
---|
[958] | 215 | /*! \ingroup TArray \fn operator/(const TArray<T>&,T)
|
---|
| 216 | \brief Operator TArray = TArray / constant */
|
---|
[772] | 217 | template <class T> inline TArray<T> operator / (const TArray<T>& a, T b)
|
---|
[970] | 218 | {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
---|
| 219 | result.Div(b); return result;}
|
---|
[772] | 220 |
|
---|
[970] | 221 | /*! \ingroup TArray \fn operator/(T,const TArray<T>&)
|
---|
| 222 | \brief Operator TArray = constant / TArray */
|
---|
| 223 | template <class T> inline TArray<T> operator / (T b, const TArray<T>& a)
|
---|
| 224 | {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
---|
| 225 | result.Div(b, true); return result;}
|
---|
| 226 |
|
---|
[772] | 227 | ////////////////////////////////////////////////////////////////
|
---|
| 228 | // Surcharge d'operateurs C = A (+,-) B
|
---|
| 229 |
|
---|
[958] | 230 | /*! \ingroup TArray \fn operator+(const TArray<T>&,const TArray<T>&)
|
---|
| 231 | \brief Operator TArray = TArray + TArray */
|
---|
[772] | 232 | template <class T>
|
---|
| 233 | inline TArray<T> operator + (const TArray<T>& a,const TArray<T>& b)
|
---|
[970] | 234 | { TArray<T> result; result.SetTemp(true);
|
---|
| 235 | if (b.IsTemp()) { result.Share(b); result.AddElt(a); }
|
---|
| 236 | else { result.CloneOrShare(a); result.AddElt(b); }
|
---|
| 237 | return result; }
|
---|
[772] | 238 |
|
---|
[958] | 239 | /*! \ingroup TArray \fn operator-(const TArray<T>&,const TArray<T>&)
|
---|
| 240 | \brief Operator TArray = TArray - TArray */
|
---|
[772] | 241 | template <class T>
|
---|
| 242 | inline TArray<T> operator - (const TArray<T>& a,const TArray<T>& b)
|
---|
[970] | 243 | { TArray<T> result; result.SetTemp(true);
|
---|
| 244 | if (b.IsTemp()) { result.Share(b); result.SubElt(a, true); }
|
---|
| 245 | else { result.CloneOrShare(a); result.SubElt(b); }
|
---|
| 246 | return result; }
|
---|
[772] | 247 |
|
---|
| 248 |
|
---|
| 249 | // --------------------------------------------------
|
---|
| 250 | // inline element acces methods
|
---|
| 251 | // --------------------------------------------------
|
---|
[894] | 252 |
|
---|
| 253 | //! Return element (ix,iy,iz,it,iu) value
|
---|
[772] | 254 | template <class T>
|
---|
| 255 | inline T const& TArray<T>::Elem(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) const
|
---|
| 256 | {
|
---|
| 257 | return ( *( mNDBlock.Begin()+ offset_+
|
---|
| 258 | ix*step_[0] + iy*step_[1] + iz*step_[2] +
|
---|
| 259 | it*step_[3] + iu*step_[4]) );
|
---|
| 260 | }
|
---|
| 261 |
|
---|
[894] | 262 | //! Return element (ix,iy,iz,it,iu) value
|
---|
[772] | 263 | template <class T>
|
---|
| 264 | inline T & TArray<T>::Elem(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu)
|
---|
| 265 | {
|
---|
| 266 | return ( *( mNDBlock.Begin()+ offset_+
|
---|
| 267 | ix*step_[0] + iy*step_[1] + iz*step_[2] +
|
---|
| 268 | it*step_[3] + iu*step_[4]) );
|
---|
| 269 | }
|
---|
| 270 |
|
---|
[894] | 271 | //! Return element (ix,iy,iz,it,iu) value with Check of indexes bound first
|
---|
[772] | 272 | template <class T>
|
---|
| 273 | inline T const& TArray<T>::ElemCheckBound(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) const
|
---|
| 274 | {
|
---|
| 275 | CheckBound(ix, iy, iz, it, iu, 4);
|
---|
[804] | 276 | return(Elem(ix, iy, iz, it, iu));
|
---|
[772] | 277 | }
|
---|
| 278 |
|
---|
[894] | 279 | //! Return element (ix,iy,iz,it,iu) value with Check of indexes bound first
|
---|
[772] | 280 | template <class T>
|
---|
| 281 | inline T & TArray<T>::ElemCheckBound(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu)
|
---|
| 282 | {
|
---|
| 283 | CheckBound(ix, iy, iz, it, iu, 4);
|
---|
[804] | 284 | return(Elem(ix, iy, iz, it, iu));
|
---|
[772] | 285 | }
|
---|
| 286 |
|
---|
[894] | 287 | //! Return element (ix,iy,iz) value
|
---|
[772] | 288 | template <class T>
|
---|
| 289 | inline T const& TArray<T>::operator()(uint_4 ix, uint_4 iy, uint_4 iz) const
|
---|
| 290 | {
|
---|
| 291 | #ifdef SO_BOUNDCHECKING
|
---|
| 292 | CheckBound(ix, iy, iz, 0, 0, 4);
|
---|
| 293 | #endif
|
---|
| 294 | return ( *( mNDBlock.Begin()+ offset_+
|
---|
| 295 | ix*step_[0] + iy*step_[1] + iz*step_[2]) );
|
---|
| 296 | }
|
---|
| 297 |
|
---|
[894] | 298 | //! Return element (ix,iy,iz) value
|
---|
[772] | 299 | template <class T>
|
---|
| 300 | inline T & TArray<T>::operator()(uint_4 ix, uint_4 iy, uint_4 iz)
|
---|
| 301 | {
|
---|
| 302 | #ifdef SO_BOUNDCHECKING
|
---|
| 303 | CheckBound(ix, iy, iz, 0, 0, 4);
|
---|
| 304 | #endif
|
---|
| 305 | return ( *( mNDBlock.Begin()+ offset_+
|
---|
| 306 | ix*step_[0] + iy*step_[1] + iz*step_[2]) );
|
---|
| 307 | }
|
---|
| 308 |
|
---|
[894] | 309 | //! Operator () : return element (ix,iy,iz,it,iu) value
|
---|
[772] | 310 | template <class T>
|
---|
| 311 | inline T const& TArray<T>::operator()(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) const
|
---|
| 312 | {
|
---|
| 313 | #ifdef SO_BOUNDCHECKING
|
---|
| 314 | CheckBound(ix, iy, iz, it, iu, 4);
|
---|
| 315 | #endif
|
---|
| 316 | return ( *( mNDBlock.Begin()+ offset_+
|
---|
| 317 | ix*step_[0] + iy*step_[1] + iz*step_[2] +
|
---|
| 318 | it*step_[3] + iu*step_[4]) );
|
---|
| 319 | }
|
---|
| 320 |
|
---|
[894] | 321 | //! Operator () : return element (ix,iy,iz,it,iu) value
|
---|
[772] | 322 | template <class T>
|
---|
| 323 | inline T & TArray<T>::operator()(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu)
|
---|
| 324 | {
|
---|
| 325 | #ifdef SO_BOUNDCHECKING
|
---|
| 326 | CheckBound(ix, iy, iz, it, iu, 4);
|
---|
| 327 | #endif
|
---|
| 328 | return ( *( mNDBlock.Begin()+ offset_+
|
---|
| 329 | ix*step_[0] + iy*step_[1] + iz*step_[2] +
|
---|
| 330 | it*step_[3] + iu*step_[4]) );
|
---|
| 331 | }
|
---|
| 332 |
|
---|
[785] | 333 |
|
---|
[894] | 334 | //! Operator [] : return element at positon ip
|
---|
[772] | 335 | template <class T>
|
---|
[785] | 336 | inline T const& TArray<T>::operator[](uint_8 ip) const
|
---|
[772] | 337 | {
|
---|
| 338 | #ifdef SO_BOUNDCHECKING
|
---|
| 339 | if (ip >= totsize_) throw( ParmError("TArray<T>::operator[] Out-of-bound Error") );
|
---|
| 340 | #endif
|
---|
[785] | 341 | return *(mNDBlock.Begin()+Offset(ip));
|
---|
[772] | 342 | }
|
---|
| 343 |
|
---|
[894] | 344 | //! Operator [] : return element at positon ip
|
---|
[772] | 345 | template <class T>
|
---|
[785] | 346 | inline T & TArray<T>::operator[](uint_8 ip)
|
---|
[772] | 347 | {
|
---|
| 348 | #ifdef SO_BOUNDCHECKING
|
---|
| 349 | if (ip >= totsize_) throw( ParmError("TArray<T>::operator[] Out-of-bound Error") );
|
---|
| 350 | #endif
|
---|
[785] | 351 | return *(mNDBlock.Begin()+Offset(ip));
|
---|
[772] | 352 | }
|
---|
| 353 |
|
---|
[785] | 354 |
|
---|
[894] | 355 | //! Return the value of first element
|
---|
[772] | 356 | template <class T>
|
---|
[787] | 357 | inline T TArray<T>::toScalar()
|
---|
[772] | 358 | {
|
---|
| 359 | if (Size() != 1) throw(SzMismatchError("TArray<T>::operator T() Size() != 1")) ;
|
---|
| 360 | return ( (*this)[0] );
|
---|
| 361 | }
|
---|
| 362 |
|
---|
[804] | 363 | // Typedef pour simplifier
|
---|
[956] | 364 | /*! \ingroup TArray
|
---|
| 365 | \typedef Array
|
---|
| 366 | \brief To simplified TArray<r_8> writing
|
---|
| 367 | */
|
---|
[804] | 368 | typedef TArray<r_8> Array;
|
---|
| 369 |
|
---|
[772] | 370 | } // Fin du namespace
|
---|
| 371 |
|
---|
| 372 | #endif
|
---|