Changeset 894 in Sophya for trunk/SophyaLib/TArray/tarray.cc


Ignore:
Timestamp:
Apr 12, 2000, 7:42:33 PM (25 years ago)
Author:
ansari
Message:

documentation cmv 12/4/00

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/TArray/tarray.cc

    r850 r894  
    1515// -------------------------------------------------------
    1616
    17 // Les constructeurs
     17////////////////////////// Les constructeurs / destructeurs
     18
     19//! Default constructor
    1820template <class T>
    1921TArray<T>::TArray()
    2022  : BaseArray() , mNDBlock()
    21 // Default constructor
    22 {
    23 }
    24 
     23{
     24}
     25
     26//! Constructor
     27/*!
     28  \param ndim : number of dimensions (less or equal to
     29                \ref BASEARRAY_MAXNDIMS "BASEARRAY_MAXNDIMS")
     30  \param siz[ndim] : size along each dimension
     31  \param step : step (same for all dimensions)
     32 */
    2533template <class T>
    2634TArray<T>::TArray(uint_4 ndim, const uint_4 * siz, uint_4 step)
     
    3139}
    3240
     41//! Constructor
     42/*!
     43  \param nx,ny,nz,nt,nu : sizes along first, second, third, fourth and fifth dimension
     44 */
    3345template <class T>
    3446TArray<T>::TArray(uint_4 nx, uint_4 ny, uint_4 nz, uint_4 nt, uint_4 nu)
     
    4860}
    4961
     62//! Constructor
     63/*!
     64  \param ndim : number of dimensions
     65  \param siz[ndim] : size along each dimension
     66  \param db : datas are given by this NDataBlock
     67  \param share : if true, data are shared, if false they are copied
     68  \param step : step (same for all dimensions) in data block
     69  \param offset : offset for first element in data block
     70 */
    5071template <class T>
    5172TArray<T>::TArray(uint_4 ndim, const uint_4 * siz, NDataBlock<T> & db, bool share, uint_4 step, uint_8 offset)
     
    5778}
    5879
     80//! Constructor
     81/*!
     82  \param ndim : number of dimensions
     83  \param siz[ndim] : size along each dimension
     84  \param values : datas are given by this pointer
     85  \param share : if true, data are shared, if false they are copied
     86  \param step : step (same for all dimensions) in data block
     87  \param offset : offset for first element in data block
     88  \param br : if not NULL, dats are bridge with other datas
     89  \sa NDataBlock
     90 */
    5991template <class T>
    6092TArray<T>::TArray(uint_4 ndim, const uint_4 * siz, T* values, uint_4 step, uint_8 offset, Bridge* br)
     
    6597}
    6698
     99//! Constructor by copy
    67100template <class T>
    68101TArray<T>::TArray(const TArray<T>& a)
     
    74107}
    75108
     109//! Constructor by copy
     110/*!
     111  \param share : if true, data are shared, if false they are copied
     112 */
    76113template <class T>
    77114TArray<T>::TArray(const TArray<T>& a, bool share)
     
    83120}
    84121
    85 // Destructeur
     122//! Destructor
    86123template <class T>
    87124TArray<T>::~TArray()
     
    89126}
    90127
     128////////////////////////// Les methodes de copie/share
     129
     130//! Set array equal to \b a and return *this
    91131template <class T>
    92132TArray<T>& TArray<T>::Set(const TArray<T>& a)
     
    94134  if (this != &a) {
    95135    CloneOrShare(a);
    96     if (mInfo) delete mInfo;
     136    if (mInfo) {delete mInfo; mInfo = NULL;}
    97137    if (a.mInfo) mInfo = new DVList(*(a.mInfo));
    98138  }
     
    100140}
    101141
     142//! Clone array \b a
    102143template <class T>
    103144void TArray<T>::Clone(const TArray<T>& a)
     
    106147  if (!UpdateSizes(a, exmsg))  throw( ParmError(exmsg) );
    107148  mNDBlock.Clone(a.mNDBlock);
    108   if (mInfo) delete mInfo;
     149  if (mInfo) {delete mInfo; mInfo = NULL;}
    109150  if (a.mInfo) mInfo = new DVList(*(a.mInfo));
    110151}
    111152
     153//! Resize array
     154/*!
     155  \param ndim : number of dimensions
     156  \param siz[ndim] : size along each dimension
     157  \param step : step (same for all dimensions)
     158 */
    112159template <class T>
    113160void TArray<T>::ReSize(uint_4 ndim, uint_4 * siz, uint_4 step)
     
    118165}
    119166
     167//! Re-allocate space for array
     168/*!
     169  \param ndim : number of dimensions
     170  \param siz[ndim] : size along each dimension
     171  \param step : step (same for all dimensions)
     172  \param force : if true re-allocation is forced, if not it occurs
     173          only if the required space is greater than the old one.
     174 */
    120175template <class T>
    121176void TArray<T>::Realloc(uint_4 ndim, uint_4 * siz, uint_4 step, bool force)
     
    127182
    128183
     184//! Compact dimensions in one or more is equal to 1.
    129185template <class T>
    130186TArray<T>& TArray<T>::CompactAllDimensions()
     
    134190}
    135191
     192//! Compact dimensions if the last one is equal to 1.
    136193template <class T>
    137194TArray<T>& TArray<T>::CompactTrailingDimensions()
     
    141198}
    142199
     200//! Give value (in \b double) for element at position \b ip..
    143201template <class T>
    144202double TArray<T>::ValueAtPosition(uint_8 ip) const
     
    150208}
    151209
    152 // For complex values, we return the module of the complex number
     210//! Give value (in \b double) for element at position \b ip..
     211/*!
     212  For complex values, we return the module of the complex number
     213*/
    153214double TArray< complex<r_4> >::ValueAtPosition(uint_8 ip) const
    154215{
     
    162223}
    163224
     225//! Give value (in \b double) for element at position \b ip..
     226/*!
     227  For complex values, we return the module of the complex number
     228*/
    164229double TArray< complex<r_8> >::ValueAtPosition(uint_8 ip) const
    165230{
     
    173238}
    174239
    175 
     240//! Return array with elements packed
     241/*!
     242  \param force : if true, pack elements in a new array.
     243                 If false and array is already packed, return
     244                 an array that share data with the current one.
     245  \return packed array
     246 */
    176247template <class T>
    177248TArray<T> TArray<T>::PackElements(bool force) const
     
    194265// SubArrays
    195266// $CHECK$ Reza 03/2000  Doit-on declarer cette methode const ?
     267//! Extract a sub-array
     268/*!
     269  \param rx,ry,rz,rt,ru : range of extraction along dimensions
     270  \sa Range
     271 */
    196272template <class T>
    197273TArray<T> TArray<T>::SubArray(Range rx, Range ry, Range rz, Range rt, Range ru) const
     
    232308//              ------- Attention --------
    233309//  Boucles normales prenant en compte les steps ....
    234 //  Possibilite de // , vectorisation
     310//  Possibilite de // , vectorisation
     311
     312//! Fill TArray with Sequence \b seq
     313/*!
     314  \param seq : sequence to fill the array
     315  \sa Sequence
     316 */
    235317template <class T>
    236318TArray<T>& TArray<T>::SetSeq(Sequence seq)
     
    261343//  >>>> Operations avec 2nd membre de type scalaire
    262344
     345//! Fill an array with a constant value \b x
    263346template <class T>
    264347TArray<T>& TArray<T>::SetT(T x)
     
    287370}
    288371
     372//! Add a constant value \b x to an array
    289373template <class T>
    290374TArray<T>& TArray<T>::Add(T x)
     
    313397}
    314398
     399//! Substract a constant value \b x to an array
    315400template <class T>
    316401TArray<T>& TArray<T>::Sub(T x)
     
    339424}
    340425
     426//! Multiply an array by a constant value \b x
    341427template <class T>
    342428TArray<T>& TArray<T>::Mul(T x)
     
    365451}
    366452
     453//! Divide an array by a constant value \b x
    367454template <class T>
    368455TArray<T>& TArray<T>::Div(T x)
     
    370457  if (NbDimensions() < 1)
    371458    throw RangeCheckError("TArray<T>::Div(T )  - Not Allocated Array ! ");
     459  if (x == (T) 0 )
     460    throw MathExc("TArray<T>::Div(T )  - Divide by zero ! ");
    372461  T * pe;
    373462  uint_8 j,k;
     
    392481
    393482
     483//! Inverse substract : A = \b x - A
    394484template <class T>
    395485TArray<T>& TArray<T>::SubInv(T x)
     
    418508}
    419509
     510//! Inverse Divide : A(i,j,...) = x / A(i,j,...)
    420511template <class T>
    421512TArray<T>& TArray<T>::DivInv(T x)
     
    446537
    447538//  >>>> Operations avec 2nd membre de type tableau
     539//! Add two TArrays
    448540template <class T>
    449541TArray<T>& TArray<T>::AddElt(const TArray<T>& a)
     
    480572}
    481573
     574//! Substract two TArrays
    482575template <class T>
    483576TArray<T>& TArray<T>::SubElt(const TArray<T>& a)
     
    514607}
    515608
    516 
     609//! Multiply two TArrays (elements by elements)
    517610template <class T>
    518611TArray<T>& TArray<T>::MulElt(const TArray<T>& a)
     
    550643
    551644
     645//! Divide two TArrays (elements by elements)
    552646template <class T>
    553647TArray<T>& TArray<T>::DivElt(const TArray<T>& a)
     
    584678}
    585679
     680//! Copy elements of \b a
    586681template <class T>
    587682TArray<T>& TArray<T>::CopyElt(const TArray<T>& a)
     
    620715
    621716// Somme et produit des elements
     717//! Sum all elements
    622718template <class T>
    623719T TArray<T>::Sum() const
     
    647743}
    648744
     745//! Multiply all elements
    649746template <class T>
    650747T TArray<T>::Product() const
     
    680777// ----------------------------------------------------
    681778
     779//! Return a string that contain the type \b T of the array
    682780template <class T>
    683781string TArray<T>::InfoString() const
     
    689787}
    690788
     789//! Print array
     790/*!
     791  \param os : output stream
     792  \param maxprt : maximum numer of print
     793  \param si : if true,  display attached DvList
     794  \sa SetMaxPrint
     795 */
    691796template <class T>
    692797void TArray<T>::Print(ostream& os, int_4 maxprt, bool si) const
     
    720825}
    721826
    722 
     827//! Clone if \b a is not temporary, share if temporary
    723828template <class T>
    724829void TArray<T>::CloneOrShare(const TArray<T>& a)
     
    729834}
    730835
     836//! Share data with a
    731837template <class T>
    732838void TArray<T>::Share(const TArray<T>& a)
Note: See TracChangeset for help on using the changeset viewer.