Changeset 894 in Sophya for trunk/SophyaLib/TArray


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

documentation cmv 12/4/00

Location:
trunk/SophyaLib/TArray
Files:
15 edited

Legend:

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

    r890 r894  
    99
    1010// Variables statiques globales
    11 char * BaseArray::ck_op_msg_[6] = {"???", "Size(int )", "IsPacked(int )",
    12                        "Stride(int )", "ElemCheckBound()", "operator()" };
     11char * BaseArray::ck_op_msg_[6] =
     12     {"???", "Size(int )", "IsPacked(int )"
     13     ,"Stride(int )", "ElemCheckBound()", "operator()" };
    1314uint_4 BaseArray::max_nprt_ = 50;
    1415uint_4 BaseArray::prt_lev_ = 0;
     
    1920// ------ Methodes statiques globales --------
    2021
    21 //  1/ Gestion des impressions
    2222//! Set maximum number of printed elements and print level
    2323/*!
     
    4141
    4242
     43//! Compute totale size
     44/*!
     45  \param ndim : number of dimensions
     46  \param siz : array of size along the \b ndim dimensions
     47  \param step[ndim] : step value
     48  \param offset : offset value
     49  \return Total size of the array
     50*/
    4351uint_8 BaseArray::ComputeTotalSize(uint_4 ndim, const uint_4 * siz, uint_4 step, uint_8 offset)
    4452{
     
    4856}
    4957
     58//! Set Default Memory Mapping
     59/*!
     60  \param mm : Memory Mapping type
     61  \verbatim
     62     mm == CMemoryMapping : C like memory mapping
     63     mm == FortranMemoryMapping : Fortran like memory mapping
     64  \endverbatim
     65  \verbatim
     66  # ===== For Matrices
     67  *** MATHEMATICS:   m(row,column) with indexes running [1,n])
     68                          | 11 12 13 |
     69     matrix Math = Mmath= | 21 22 23 |
     70                          | 31 32 33 |
     71  *** IDL, \b FORTRAN: indexes data in \b row-major format:
     72     indexes arrays in (column,row) order.
     73     index IDL running [0,n[ ; index FORTRAN running [1,n]
     74     M in memory: [ 11 12 13 : 21 22 23 : 31 32 33 : ... ]
     75                     line 1  : line 2   : line 3  : ...
     76     ex: Midl(0,2) = Mfor(1,3) = Mmath(3,1) = 31
     77         Midl(2,0) = Mfor(3,1) = Mmath(1,3) = 13
     78  *** C: indexes data in \b column-major format:
     79     indexes arrays in [row][column] order.
     80     index C running [0,n[
     81     M in memory: [ 11 21 31 : 12 22 32 : 13 23 33 : ... ]
     82                    column 1 : column 2 : column 3 : ...
     83     ex: Mc[2][0] = Mmath(3,1) = 31
     84         Mc[0][2] = Mmath(1,3) = 13
     85  *** RESUME diff Idl/Fortan/C/Math:
     86    Midl(col-1,row-1) = Mfor(col,row) = Mc[row-1][col-1] = Mmath(row,col)
     87    TRANSPOSE(column-major array) --> row-major array
     88  \endverbatim
     89  \return default memory mapping value
     90 */
    5091short BaseArray::SetDefaultMemoryMapping(short mm)
    5192{
     
    5495}
    5596
     97//! Set Default Vector Type
     98/*!
     99  \param vt : vector type (ColumnVector,RowVector)
     100  \return default vector type value
     101 */
    56102short BaseArray::SetDefaultVectorType(short vt)
    57103{
     
    60106}
    61107
    62 // Memory organisation
     108//! Select Memory Mapping
     109/*!
     110  Do essentially nothing.
     111  \param mm : type of Memory Mapping (CMemoryMapping,FortranMemoryMapping)
     112  \return return \b mm if it makes sense or default memory mapping value
     113  \sa SetDefaultMemoryMapping
     114 */
    63115short BaseArray::SelectMemoryMapping(short mm)
    64 // si mm == CMemoryMapping, elements d'une ligne suivant X (consecutif)
    65 // sinon (mm == FortranMemoryMapping)  elements d'une colonne suivant X
    66116{
    67117  if ( (mm == CMemoryMapping) || (mm == FortranMemoryMapping) )  return (mm) ;
    68118  else return (default_memory_mapping);
    69119}
     120
     121//! Select Vector type
     122/*!
     123  Do essentially nothing.
     124  \param vt : vector type (ColumnVector,RowVector)
     125  \return return \b vt if it makes sense or default vector type
     126  \sa SetDefaultVectorType
     127 */
    70128short BaseArray::SelectVectorType(short vt)
    71129{
     
    74132}
    75133
     134//! Update Memory Mapping
     135/*!
     136  Update variables marowi_ macoli_ veceli_
     137  \param mm : type of Memory Mapping (CMemoryMapping,FortranMemoryMapping)
     138  \sa SetDefaultMemoryMapping
     139 */
    76140void BaseArray::UpdateMemoryMapping(short mm)
    77141{
     
    94158}
    95159
     160//! Update Memory Mapping
     161/*!
     162  \param a  : Array to be compared with
     163  \param mm : type of Memory Mapping or memory mapping transfert
     164       (SameMemoryMapping,AutoMemoryMapping,CMemoryMapping,FortranMemoryMapping)
     165  \sa SetDefaultMemoryMapping
     166 */
    96167void BaseArray::UpdateMemoryMapping(BaseArray const & a, short mm)
    97168{
     
    119190}
    120191
     192//! Set Memory Mapping type
     193/*!
     194  Compute values for variables marowi_ macoli_ veceli_
     195  \param mm : Memory Mapping type (SameMemoryMapping,AutoMemoryMapping
     196                                  ,CMemoryMapping,FortranMemoryMapping)
     197  \sa SetDefaultMemoryMapping
     198 */
    121199void BaseArray::SetMemoryMapping(short mm)
    122200{
     
    140218}
    141219
     220//! Set Vector Type
     221/*!
     222  Compute values for variable veceli_
     223  \param vt : vector type ()
     224  \sa SetDefaultVectorType
     225 */
    142226void BaseArray::SetVectorType(short vt)
    143227{
     
    184268
    185269
    186 //! Returns true if \b ndim and \b sizes are equal
     270//! Returns true if dimension and sizes are equal
    187271/*!
    188272  \param a : array to be compared
    189   \return true if ndim and sizes are equal, false if not
     273  \return true if ndim and sizes[ndim] are equal, false if not
    190274*/
    191275bool BaseArray::CompareSizes(const BaseArray& a)
     
    201285}
    202286
     287//! Change dimension if some size == 1
    203288void BaseArray::CompactAllDim()
    204289{
     
    223308}
    224309
     310//! Change dimension if some trailed size == 1
    225311void BaseArray::CompactTrailingDim()
    226312{
     
    240326}
    241327
    242 
     328//! return minimum value for step[ndim]
    243329uint_4 BaseArray::MinStepKA() const
    244330{
     
    248334}
    249335
     336//! return maximum value for step[ndim]
    250337uint_4 BaseArray::MaxSizeKA() const
    251338{
     
    262349// Position de l'element 0 du vecteur i selon l'axe ka
    263350// --------------------------------------------------
     351//! return position of first element for vector \b i alond \b ka th axe.
    264352uint_8 BaseArray::Offset(uint_4 ka, uint_8 i) const
    265353{
     
    285373}
    286374
     375//! return position of element \b ip.
    287376uint_8 BaseArray::Offset(uint_8 ip) const
    288377{
     
    317406// ----------------------------------------------------
    318407
     408//! Show infos on stream \b os (\b si to display DvList)
    319409void BaseArray::Show(ostream& os, bool si) const
    320410{
     
    345435}
    346436
     437//! Return BaseArray Type
    347438string BaseArray::InfoString() const
    348439{
     
    352443}
    353444
     445//! Return attached DVList
    354446DVList& BaseArray::Info()
    355447{
     
    358450}
    359451
    360 
     452//! Update sizes and information for array
     453/*!
     454  \param ndim : dimension
     455  \param siz[ndim] : sizes
     456  \param step : step (must be the same on all dimensions)
     457  \param offset : offset of the first element
     458  \return true if all OK, false if problems appear
     459  \return string \b exmsg for explanation in case of problems
     460 */
    361461bool BaseArray::UpdateSizes(uint_4 ndim, const uint_4 * siz, uint_4 step, uint_8 offset, string & exmsg)
    362462{
     
    402502}
    403503
     504//! Update sizes and information for array
     505/*!
     506  \param ndim : dimension
     507  \param siz[ndim] : sizes
     508  \param step[ndim] : steps
     509  \param offset : offset of the first element
     510  \return true if all OK, false if problems appear
     511  \return string \b exmsg for explanation in case of problems
     512 */
    404513bool BaseArray::UpdateSizes(uint_4 ndim, const uint_4 * siz, const uint_4 * step, uint_8 offset, string & exmsg)
    405514{
     
    450559}
    451560
     561//! Update sizes and information relative to array \b a
     562/*!
     563  \param a : array to be compare with
     564  \return true if all OK, false if problems appear
     565  \return string \b exmsg for explanation in case of problems
     566 */
    452567bool BaseArray::UpdateSizes(const BaseArray& a, string & exmsg)
    453568{
     
    492607
    493608
     609//! Update sizes and information relative to array \b a
     610/*!
     611  \param a : array to be compare with
     612  \param ndim : could be change (but should be less than the ndim of the current class)
     613  \param siz[ndim],pos[ndim],step[ndim] : could be changed but must be
     614             compatible within the memory size with those of the current class.
     615  \return true if all OK, false if problems appear
     616  \return string \b exmsg for explanation in case of problems
     617 */
    494618void BaseArray::UpdateSubArraySizes(BaseArray & ra, uint_4 ndim, uint_4 * siz, uint_4 * pos, uint_4 * step) const
    495619{
  • trunk/SophyaLib/TArray/basarr.h

    r890 r894  
    1313
    1414
    15 //! Maximum number of dimensions for an array
     15//! Maximum number of dimensions for an array
     16/*! \anchor BASEARRAY_MAXNDIMS */
    1617#define BASEARRAY_MAXNDIMS  5
    1718
     
    2122//! Base class for template arrays
    2223/*!
    23   Define base methods, enum and defaults for TArray , TMatrix and TVector
     24  No data are connected to this class.
     25
     26  Define base methods, enum and defaults for TArray , TMatrix and TVector.
    2427*/
    2528class BaseArray : public AnyDataObj {
     
    5154  static inline uint_4 GetPrintLevel() { return prt_lev_; }
    5255
    53   //! Set Default Memory Mapping
    5456  static short   SetDefaultMemoryMapping(short mm=CMemoryMapping);
    5557  //! Get Default Memory Mapping
    5658  static inline short GetDefaultMemoryMapping() { return default_memory_mapping; }
    57   //! Set Default Vector Type
    5859  static short   SetDefaultVectorType(short vt=ColumnVector);
    5960  //! Get Default Vector Type
     
    146147  virtual string InfoString() const;
    147148
    148   //  Objet DVList info
    149   DVList&       Info();
     149  // DVList info Object
     150  DVList& Info();
    150151
    151152protected:
     
    166167  virtual void UpdateSubArraySizes(BaseArray & ra, uint_4 ndim, uint_4 * siz, uint_4 * pos, uint_4 * step) const;
    167168
    168   uint_4 ndim_; //! number of dimensions of array
    169   uint_4 size_[BASEARRAY_MAXNDIMS]; //! array of the size in each dimension
    170   uint_8 totsize_; //! Total number of elements
     169  uint_4 ndim_; //!< number of dimensions of array
     170  uint_4 size_[BASEARRAY_MAXNDIMS]; //!< array of the size in each dimension
     171  uint_8 totsize_; //!< Total number of elements
    171172  //! two consecutive elements distance in a given dimension
    172173  uint_4 step_[BASEARRAY_MAXNDIMS];
    173   uint_4 minstep_; //! minimal step (in any axes)
    174   uint_4 moystep_; //! mean step, if == 0 --\> non regular steps
    175   uint_8 offset_;  //! global offset -\> position of elem[0] in DataBlock
    176   uint_4 marowi_; //! For matrices, Row index in dimensions
    177   uint_4 macoli_; //! For matrices, Column index in dimensions
    178   uint_4 veceli_; //! For vectors, dimension index = marowi_/macoli_ (Row/Col vectors)
    179   bool ck_memo_vt_; //! if true, check MemoryOrg./VectorType for CompareSize
    180   DVList* mInfo;    //! Infos (variables) attached to the array
    181 
    182   static char * ck_op_msg_[6]; //! Operation messages for CheckDI() CheckBound()
    183   static uint_4 max_nprt_; //! Nb maximum number of printed elements
    184   static uint_4 prt_lev_;  //! Print level
    185   static short default_memory_mapping; //! Default memory mapping
    186   static short default_vector_type;    //! Default vector type Row/Column
    187   static uint_8 openmp_size_threshold; //! Size limit for parallel routine calls
     174  uint_4 minstep_; //!< minimal step (in any axes)
     175  uint_4 moystep_; //!< mean step, if == 0 --\> non regular steps
     176  uint_8 offset_;  //!< global offset -\> position of elem[0] in DataBlock
     177  uint_4 marowi_; //!< For matrices, Row index in dimensions
     178  uint_4 macoli_; //!< For matrices, Column index in dimensions
     179  uint_4 veceli_; //!< For vectors, dimension index = marowi_/macoli_ (Row/Col vectors)
     180  bool ck_memo_vt_; //!< if true, check MemoryOrg./VectorType for CompareSize
     181  DVList* mInfo;    //!< Infos (variables) attached to the array
     182
     183  static char * ck_op_msg_[6]; //!< Operation messages for CheckDI() CheckBound()
     184  static uint_4 max_nprt_; //!< maximum number of printed elements
     185  static uint_4 prt_lev_;  //!< Print level
     186  static short default_memory_mapping; //!< Default memory mapping
     187  static short default_vector_type;    //!< Default vector type Row/Column
     188  static uint_8 openmp_size_threshold; //!< Size limit for parallel routine calls
    188189};
    189190
  • trunk/SophyaLib/TArray/fioarr.cc

    r818 r894  
    1313///////////////////////////////////////////////////////////
    1414
     15//! Default constructor
    1516template <class T>
    1617FIO_TArray<T>::FIO_TArray()
     
    2021}
    2122
     23
     24//! Constructor from the file \b filename
    2225template <class T>
    2326FIO_TArray<T>::FIO_TArray(string const & filename)
     
    2831}
    2932
     33//! Constructor from the TArray \b obj
    3034template <class T>
    3135FIO_TArray<T>::FIO_TArray(const TArray<T> & obj)
     
    4145}
    4246
     47//! Connect with a TArray \b obj
    4348template <class T>
    4449FIO_TArray<T>::FIO_TArray(TArray<T> * obj)
     
    4853}
    4954
     55//! destructor
    5056template <class T>
    5157FIO_TArray<T>::~FIO_TArray()
     
    5460}
    5561
     62//! Return pointer to the connected TArray
    5663template <class T>
    5764AnyDataObj* FIO_TArray<T>::DataObj()
     
    6067}
    6168
     69//! Connect TArray \b o
    6270template <class T>
    6371void FIO_TArray<T>::SetDataObj(AnyDataObj & o)
  • trunk/SophyaLib/TArray/fioarr.h

    r804 r894  
    1515namespace SOPHYA {
    1616/////////////////////////////////////////////////////////////////////////
    17 // Classe pour la gestion de persistance
     17//! Class for persistent management of TArray
     18/*!
     19  This class manage also persistence for TMatrix and TVector.
     20  \sa TArray TMatrix TVector.
     21 */
    1822template <class T>
    1923class FIO_TArray : public  PPersist  {
     
    3034  virtual void ReadSelf(PInPersist&);           
    3135  virtual void WriteSelf(POutPersist&) const; 
    32   TArray<T> * dobj;
    33   bool ownobj;
     36  TArray<T> * dobj; //!< Pointer to the connected TArray
     37  bool ownobj; //!< true if the connected object belong to the class
    3438};
    3539
     40//! Write TArray \b obj into POutPersist stream \b os
    3641template <class T>
    3742inline POutPersist& operator << (POutPersist& os, TArray<T> & obj)
    3843{ FIO_TArray<T> fio(&obj);  fio.Write(os);  return(os); }
     44
     45//! Read TArray \b obj from PInPersist stream \b os
    3946template <class T>
    4047inline PInPersist& operator >> (PInPersist& is, TArray<T> & obj)
  • trunk/SophyaLib/TArray/matharr.cc

    r882 r894  
    1010// ----------------------------------------------------
    1111
     12
     13//! Apply Function In Place (function double version)
     14/*!
     15  \param a : array to be replaced in place
     16  \param f : function for replacement
     17  \return Return an array \b a filled with function f(a(i,j))
     18*/
    1219template <class T>
    1320TArray<T>& MathArray<T>::ApplyFunctionInPlace(TArray<T> & a, Arr_DoubleFunctionOfX f)
     
    3643}
    3744
     45//! Apply Function In Place (function float version)
     46/*!
     47  \param a : array to be replaced in place
     48  \param f : function for replacement
     49  \return Return an array \b a filled with function f(a(i,j))
     50*/
    3851template <class T>
    3952TArray<T>& MathArray<T>::ApplyFunctionInPlace(TArray<T> & a, Arr_FloatFunctionOfX f)
     
    6376
    6477
     78//! Apply Function (function double version)
     79/*!
     80  \param a : argument array of the function
     81  \param f : function for replacement
     82  \return Return a new array filled with function f(a(i,j))
     83*/
    6584template <class T>
    6685TArray<T> MathArray<T>::ApplyFunction(TArray<T> const & a, Arr_DoubleFunctionOfX f)
     
    7291}
    7392
     93//! Apply Function (function float version)
     94/*!
     95  \param a : argument array of the function
     96  \param f : function for replacement
     97  \return Return a new array filled with function f(a(i,j))
     98*/
    7499template <class T>
    75100TArray<T> MathArray<T>::ApplyFunction(TArray<T> const & a, Arr_FloatFunctionOfX f)
     
    81106}
    82107
     108//! Compute \b mean and \b sigma of elements of array \b a, return \b mean
    83109template <class T>
    84110double MathArray<T>::MeanSigma(TArray<T> const & a, double & mean, double & sig)
  • trunk/SophyaLib/TArray/matharr.h

    r882 r894  
    1212namespace SOPHYA {
    1313
    14 //       Class for simple mathematical operation on arrays
    15 //   Instanciated only for real and double (r_4, r_8) type arrays
    16 //                                                Reza 03/2000
     14//! Class for simple mathematical operation on arrays
     15/*!
     16  \warning Instanciated only for \b real and \b double (r_4, r_8) type arrays
     17*/
    1718template <class T>
    1819class MathArray {
     
    8485#endif
    8586
     87//! Return \b mean and \b sigma of elements of array \b a
    8688template <class T>
    8789inline double MeanSigma(const TArray<T>& a, double & mean, double & sig)
    8890  { MathArray<T> ma;   return( ma.MeanSigma(a, mean, sig) ); }
    8991
     92//! Return \b mean of elements of array \b a
    9093template <class T>
    9194inline double Mean(const TArray<T>& a)
  • 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)
  • trunk/SophyaLib/TArray/tarray.h

    r813 r894  
    2323//  ( See BaseArray class for data organisation in  memory and related methods )
    2424
     25//! Class for template arrays
     26/*!
     27  This class implements arrays of dimensions up to
     28  \ref BASEARRAY_MAXNDIMS "BASEARRAY_MAXNDIMS"
     29*/
    2530template <class T>
    2631class TArray : public BaseArray {
     
    3843
    3944  // A = B : partage les donnees si "a" est temporaire, clone sinon.
     45  //! = operator between TArray
     46  /*! \sa Set */
    4047  inline  TArray<T>& operator = (const TArray<T>& a) { return Set(a); }
    4148  virtual TArray<T>& Set(const TArray<T>& a);
     
    5461
    5562  // 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 */
    5766  inline TArray<T> operator () (Range rx, Range ry, Range rz, Range rt=0, Range ru=0) const
    5867                   { return  SubArray(rx, ry, rz, rt, ru); }
     
    7584  inline T&       ElemCheckBound(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it=0, uint_4 iu=0);
    7685
     86  //! Return pointer to first element adress
    7787  inline        T* Data()       {return mNDBlock.Begin()+offset_;}
     88  //! Return pointer to first element adress
    7889  inline const  T* Data() const {return mNDBlock.Begin()+offset_;}
     90  //! Return reference to datablock NDataBlock
    7991  inline        NDataBlock<T>& DataBlock()       {return mNDBlock;}
     92  //! Return reference to datablock NDataBlock
    8093  inline const  NDataBlock<T>& DataBlock() const {return mNDBlock;}
    8194
    8295  // Temporaire?
     96  //! Are the array temporay ?
    8397  inline bool   IsTemp(void) const {return mNDBlock.IsTemp();}
     98  //! Set the array as temporay
    8499  inline void   SetTemp(bool temp=false) const {mNDBlock.SetTemp(temp);}
    85100
     
    89104// Met les elements a une suite de valeurs
    90105  virtual TArray<T>&  SetSeq(Sequence seq);
     106  //! Fill TArray with Sequence \b seq
    91107  inline  TArray<T>&  operator = (Sequence seq)    { return SetSeq(seq); }
    92108// A = x (tous les elements a x)
    93109  virtual TArray<T>&  SetT(T x);
     110  //! Fill TArray with all elements equal to \b x
    94111  inline  TArray<T>&  operator = (T x)             { return SetT(x); }
    95112// A += -= *= /= x (ajoute, soustrait, ... x a tous les elements)
    96113  virtual TArray<T>&  Add(T x);
     114  //! Add \b x to all elements
    97115  inline  TArray<T>&  operator += (T x)            { return Add(x); }
    98116  virtual TArray<T>&  Sub(T x);
     117  //! Substract \b x to all elements
    99118  inline  TArray<T>&  operator -= (T x)            { return Sub(x); }
    100119  virtual TArray<T>&  Mul(T x);
     120  //! Multiply all elements by \b x
    101121  inline  TArray<T>&  operator *= (T x)            { return Mul(x); }
    102122  virtual TArray<T>&  Div(T x);
     123  //! Divide all elements by \b x
    103124  inline  TArray<T>&  operator /= (T x)            { return Div(x); }
    104125  virtual TArray<T>&  SubInv(T x);  //   A ---> x-A
     
    107128// A += -=  (ajoute, soustrait element par element les deux tableaux )
    108129  virtual TArray<T>&  AddElt(const TArray<T>& a);
     130  //! Operator TArray += TArray
    109131  inline  TArray<T>&  operator += (const TArray<T>& a)  { return AddElt(a); }
    110132  virtual TArray<T>&  SubElt(const TArray<T>& a);
     133  //! Operator TArray -= TArray
    111134  inline  TArray<T>&  operator -= (const TArray<T>& a)  { return SubElt(a); }
    112135// Multiplication, division element par element les deux tableaux
     
    133156  void Share(const TArray<T>& a);
    134157
    135   NDataBlock<T> mNDBlock;      // Le bloc des donnees
     158  NDataBlock<T> mNDBlock; //!< Block for datas
    136159};
    137160
    138161////////////////////////////////////////////////////////////////
    139162//   Surcharge d'operateur <<
     163//! Print TArray \b a on stream \b os
    140164template <class T>
    141165inline ostream& operator << (ostream& os, const TArray<T>& a)
     
    145169// Surcharge d'operateurs A (+,-,*,/) (T) x
    146170
     171//! Operator TArray = TArray + constant
    147172template <class T> inline TArray<T> operator + (const TArray<T>& a, T b)
    148173    {TArray<T> result(a); result.SetTemp(true); result.Add(b); return result;}
    149174
     175//! Operator TArray = constant + TArray
    150176template <class T> inline TArray<T> operator + (T b,const TArray<T>& a)
    151177    {TArray<T> result(a); result.SetTemp(true); result.Add(b); return result;}
    152178
     179//! Operator TArray = TArray - constant
    153180template <class T> inline TArray<T> operator - (const TArray<T>& a, T b)
    154181    {TArray<T> result(a); result.SetTemp(true); result.Sub(b); return result;}
    155182
     183//! Operator TArray = constant - TArray
    156184template <class T> inline TArray<T> operator - (T b,const TArray<T>& a)
    157185    {TArray<T> result(a); result.SetTemp(true); result.SubInv(b); return result;}
    158186
     187//! Operator TArray = TArray * constant
    159188template <class T> inline TArray<T> operator * (const TArray<T>& a, T b)
    160189    {TArray<T> result(a); result.SetTemp(true); result.Mul(b); return result;}
    161190
     191//! Operator TArray = constant * TArray
    162192template <class T> inline TArray<T> operator * (T b,const TArray<T>& a)
    163193    {TArray<T> result(a); result.SetTemp(true); result.Mul(b); return result;}
    164194
     195//! Operator TArray = TArray / constant
    165196template <class T> inline TArray<T> operator / (const TArray<T>& a, T b)
    166197    {TArray<T> result(a); result.SetTemp(true); result.DivInv(b); return result;}
     
    169200// Surcharge d'operateurs C = A (+,-) B
    170201
     202//! Operator TArray = TArray + TArray
    171203template <class T>
    172204inline TArray<T> operator + (const TArray<T>& a,const TArray<T>& b)
    173205    {TArray<T> result(a); result.SetTemp(true); result.AddElt(b); return result;}
    174206
     207//! Operator TArray = TArray - TArray
    175208template <class T>
    176209inline TArray<T> operator - (const TArray<T>& a,const TArray<T>& b)
     
    181214//        inline element acces methods
    182215// --------------------------------------------------
     216
     217//! Return element (ix,iy,iz,it,iu) value
    183218template <class T>
    184219inline T const& TArray<T>::Elem(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) const
     
    189224}
    190225
     226//! Return element (ix,iy,iz,it,iu) value
    191227template <class T>
    192228inline T & TArray<T>::Elem(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu)
     
    197233}
    198234
     235//! Return element (ix,iy,iz,it,iu) value with Check of indexes bound first
    199236template <class T>
    200237inline T const& TArray<T>::ElemCheckBound(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) const
     
    204241}
    205242
     243//! Return element (ix,iy,iz,it,iu) value with Check of indexes bound first
    206244template <class T>
    207245inline T & TArray<T>::ElemCheckBound(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu)
     
    211249}
    212250
     251//! Return element (ix,iy,iz) value
    213252template <class T>
    214253inline T const& TArray<T>::operator()(uint_4 ix, uint_4 iy, uint_4 iz) const
     
    221260}
    222261
     262//! Return element (ix,iy,iz) value
    223263template <class T>
    224264inline T & TArray<T>::operator()(uint_4 ix, uint_4 iy, uint_4 iz)
     
    231271}
    232272
     273//! Operator () : return element (ix,iy,iz,it,iu) value
    233274template <class T>
    234275inline T const& TArray<T>::operator()(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) const
     
    242283}
    243284
     285//! Operator () : return element (ix,iy,iz,it,iu) value
    244286template <class T>
    245287inline T & TArray<T>::operator()(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu)
     
    254296
    255297
     298//! Operator [] : return element at positon ip
    256299template <class T>
    257300inline T const& TArray<T>::operator[](uint_8 ip) const
     
    263306}
    264307
     308//! Operator [] : return element at positon ip
    265309template <class T>
    266310inline T & TArray<T>::operator[](uint_8 ip)
     
    273317
    274318
     319//! Return the value of first element
    275320template <class T>
    276321inline T TArray<T>::toScalar()
     
    281326
    282327// Typedef pour simplifier
     328//! To simplify, Array \<==\> TArray<r_8>
    283329typedef TArray<r_8> Array;
    284330
  • trunk/SophyaLib/TArray/tarrinit.h

    r762 r894  
    1111namespace SOPHYA {
    1212
     13//! Class to initialize the TArray's classes
    1314class TArrayInitiator : public SophyaInitiator {
    1415private:
  • trunk/SophyaLib/TArray/tmatrix.cc

    r850 r894  
    1 // $Id: tmatrix.cc,v 1.5 2000-04-10 12:57:44 ansari Exp $
     1// $Id: tmatrix.cc,v 1.6 2000-04-12 17:42:21 ansari Exp $
    22//                         C.Magneville          04/99
    33#include "machdefs.h"
     
    1212////////////////////////////////////////////////////////////////
    1313//**** Createur, Destructeur
     14//! Default constructor
    1415template <class T>
    1516TMatrix<T>::TMatrix()
     
    2021}
    2122
     23//! constructor of a matrix with  r lines et c columns.
     24/*!
     25  \param r : number of rows
     26  \param c : number of columns
     27  \param mm : define the memory mapping type
     28  \sa ReSize
     29 */
    2230template <class T>
    2331TMatrix<T>::TMatrix(uint_4 r,uint_4 c, short mm)
     
    3038}
    3139
     40//! Constructor by copy (share data if \b a is temporary).
    3241template <class T>
    3342TMatrix<T>::TMatrix(const TMatrix<T>& a)
     
    3746}
    3847
     48//! Constructor by copy
     49/*!
     50  \param share : if true, share data. If false copy data
     51 */
    3952template <class T>
    4053TMatrix<T>::TMatrix(const TMatrix<T>& a, bool share)
     
    4457}
    4558
    46 
     59//! Constructor of a matrix from a TArray \b a
    4760template <class T>
    4861TMatrix<T>::TMatrix(const TArray<T>& a)
     
    5972}
    6073
     74//! Constructor of a matrix from a TArray \b a
     75/*!
     76  \param a : TArray to be copied or shared
     77  \param share : if true, share data. If false copy data
     78  \param mm : define the memory mapping type
     79 */
    6180template <class T>
    6281TMatrix<T>::TMatrix(const TArray<T>& a, bool share, short mm )
     
    7392}
    7493
     94//! Destructor
    7595template <class T>
    7696TMatrix<T>::~TMatrix()
    77 // Destructeur
    78 {
    79 
    80 }
    81 
     97{
     98}
     99
     100//! Set matirx equal to \b a and return *this
    82101template <class T>
    83102TArray<T>& TMatrix<T>::Set(const TArray<T>& a)
     
    95114}
    96115
     116//! Resize the matrix
     117/*!
     118  \param r : number of rows
     119  \param c : number of columns
     120  \param mm : define the memory mapping type
     121         (SameMemoryMapping,CMemoryMapping
     122         ,FortranMemoryMapping,DefaultMemoryMapping)
     123 */
    97124template <class T>
    98125void TMatrix<T>::ReSize(uint_4 r, uint_4 c, short mm)
     
    115142}
    116143
     144//! Re-allocate space for the matrix
     145/*!
     146  \param r : number of rows
     147  \param c : number of columns
     148  \param mm : define the memory mapping type
     149  \param force : if true re-allocation is forced, if not it occurs
     150          only if the required space is greater than the old one.
     151  \sa ReSize
     152 */
    117153template <class T>
    118154void TMatrix<T>::Realloc(uint_4 r,uint_4 c, short mm, bool force)
     
    136172
    137173// $CHECK$ Reza 03/2000  Doit-on declarer cette methode const ?
     174//! Return a submatrix define by \b Range \b rline and \b rcol
    138175template <class T>
    139176TMatrix<T> TMatrix<T>::SubMatrix(Range rline, Range rcol) const
     
    151188////////////////////////////////////////////////////////////////
    152189// Transposition
     190//! Transpose matrix in place
    153191template <class T>
    154192TMatrix<T>& TMatrix<T>::Transpose()
     
    163201
    164202
     203//! Transpose matrix into new matrix
     204/*!
     205  \param mm : define the memory mapping type
     206    (SameMemoryMapping,CMemoryMapping,FortranMemoryMapping)
     207  \return return a new matrix
     208 */
    165209template <class T>
    166210TMatrix<T> TMatrix<T>::Transpose(short mm)
     
    175219}
    176220
    177 // Rearrangement memoire
    178 // Si identique, renvoie une matrice qui partage les donnees
     221//! Rearrange data in memory memoire according to \b mm
     222/*!
     223  \param mm : define the memory mapping type
     224    (SameMemoryMapping,CMemoryMapping,FortranMemoryMapping)
     225  \warning If identical, return a matrix that share the datas
     226 */
    179227template <class T>
    180228TMatrix<T> TMatrix<T>::Rearrange(short mm)
     
    195243}
    196244
     245//! Set the matrix to the identity matrix \b imx
    197246template <class T>
    198247TMatrix<T>& TMatrix<T>::SetIdentity(IdentityMatrix imx)
     
    215264////////////////////////////////////////////////////////////////
    216265//**** Impression
     266//! Return info on number of rows, column and type \b T
    217267template <class T>
    218268string TMatrix<T>::InfoString() const
     
    226276}
    227277
     278//! Print matrix
     279/*!
     280  \param maxprt : maximum numer of print
     281  \param si : if true,  display attached DvList
     282  \sa SetMaxPrint
     283 */
    228284template <class T>
    229285void TMatrix<T>::Print(ostream& os, int_4 maxprt, bool si) const
     
    252308////////////////////////////////////////////////////////////////
    253309
     310//! Return the matrix product C = (*this)*B
     311/*!
     312  \param mm : define the memory mapping type for the return matrix
     313 */
    254314template <class T>
    255315TMatrix<T> TMatrix<T>::Multiply(const TMatrix<T>& b, short mm) const
  • trunk/SophyaLib/TArray/tmatrix.h

    r813 r894  
    88
    99namespace SOPHYA {
     10
     11//! Class of matrixes
     12/*!
     13  \sa TArray
     14 */
    1015
    1116template <class T>
     
    2328  //  Pour verifiez la compatibilite de dimensions lors de l'affectation
    2429  virtual TArray<T>& Set(const TArray<T>& a);
     30  //! Operator = between matrices
    2531  inline  TMatrix<T>& operator = (const TMatrix<T>& a)
    26                        { Set(a);  return(*this); }
     32                     { Set(a);  return(*this); }
    2733
    2834  // Size - Changing the Size
     35  //! return number of rows
    2936  inline uint_4 NRows() const {return Size(marowi_); }
     37  //! return number of columns
    3038  inline uint_4 NCols() const {return Size(macoli_); }
     39  //! return number of columns
    3140  inline uint_4 NCol()  const {return Size(macoli_); } // back-compat Peida
    3241
     
    3645  // Sub-matrix extraction $CHECK$ Reza 03/2000  Doit-on declarer ces methode const ?
    3746  TMatrix<T> SubMatrix(Range rline, Range rcol) const ;
     47  //! () : Return submatrix define by \b Range \b rline and \b rcol
    3848  inline TMatrix<T> operator () (Range rline, Range rcol) const
    3949                    { return SubMatrix(rline, rcol); }
    4050  // Lignes et colonnes de la matrice
     51  //! Return submatrix define by line \b ir (line vector)
    4152  inline TMatrix<T> Row(uint_4 ir) const
    4253                    { return SubMatrix(Range(ir,ir), Range(0,NCols()-1)); }
     54  //! Return submatrix define by column \b ic (column vector)
    4355  inline TMatrix<T> Column(uint_4 ic) const
    4456                    { return SubMatrix(Range(0,NRows()-1), Range(ic,ic)); }
     
    5870  // A = x (matrice diagonale Identite)
    5971  virtual TMatrix<T>& SetIdentity(IdentityMatrix imx);
     72  // = : fill matrix with an identity matrix \b imx
    6073  inline  TMatrix<T>& operator = (IdentityMatrix imx) { return SetIdentity(imx); }
    6174
     75  // = : fill matrix with a Sequence \b seq
    6276  inline  TMatrix<T>&  operator = (Sequence seq)    { SetSeq(seq); return(*this); }
    6377
    6478  // Operations diverses  avec une constante
     79  //! = : fill matrix with constant value \b x
    6580  inline  TMatrix<T>&  operator = (T x)             { SetT(x); return(*this); }
     81  //! += : add constant value \b x to matrix
    6682  inline  TMatrix<T>&  operator += (T x)            { Add(x); return(*this); }
     83  //! -= : substract constant value \b x to matrix
    6784  inline  TMatrix<T>&  operator -= (T x)            { Sub(x); return(*this); }
     85  //! *= : multiply matrix by constant value \b x
    6886  inline  TMatrix<T>&  operator *= (T x)            { Mul(x); return(*this); }
     87  //! /= : divide matrix by constant value \b x
    6988  inline  TMatrix<T>&  operator /= (T x)            { Div(x); return(*this); }
    7089
    7190  //  operations avec matrices
     91  //! += : add a matrix
    7292  inline  TMatrix<T>&  operator += (const TMatrix<T>& a)  { AddElt(a); return(*this); }
     93  //! -= : substract a matrix
    7394  inline  TMatrix<T>&  operator -= (const TMatrix<T>& a)  { SubElt(a); return(*this); }
    74   // Produit matriciel Multiply : C = (*this)*B
    7595  TMatrix<T>  Multiply(const TMatrix<T>& b, short mm=SameMemoryMapping) const;
     96  //! *= : matrix product : C = (*this)*B
    7697  inline  TMatrix<T>&  operator *= (const TMatrix<T>& b)
    7798          { this->Set(Multiply(b));  return(*this); }
     
    85106
    86107//  ---- inline acces methods ------
     108 //! () : return element for line \b r and column \b c
    87109template <class T>
    88110inline T const& TMatrix<T>::operator()(uint_4 r, uint_4 c) const
     
    96118}
    97119
     120//! () : return element for line \b r and column \b c
    98121template <class T>
    99122inline T & TMatrix<T>::operator()(uint_4 r, uint_4 c)
     
    113136// Doit-on le faire aussi pour les constantes ? - Fin de $CHECK$ Reza 3/4/2000
    114137
     138//! + : add matrixes \b a and \b b
    115139template <class T>
    116140inline TMatrix<T> operator + (const TMatrix<T>& a,const TMatrix<T>& b)
    117141    {TMatrix<T> result(a); result.SetTemp(true); result.AddElt(b); return result;}
    118142
     143//! - : substract matrixes \b a and \b b
    119144template <class T>
    120145inline TMatrix<T> operator - (const TMatrix<T>& a,const TMatrix<T>& b)
     
    122147
    123148// Surcharge d'operateurs C = A * B
    124 
     149//! - : multiply matrixes \b a and \b b
    125150template <class T> inline TMatrix<T> operator * (const TMatrix<T>& a, const TMatrix<T>& b)
    126151{ TMatrix<T> result(a); result.SetTemp(true); return(result.Multiply(b)); }
    127152
     153//! Define Matrix to be TMatrix<r_8>
    128154typedef TMatrix<r_8> Matrix;
    129155
  • trunk/SophyaLib/TArray/tvector.cc

    r813 r894  
    1 // $Id: tvector.cc,v 1.3 2000-04-05 15:44:17 ansari Exp $
     1// $Id: tvector.cc,v 1.4 2000-04-12 17:42:30 ansari Exp $
    22//                         C.Magneville          04/99
    33#include "machdefs.h"
     
    99//**** Createur, Destructeur
    1010
     11//! Default constructor
    1112template <class T>
    1213TVector<T>::TVector()
     
    1516}
    1617
     18//! construct a vector
     19/*!
     20  \param n : number of elements
     21  \param lcv : line or column vector ?
     22  \param mm : memory mapping type
     23  \sa SelectVectorType
     24 */
    1725template <class T>
    1826TVector<T>::TVector(uint_4 n, short lcv, short mm)
     
    2432}
    2533
    26 
     34//! Constructor by copy (share if \b a is temporary)
    2735template <class T>
    2836TVector<T>::TVector(const TVector<T>& a)
     
    3240}
    3341
     42//! Constructor by copy
     43/*!
     44  \param share : if true, share data. If false copy data
     45 */
    3446template <class T>
    3547TVector<T>::TVector(const TVector<T>& a, bool share)
     
    3951}
    4052
     53//! Constructor from a TArray
    4154template <class T>
    4255TVector<T>::TVector(const TArray<T>& a)
     
    4861
    4962
     63//! Constructor of a vector from a TArray \b a
     64/*!
     65  \param a : TArray to be copied or shared
     66  \param share : if true, share data. If false copy data
     67  \param mm : define the memory mapping type
     68  \param lcv : line or column vector ?
     69  \sa SelectVectorType
     70 */
    5071template <class T>
    5172TVector<T>::TVector(const TArray<T>& a, bool share, short mm, short lcv )
     
    6182}
    6283
     84//! Destructor
    6385template <class T>
    6486TVector<T>::~TVector()
    65 // Destructeur
    6687{
    67 
    6888}
    6989
     90//! Resize the vector
     91/*!
     92  \param n : number of elements
     93  \param lcv : line or column vector ?
     94  \sa SelectVectorType
     95 */
    7096template <class T>
    7197void TVector<T>::ReSize(uint_4 n, short lcv)
     
    82108}
    83109
     110//! Re-allocate space for the vector
     111/*!
     112  \param n : number of elements
     113  \param lcv : line or column vector ?
     114  \param force : if true re-allocation is forced, if not it occurs
     115          only if the required space is greater than the old one.
     116  \sa ReSize SelectVectorType
     117 */
    84118template <class T>
    85119void TVector<T>::Realloc(uint_4 n, short lcv, bool force)
     
    97131
    98132// $CHECK$ Reza 03/2000  Doit-on declarer cette methode const ?
     133//! Return a subvector define by \b Range \b relt
    99134template <class T>
    100135TVector<T> TVector<T>::SubVector(Range relt) const
     
    109144}
    110145
     146//! Return the norm \f$ \sum{V(i)^2} \f$
    111147template <class T>
    112148T TVector<T>::Norm2() const
     
    117153}
    118154
     155//! Return info on number of rows, column and type \b T
    119156template <class T>
    120157string TVector<T>::InfoString() const
  • trunk/SophyaLib/TArray/tvector.h

    r813 r894  
    88namespace SOPHYA {
    99
     10//! Class of vector (line or column)
     11/*!
     12  \sa TMatrix TArray
     13  */
    1014template <class T>
    1115class TVector : public TMatrix<T> {
     
    2125  virtual ~TVector();
    2226
     27  //! Operator =
    2328  inline  TVector<T>& operator = (const TVector<T>& a)
    2429                       { Set(a);  return(*this); }
     
    3136  // Sub-Vector extraction $CHECK$ Reza 03/2000  Doit-on declarer cette methode const ?
    3237  TVector<T> SubVector(Range relt) const ;
     38  //! Extract a vector define by Range \b relt
    3339  inline TVector<T> operator () (Range relt) const
    3440                    { return SubVector(relt); }
    3541
    3642  // Informations pointeur/data
     43  //! return the number of elements
    3744  inline uint_4 NElts() const {return Size(); }
    3845 
     
    4249
    4350  // Operateur d'affectation
     51  //! Fill the
    4452  inline  TMatrix<T>&  operator = (Sequence seq)    { SetSeq(seq); return(*this); }
    4553
    4654  // Operations diverses  avec une constante
     55  //! Set vector elements to constant value \b x
    4756  inline  TVector<T>&  operator = (T x)             { SetT(x); return(*this); }
     57  //! Add constant value \b x to vector elements
    4858  inline  TVector<T>&  operator += (T x)            { Add(x); return(*this); }
     59  //! Substract constant value \b x to vector elements
    4960  inline  TVector<T>&  operator -= (T x)            { Sub(x); return(*this); }
     61  //! Multiply vector elements by constant value \b x
    5062  inline  TVector<T>&  operator *= (T x)            { Mul(x); return(*this); }
     63  //! Divide vector elements by constant value \b x
    5164  inline  TVector<T>&  operator /= (T x)            { Div(x); return(*this); }
    5265
    5366  //  operations avec matrices
     67  //! += : add a vector in place
    5468  inline  TVector<T>&  operator += (const TVector<T>& a)  { AddElt(a); return(*this); }
     69  //! += : substract a vector in place
    5570  inline  TVector<T>&  operator -= (const TVector<T>& a)  { SubElt(a); return(*this); }
    5671
     
    6378
    6479//  ---- inline acces methods ------
     80
     81//! Return the value of element \b n
    6582template <class T>
    6683inline T const& TVector<T>::operator()(uint_4 n) const
     
    7390}
    7491
     92//! Return the value of element \b n
    7593template <class T>
    7694inline T & TVector<T>::operator()(uint_4 n)
     
    84102
    85103// Typedef pour simplifier et compatibilite Peida
     104//! Define Vector to be TVector<r_8>
    86105typedef TVector<r_8> Vector;
    87106
  • trunk/SophyaLib/TArray/utilarr.cc

    r850 r894  
    88// Classe utilitaires
    99
     10//////////////////////////////////////////////////////////
     11//! Constructor
     12/*!
     13  \param typ : generator type
     14  \param m : mean parameter of the generator (if needed)
     15  \param s : sigma parameter of the generator (if needed)
     16 */
    1017RandomSequence::RandomSequence(int typ, double m, double s)
    1118{
     
    1522}
    1623
     24//! Return random sequence values.
    1725double RandomSequence::Rand()
    1826{
     
    2331
    2432
     33//////////////////////////////////////////////////////////
     34//! Constructor
     35/*!
     36  \param start : start value
     37  \param step : step value
     38  \param f : pointer to the sequence function
     39
     40  See \ref SequenceOperat "operator()"
     41 */
    2542Sequence::Sequence(double start, double step, Arr_DoubleFunctionOfX f)
    2643  : rseq_(RandomSequence::Gaussian)
     
    3249}
    3350
     51//! Constructor
     52/*!
     53  \param rseq : RandomSequence
     54
     55  See \ref SequenceOperat "operator()"
     56 */
    3457Sequence::Sequence(RandomSequence rseq)
    3558{
     
    4164}
    4265
     66//! Get the \b k th value
     67/*!
     68  \param k : index of the value
     69  \anchor SequenceOperat
     70
     71  If the constructor was done with RandomSequence, return a RandomSequence
     72  and \b k doesn't matter.
     73
     74  If the constructor has a NULL Arr_DoubleFunctionOfX, return start+k*step
     75
     76  If the constructor has a not NULL Arr_DoubleFunctionOfX, return f(start+k*step)
     77  \return the \b k th value
     78 */
    4379double Sequence::operator () (uint_4 k)
    4480{
     
    5187}
    5288
     89//////////////////////////////////////////////////////////
     90//! Constructor
     91/*!
     92  Define a range of indexes
     93  \param start : start index
     94  \param end : start end
     95  \param size : size
     96  \param step : step
     97
     98  \warning If \b end \> \b start, \b size is computed automatically
     99  \warning If not \b size is fixed and \b end recomputed
     100 */
    53101Range::Range(uint_4 start, uint_4 end, uint_4 size, uint_4 step)
    54102{
     
    77125
    78126
     127//////////////////////////////////////////////////////////
     128//! Constructor of a (n,n) diagonal matrix with value diag on the diagonal
    79129IdentityMatrix::IdentityMatrix(double diag, uint_4 n)
    80130{
  • trunk/SophyaLib/TArray/utilarr.h

    r850 r894  
    1313/* Quelques utilitaires pour les tableaux (Array) */             
    1414
     15//! define a function of double which returns a double
    1516typedef double (* Arr_DoubleFunctionOfX) (double x);
     17//! define a function of float which returns a float
    1618typedef float  (* Arr_FloatFunctionOfX)  (float x);
    1719
     20//////////////////////////////////////////////////////////
     21//! Class to generate a random sequence of values
    1822class RandomSequence {
    1923public:
    20   enum { Gaussian = 0, Flat = 1 };
     24  //! to define the generator type
     25  enum {
     26    Gaussian = 0, //!< gaussian generator
     27    Flat = 1      //!< Flat generator
     28    };
     29
    2130  RandomSequence(int typ = RandomSequence::Gaussian, double m=0., double s=1.);
    2231  double Rand();
    2332protected:
    24   int typ_;
    25   double mean_, sig_;
     33  int typ_;            //!< random generation type
     34  double mean_, sig_;  //!< generation parameters mean and sigma (if needed)
    2635};
    2736
    2837
     38//////////////////////////////////////////////////////////
     39//! Class to generate a sequence of values
    2940class Sequence {
    3041public:
    3142  explicit Sequence (double start=0., double step=1., Arr_DoubleFunctionOfX f=NULL);
    3243  explicit Sequence (RandomSequence rseq);
     44
     45  //! return start value of the sequence
    3346  inline double & Start() { return start_; }
     47  //! return step value of the sequence
    3448  inline double & Step() { return step_; }
    3549  double operator () (uint_4 k);
    3650protected:
    37   double start_, step_;
    38   Arr_DoubleFunctionOfX myf_;
    39   bool fgrseq_;
    40   RandomSequence rseq_;
     51  double start_;              //!< start value of the sequence
     52  double step_;               //!< step value of the sequence
     53  Arr_DoubleFunctionOfX myf_; //!< pointer to the sequence function
     54  bool fgrseq_;               //!< true if RandomSequence is used
     55  RandomSequence rseq_;       //!< RandomSequence
    4156};
    4257
     58//////////////////////////////////////////////////////////
     59//! Class to define a range of indexes
    4360class Range {
    4461public:
    4562  explicit Range(uint_4 start=0, uint_4 end=0, uint_4 size=1, uint_4 step=1);
     63  //! Return the start index
    4664  inline uint_4 & Start()  {  return start_; }
     65  //! Return the last index
    4766  inline uint_4 & End()    {  return end_; }
     67  //! Return the size
    4868  inline uint_4 & Size()   {  return size_; }
     69  //! Return the step
    4970  inline uint_4 & Step()   {  return step_; }
    5071protected:
    51   uint_4 start_, end_, size_, step_ ;
     72  uint_4 start_; //!< start index
     73  uint_4 end_;   //!< end index
     74  uint_4 size_;  //!< size
     75  uint_4 step_;  //!< step
    5276};
    5377
     78//////////////////////////////////////////////////////////
     79//! Class to define an identity matrix
    5480class IdentityMatrix {
    5581public:
    5682  explicit IdentityMatrix(double diag=1., uint_4 n=0);
     83  //! return the size of the identity matrix
    5784  inline uint_4 Size() { return size_; }
     85  //! return the value of the diagonal elements
    5886  inline double Diag() { return diag_; }
    5987protected:
    60   uint_4 size_;
    61   double diag_;
     88  uint_4 size_; //!< size of the matrix
     89  double diag_; //!< value of the diagonal elements
    6290};
    6391
     
    6593
    6694#endif
    67 
Note: See TracChangeset for help on using the changeset viewer.