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