| 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 | /*! \warning Datas are copied (cloned) from \b a.
|
|---|
| 43 | \sa Set \sa NDataBlock::operator=(const NDataBlock<T>&) */
|
|---|
| 44 | inline TArray<T>& operator = (const TArray<T>& a) { return Set(a); }
|
|---|
| 45 | virtual TArray<T>& Set(const TArray<T>& a);
|
|---|
| 46 |
|
|---|
| 47 | // Gestion taille/Remplissage
|
|---|
| 48 | virtual void Clone(const TArray<T>& a);
|
|---|
| 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);
|
|---|
| 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);
|
|---|
| 56 |
|
|---|
| 57 | // Compacts size=1 array dimensions
|
|---|
| 58 | virtual TArray<T>& CompactAllDimensions();
|
|---|
| 59 | virtual TArray<T>& CompactTrailingDimensions();
|
|---|
| 60 |
|
|---|
| 61 | // Packing array elements in memory
|
|---|
| 62 | virtual TArray<T> PackElements(bool force=false) const ;
|
|---|
| 63 |
|
|---|
| 64 | // SubArrays - $CHECK$ Reza 03/2000 je ne sais pas s'il faut declarer ca const ??
|
|---|
| 65 | TArray<T> SubArray(Range rx, Range ry, Range rz, Range rt, Range ru) const ;
|
|---|
| 66 | #if !defined(__GNUG__)
|
|---|
| 67 | //! () operator for Sub arrays extraction
|
|---|
| 68 | /*! \sa SubArray */
|
|---|
| 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); }
|
|---|
| 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
|
|---|
| 82 |
|
|---|
| 83 | // ---- Access to data
|
|---|
| 84 | // Definition of virtual element acces method inherited from BaseArray class
|
|---|
| 85 | virtual double ValueAtPosition(uint_8 ip) const;
|
|---|
| 86 |
|
|---|
| 87 | // Data Access: operator overloaded inline acces methods
|
|---|
| 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);
|
|---|
| 92 | inline T const& operator[](uint_8 ip) const ;
|
|---|
| 93 | inline T& operator[](uint_8 ip);
|
|---|
| 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 |
|
|---|
| 100 | //! Return pointer to first element adress
|
|---|
| 101 | inline T* Data() {return mNDBlock.Begin()+offset_;}
|
|---|
| 102 | //! Return pointer to first element adress
|
|---|
| 103 | inline const T* Data() const {return mNDBlock.Begin()+offset_;}
|
|---|
| 104 | //! Return reference to datablock NDataBlock
|
|---|
| 105 | inline NDataBlock<T>& DataBlock() {return mNDBlock;}
|
|---|
| 106 | //! Return reference to datablock NDataBlock
|
|---|
| 107 | inline const NDataBlock<T>& DataBlock() const {return mNDBlock;}
|
|---|
| 108 |
|
|---|
| 109 | // Temporaire?
|
|---|
| 110 | //! Are the array temporay ?
|
|---|
| 111 | inline bool IsTemp(void) const {return mNDBlock.IsTemp();}
|
|---|
| 112 | //! Set the array as temporay
|
|---|
| 113 | inline void SetTemp(bool temp=false) const {mNDBlock.SetTemp(temp);}
|
|---|
| 114 |
|
|---|
| 115 | // Operations diverses = , +=, ...
|
|---|
| 116 | // Conversion en type T, if Size() == 1
|
|---|
| 117 | inline T toScalar();
|
|---|
| 118 | // Met les elements a une suite de valeurs
|
|---|
| 119 | virtual TArray<T>& SetSeq(Sequence seq);
|
|---|
| 120 | //! Fill TArray with Sequence \b seq
|
|---|
| 121 | inline TArray<T>& operator = (Sequence seq) { return SetSeq(seq); }
|
|---|
| 122 | // A = x (tous les elements a x)
|
|---|
| 123 | virtual TArray<T>& SetT(T x);
|
|---|
| 124 | //! Fill TArray with all elements equal to \b x
|
|---|
| 125 | inline TArray<T>& operator = (T x) { return SetT(x); }
|
|---|
| 126 | // A += -= *= /= x (ajoute, soustrait, ... x a tous les elements)
|
|---|
| 127 | virtual TArray<T>& Add(T x);
|
|---|
| 128 | //! Add \b x to all elements
|
|---|
| 129 | inline TArray<T>& operator += (T x) { return Add(x); }
|
|---|
| 130 | virtual TArray<T>& Sub(T x, bool fginv=false);
|
|---|
| 131 | //! Substract \b x to all elements
|
|---|
| 132 | inline TArray<T>& operator -= (T x) { return Sub(x); }
|
|---|
| 133 | virtual TArray<T>& Mul(T x);
|
|---|
| 134 | //! Multiply all elements by \b x
|
|---|
| 135 | inline TArray<T>& operator *= (T x) { return Mul(x); }
|
|---|
| 136 | virtual TArray<T>& Div(T x, bool fginv=false);
|
|---|
| 137 | //! Divide all elements by \b x
|
|---|
| 138 | inline TArray<T>& operator /= (T x) { return Div(x); }
|
|---|
| 139 |
|
|---|
| 140 | // A += -= (ajoute, soustrait element par element les deux tableaux )
|
|---|
| 141 | virtual TArray<T>& AddElt(const TArray<T>& a);
|
|---|
| 142 | //! Operator TArray += TArray
|
|---|
| 143 | inline TArray<T>& operator += (const TArray<T>& a) { return AddElt(a); }
|
|---|
| 144 | virtual TArray<T>& SubElt(const TArray<T>& a, bool fginv=false);
|
|---|
| 145 | //! Operator TArray -= TArray
|
|---|
| 146 | inline TArray<T>& operator -= (const TArray<T>& a) { return SubElt(a); }
|
|---|
| 147 | // Multiplication, division element par element les deux tableaux
|
|---|
| 148 | virtual TArray<T>& MulElt(const TArray<T>& a);
|
|---|
| 149 | virtual TArray<T>& DivElt(const TArray<T>& a, bool fginv=false);
|
|---|
| 150 | // Recopie des valeurs, element par element
|
|---|
| 151 | virtual TArray<T>& CopyElt(const TArray<T>& a);
|
|---|
| 152 |
|
|---|
| 153 | // Somme et produit des elements
|
|---|
| 154 | virtual T Sum() const ;
|
|---|
| 155 | virtual T Product() const ;
|
|---|
| 156 |
|
|---|
| 157 | // Impression, I/O, ...
|
|---|
| 158 | virtual string InfoString() const;
|
|---|
| 159 | virtual void Print(ostream& os, int_4 maxprt=-1, bool si=false) const ;
|
|---|
| 160 |
|
|---|
| 161 | // Pour la gestion de persistance
|
|---|
| 162 | friend class FIO_TArray<T>;
|
|---|
| 163 |
|
|---|
| 164 | protected:
|
|---|
| 165 |
|
|---|
| 166 | NDataBlock<T> mNDBlock; //!< Block for datas
|
|---|
| 167 | };
|
|---|
| 168 |
|
|---|
| 169 | ////////////////////////////////////////////////////////////////
|
|---|
| 170 | // Surcharge d'operateur <<
|
|---|
| 171 | //! Print TArray \b a on stream \b os
|
|---|
| 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 |
|
|---|
| 179 | /*! \ingroup TArray \fn operator+(const TArray<T>&,T)
|
|---|
| 180 | \brief Operator TArray = TArray + constant */
|
|---|
| 181 | template <class T> inline TArray<T> operator + (const TArray<T>& a, T b)
|
|---|
| 182 | {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
|---|
| 183 | result.Add(b); return result;}
|
|---|
| 184 |
|
|---|
| 185 | /*! \ingroup TArray \fn operator+(T,const TArray<T>&)
|
|---|
| 186 | \brief Operator TArray = constant + TArray */
|
|---|
| 187 | template <class T> inline TArray<T> operator + (T b,const TArray<T>& a)
|
|---|
| 188 | {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
|---|
| 189 | result.Add(b); return result;}
|
|---|
| 190 |
|
|---|
| 191 | /*! \ingroup TArray \fn operator-(const TArray<T>&,T)
|
|---|
| 192 | \brief Operator TArray = TArray - constant */
|
|---|
| 193 | template <class T> inline TArray<T> operator - (const TArray<T>& a, T b)
|
|---|
| 194 | {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
|---|
| 195 | result.Sub(b); return result;}
|
|---|
| 196 |
|
|---|
| 197 | /*! \ingroup TArray \fn operator-(T,const TArray<T>&)
|
|---|
| 198 | \brief Operator TArray = constant - TArray */
|
|---|
| 199 | template <class T> inline TArray<T> operator - (T b,const TArray<T>& a)
|
|---|
| 200 | {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
|---|
| 201 | result.Sub(b,true); return result;}
|
|---|
| 202 |
|
|---|
| 203 | /*! \ingroup TArray \fn operator*(const TArray<T>&,T)
|
|---|
| 204 | \brief Operator TArray = TArray * constant */
|
|---|
| 205 | template <class T> inline TArray<T> operator * (const TArray<T>& a, T b)
|
|---|
| 206 | {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
|---|
| 207 | result.Mul(b); return result;}
|
|---|
| 208 |
|
|---|
| 209 | /*! \ingroup TArray \fn operator*(T,const TArray<T>&)
|
|---|
| 210 | \brief Operator TArray = constant * TArray */
|
|---|
| 211 | template <class T> inline TArray<T> operator * (T b,const TArray<T>& a)
|
|---|
| 212 | {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
|---|
| 213 | result.Mul(b); return result;}
|
|---|
| 214 |
|
|---|
| 215 | /*! \ingroup TArray \fn operator/(const TArray<T>&,T)
|
|---|
| 216 | \brief Operator TArray = TArray / constant */
|
|---|
| 217 | template <class T> inline TArray<T> operator / (const TArray<T>& a, T b)
|
|---|
| 218 | {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
|---|
| 219 | result.Div(b); return result;}
|
|---|
| 220 |
|
|---|
| 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 |
|
|---|
| 227 | ////////////////////////////////////////////////////////////////
|
|---|
| 228 | // Surcharge d'operateurs C = A (+,-) B
|
|---|
| 229 |
|
|---|
| 230 | /*! \ingroup TArray \fn operator+(const TArray<T>&,const TArray<T>&)
|
|---|
| 231 | \brief Operator TArray = TArray + TArray */
|
|---|
| 232 | template <class T>
|
|---|
| 233 | inline TArray<T> operator + (const TArray<T>& a,const TArray<T>& b)
|
|---|
| 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; }
|
|---|
| 238 |
|
|---|
| 239 | /*! \ingroup TArray \fn operator-(const TArray<T>&,const TArray<T>&)
|
|---|
| 240 | \brief Operator TArray = TArray - TArray */
|
|---|
| 241 | template <class T>
|
|---|
| 242 | inline TArray<T> operator - (const TArray<T>& a,const TArray<T>& b)
|
|---|
| 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; }
|
|---|
| 247 |
|
|---|
| 248 |
|
|---|
| 249 | // --------------------------------------------------
|
|---|
| 250 | // inline element acces methods
|
|---|
| 251 | // --------------------------------------------------
|
|---|
| 252 |
|
|---|
| 253 | //! Return element (ix,iy,iz,it,iu) value
|
|---|
| 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 |
|
|---|
| 262 | //! Return element (ix,iy,iz,it,iu) value
|
|---|
| 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 |
|
|---|
| 271 | //! Return element (ix,iy,iz,it,iu) value with Check of indexes bound first
|
|---|
| 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);
|
|---|
| 276 | return(Elem(ix, iy, iz, it, iu));
|
|---|
| 277 | }
|
|---|
| 278 |
|
|---|
| 279 | //! Return element (ix,iy,iz,it,iu) value with Check of indexes bound first
|
|---|
| 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);
|
|---|
| 284 | return(Elem(ix, iy, iz, it, iu));
|
|---|
| 285 | }
|
|---|
| 286 |
|
|---|
| 287 | //! Return element (ix,iy,iz) value
|
|---|
| 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 |
|
|---|
| 298 | //! Return element (ix,iy,iz) value
|
|---|
| 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 |
|
|---|
| 309 | //! Operator () : return element (ix,iy,iz,it,iu) value
|
|---|
| 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 |
|
|---|
| 321 | //! Operator () : return element (ix,iy,iz,it,iu) value
|
|---|
| 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 |
|
|---|
| 333 |
|
|---|
| 334 | //! Operator [] : return element at positon ip
|
|---|
| 335 | template <class T>
|
|---|
| 336 | inline T const& TArray<T>::operator[](uint_8 ip) const
|
|---|
| 337 | {
|
|---|
| 338 | #ifdef SO_BOUNDCHECKING
|
|---|
| 339 | if (ip >= totsize_) throw( ParmError("TArray<T>::operator[] Out-of-bound Error") );
|
|---|
| 340 | #endif
|
|---|
| 341 | return *(mNDBlock.Begin()+Offset(ip));
|
|---|
| 342 | }
|
|---|
| 343 |
|
|---|
| 344 | //! Operator [] : return element at positon ip
|
|---|
| 345 | template <class T>
|
|---|
| 346 | inline T & TArray<T>::operator[](uint_8 ip)
|
|---|
| 347 | {
|
|---|
| 348 | #ifdef SO_BOUNDCHECKING
|
|---|
| 349 | if (ip >= totsize_) throw( ParmError("TArray<T>::operator[] Out-of-bound Error") );
|
|---|
| 350 | #endif
|
|---|
| 351 | return *(mNDBlock.Begin()+Offset(ip));
|
|---|
| 352 | }
|
|---|
| 353 |
|
|---|
| 354 |
|
|---|
| 355 | //! Return the value of first element
|
|---|
| 356 | template <class T>
|
|---|
| 357 | inline T TArray<T>::toScalar()
|
|---|
| 358 | {
|
|---|
| 359 | if (Size() != 1) throw(SzMismatchError("TArray<T>::operator T() Size() != 1")) ;
|
|---|
| 360 | return ( (*this)[0] );
|
|---|
| 361 | }
|
|---|
| 362 |
|
|---|
| 363 | // Typedef pour simplifier
|
|---|
| 364 | /*! \ingroup TArray
|
|---|
| 365 | \typedef Array
|
|---|
| 366 | \brief To simplified TArray<r_8> writing
|
|---|
| 367 | */
|
|---|
| 368 | typedef TArray<r_8> Array;
|
|---|
| 369 |
|
|---|
| 370 | } // Fin du namespace
|
|---|
| 371 |
|
|---|
| 372 | #endif
|
|---|