Changeset 894 in Sophya for trunk/SophyaLib/TArray
- Timestamp:
- Apr 12, 2000, 7:42:33 PM (25 years ago)
- Location:
- trunk/SophyaLib/TArray
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/TArray/basarr.cc
r890 r894 9 9 10 10 // Variables statiques globales 11 char * BaseArray::ck_op_msg_[6] = {"???", "Size(int )", "IsPacked(int )", 12 "Stride(int )", "ElemCheckBound()", "operator()" }; 11 char * BaseArray::ck_op_msg_[6] = 12 {"???", "Size(int )", "IsPacked(int )" 13 ,"Stride(int )", "ElemCheckBound()", "operator()" }; 13 14 uint_4 BaseArray::max_nprt_ = 50; 14 15 uint_4 BaseArray::prt_lev_ = 0; … … 19 20 // ------ Methodes statiques globales -------- 20 21 21 // 1/ Gestion des impressions22 22 //! Set maximum number of printed elements and print level 23 23 /*! … … 41 41 42 42 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 */ 43 51 uint_8 BaseArray::ComputeTotalSize(uint_4 ndim, const uint_4 * siz, uint_4 step, uint_8 offset) 44 52 { … … 48 56 } 49 57 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 */ 50 91 short BaseArray::SetDefaultMemoryMapping(short mm) 51 92 { … … 54 95 } 55 96 97 //! Set Default Vector Type 98 /*! 99 \param vt : vector type (ColumnVector,RowVector) 100 \return default vector type value 101 */ 56 102 short BaseArray::SetDefaultVectorType(short vt) 57 103 { … … 60 106 } 61 107 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 */ 63 115 short BaseArray::SelectMemoryMapping(short mm) 64 // si mm == CMemoryMapping, elements d'une ligne suivant X (consecutif)65 // sinon (mm == FortranMemoryMapping) elements d'une colonne suivant X66 116 { 67 117 if ( (mm == CMemoryMapping) || (mm == FortranMemoryMapping) ) return (mm) ; 68 118 else return (default_memory_mapping); 69 119 } 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 */ 70 128 short BaseArray::SelectVectorType(short vt) 71 129 { … … 74 132 } 75 133 134 //! Update Memory Mapping 135 /*! 136 Update variables marowi_ macoli_ veceli_ 137 \param mm : type of Memory Mapping (CMemoryMapping,FortranMemoryMapping) 138 \sa SetDefaultMemoryMapping 139 */ 76 140 void BaseArray::UpdateMemoryMapping(short mm) 77 141 { … … 94 158 } 95 159 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 */ 96 167 void BaseArray::UpdateMemoryMapping(BaseArray const & a, short mm) 97 168 { … … 119 190 } 120 191 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 */ 121 199 void BaseArray::SetMemoryMapping(short mm) 122 200 { … … 140 218 } 141 219 220 //! Set Vector Type 221 /*! 222 Compute values for variable veceli_ 223 \param vt : vector type () 224 \sa SetDefaultVectorType 225 */ 142 226 void BaseArray::SetVectorType(short vt) 143 227 { … … 184 268 185 269 186 //! Returns true if \b ndim and \bsizes are equal270 //! Returns true if dimension and sizes are equal 187 271 /*! 188 272 \param a : array to be compared 189 \return true if ndim and sizes are equal, false if not273 \return true if ndim and sizes[ndim] are equal, false if not 190 274 */ 191 275 bool BaseArray::CompareSizes(const BaseArray& a) … … 201 285 } 202 286 287 //! Change dimension if some size == 1 203 288 void BaseArray::CompactAllDim() 204 289 { … … 223 308 } 224 309 310 //! Change dimension if some trailed size == 1 225 311 void BaseArray::CompactTrailingDim() 226 312 { … … 240 326 } 241 327 242 328 //! return minimum value for step[ndim] 243 329 uint_4 BaseArray::MinStepKA() const 244 330 { … … 248 334 } 249 335 336 //! return maximum value for step[ndim] 250 337 uint_4 BaseArray::MaxSizeKA() const 251 338 { … … 262 349 // Position de l'element 0 du vecteur i selon l'axe ka 263 350 // -------------------------------------------------- 351 //! return position of first element for vector \b i alond \b ka th axe. 264 352 uint_8 BaseArray::Offset(uint_4 ka, uint_8 i) const 265 353 { … … 285 373 } 286 374 375 //! return position of element \b ip. 287 376 uint_8 BaseArray::Offset(uint_8 ip) const 288 377 { … … 317 406 // ---------------------------------------------------- 318 407 408 //! Show infos on stream \b os (\b si to display DvList) 319 409 void BaseArray::Show(ostream& os, bool si) const 320 410 { … … 345 435 } 346 436 437 //! Return BaseArray Type 347 438 string BaseArray::InfoString() const 348 439 { … … 352 443 } 353 444 445 //! Return attached DVList 354 446 DVList& BaseArray::Info() 355 447 { … … 358 450 } 359 451 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 */ 361 461 bool BaseArray::UpdateSizes(uint_4 ndim, const uint_4 * siz, uint_4 step, uint_8 offset, string & exmsg) 362 462 { … … 402 502 } 403 503 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 */ 404 513 bool BaseArray::UpdateSizes(uint_4 ndim, const uint_4 * siz, const uint_4 * step, uint_8 offset, string & exmsg) 405 514 { … … 450 559 } 451 560 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 */ 452 567 bool BaseArray::UpdateSizes(const BaseArray& a, string & exmsg) 453 568 { … … 492 607 493 608 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 */ 494 618 void BaseArray::UpdateSubArraySizes(BaseArray & ra, uint_4 ndim, uint_4 * siz, uint_4 * pos, uint_4 * step) const 495 619 { -
trunk/SophyaLib/TArray/basarr.h
r890 r894 13 13 14 14 15 //! Maximum number of dimensions for an array 15 //! Maximum number of dimensions for an array 16 /*! \anchor BASEARRAY_MAXNDIMS */ 16 17 #define BASEARRAY_MAXNDIMS 5 17 18 … … 21 22 //! Base class for template arrays 22 23 /*! 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. 24 27 */ 25 28 class BaseArray : public AnyDataObj { … … 51 54 static inline uint_4 GetPrintLevel() { return prt_lev_; } 52 55 53 //! Set Default Memory Mapping54 56 static short SetDefaultMemoryMapping(short mm=CMemoryMapping); 55 57 //! Get Default Memory Mapping 56 58 static inline short GetDefaultMemoryMapping() { return default_memory_mapping; } 57 //! Set Default Vector Type58 59 static short SetDefaultVectorType(short vt=ColumnVector); 59 60 //! Get Default Vector Type … … 146 147 virtual string InfoString() const; 147 148 148 // Objet DVList info149 DVList& 149 // DVList info Object 150 DVList& Info(); 150 151 151 152 protected: … … 166 167 virtual void UpdateSubArraySizes(BaseArray & ra, uint_4 ndim, uint_4 * siz, uint_4 * pos, uint_4 * step) const; 167 168 168 uint_4 ndim_; //! number of dimensions of array169 uint_4 size_[BASEARRAY_MAXNDIMS]; //! array of the size in each dimension170 uint_8 totsize_; //! Total number of elements169 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 171 172 //! two consecutive elements distance in a given dimension 172 173 uint_4 step_[BASEARRAY_MAXNDIMS]; 173 uint_4 minstep_; //! minimal step (in any axes)174 uint_4 moystep_; //! mean step, if == 0 --\> non regular steps175 uint_8 offset_; //! global offset -\> position of elem[0] in DataBlock176 uint_4 marowi_; //! For matrices, Row index in dimensions177 uint_4 macoli_; //! For matrices, Column index in dimensions178 uint_4 veceli_; //! For vectors, dimension index = marowi_/macoli_ (Row/Col vectors)179 bool ck_memo_vt_; //! if true, check MemoryOrg./VectorType for CompareSize180 DVList* mInfo; //! Infos (variables) attached to the array181 182 static char * ck_op_msg_[6]; //! Operation messages for CheckDI() CheckBound()183 static uint_4 max_nprt_; //! Nbmaximum number of printed elements184 static uint_4 prt_lev_; //! Print level185 static short default_memory_mapping; //! Default memory mapping186 static short default_vector_type; //! Default vector type Row/Column187 static uint_8 openmp_size_threshold; //! Size limit for parallel routine calls174 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 188 189 }; 189 190 -
trunk/SophyaLib/TArray/fioarr.cc
r818 r894 13 13 /////////////////////////////////////////////////////////// 14 14 15 //! Default constructor 15 16 template <class T> 16 17 FIO_TArray<T>::FIO_TArray() … … 20 21 } 21 22 23 24 //! Constructor from the file \b filename 22 25 template <class T> 23 26 FIO_TArray<T>::FIO_TArray(string const & filename) … … 28 31 } 29 32 33 //! Constructor from the TArray \b obj 30 34 template <class T> 31 35 FIO_TArray<T>::FIO_TArray(const TArray<T> & obj) … … 41 45 } 42 46 47 //! Connect with a TArray \b obj 43 48 template <class T> 44 49 FIO_TArray<T>::FIO_TArray(TArray<T> * obj) … … 48 53 } 49 54 55 //! destructor 50 56 template <class T> 51 57 FIO_TArray<T>::~FIO_TArray() … … 54 60 } 55 61 62 //! Return pointer to the connected TArray 56 63 template <class T> 57 64 AnyDataObj* FIO_TArray<T>::DataObj() … … 60 67 } 61 68 69 //! Connect TArray \b o 62 70 template <class T> 63 71 void FIO_TArray<T>::SetDataObj(AnyDataObj & o) -
trunk/SophyaLib/TArray/fioarr.h
r804 r894 15 15 namespace SOPHYA { 16 16 ///////////////////////////////////////////////////////////////////////// 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 */ 18 22 template <class T> 19 23 class FIO_TArray : public PPersist { … … 30 34 virtual void ReadSelf(PInPersist&); 31 35 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 34 38 }; 35 39 40 //! Write TArray \b obj into POutPersist stream \b os 36 41 template <class T> 37 42 inline POutPersist& operator << (POutPersist& os, TArray<T> & obj) 38 43 { FIO_TArray<T> fio(&obj); fio.Write(os); return(os); } 44 45 //! Read TArray \b obj from PInPersist stream \b os 39 46 template <class T> 40 47 inline PInPersist& operator >> (PInPersist& is, TArray<T> & obj) -
trunk/SophyaLib/TArray/matharr.cc
r882 r894 10 10 // ---------------------------------------------------- 11 11 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 */ 12 19 template <class T> 13 20 TArray<T>& MathArray<T>::ApplyFunctionInPlace(TArray<T> & a, Arr_DoubleFunctionOfX f) … … 36 43 } 37 44 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 */ 38 51 template <class T> 39 52 TArray<T>& MathArray<T>::ApplyFunctionInPlace(TArray<T> & a, Arr_FloatFunctionOfX f) … … 63 76 64 77 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 */ 65 84 template <class T> 66 85 TArray<T> MathArray<T>::ApplyFunction(TArray<T> const & a, Arr_DoubleFunctionOfX f) … … 72 91 } 73 92 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 */ 74 99 template <class T> 75 100 TArray<T> MathArray<T>::ApplyFunction(TArray<T> const & a, Arr_FloatFunctionOfX f) … … 81 106 } 82 107 108 //! Compute \b mean and \b sigma of elements of array \b a, return \b mean 83 109 template <class T> 84 110 double MathArray<T>::MeanSigma(TArray<T> const & a, double & mean, double & sig) -
trunk/SophyaLib/TArray/matharr.h
r882 r894 12 12 namespace SOPHYA { 13 13 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 */ 17 18 template <class T> 18 19 class MathArray { … … 84 85 #endif 85 86 87 //! Return \b mean and \b sigma of elements of array \b a 86 88 template <class T> 87 89 inline double MeanSigma(const TArray<T>& a, double & mean, double & sig) 88 90 { MathArray<T> ma; return( ma.MeanSigma(a, mean, sig) ); } 89 91 92 //! Return \b mean of elements of array \b a 90 93 template <class T> 91 94 inline double Mean(const TArray<T>& a) -
trunk/SophyaLib/TArray/tarray.cc
r850 r894 15 15 // ------------------------------------------------------- 16 16 17 // Les constructeurs 17 ////////////////////////// Les constructeurs / destructeurs 18 19 //! Default constructor 18 20 template <class T> 19 21 TArray<T>::TArray() 20 22 : 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 */ 25 33 template <class T> 26 34 TArray<T>::TArray(uint_4 ndim, const uint_4 * siz, uint_4 step) … … 31 39 } 32 40 41 //! Constructor 42 /*! 43 \param nx,ny,nz,nt,nu : sizes along first, second, third, fourth and fifth dimension 44 */ 33 45 template <class T> 34 46 TArray<T>::TArray(uint_4 nx, uint_4 ny, uint_4 nz, uint_4 nt, uint_4 nu) … … 48 60 } 49 61 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 */ 50 71 template <class T> 51 72 TArray<T>::TArray(uint_4 ndim, const uint_4 * siz, NDataBlock<T> & db, bool share, uint_4 step, uint_8 offset) … … 57 78 } 58 79 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 */ 59 91 template <class T> 60 92 TArray<T>::TArray(uint_4 ndim, const uint_4 * siz, T* values, uint_4 step, uint_8 offset, Bridge* br) … … 65 97 } 66 98 99 //! Constructor by copy 67 100 template <class T> 68 101 TArray<T>::TArray(const TArray<T>& a) … … 74 107 } 75 108 109 //! Constructor by copy 110 /*! 111 \param share : if true, data are shared, if false they are copied 112 */ 76 113 template <class T> 77 114 TArray<T>::TArray(const TArray<T>& a, bool share) … … 83 120 } 84 121 85 // Destructeur122 //! Destructor 86 123 template <class T> 87 124 TArray<T>::~TArray() … … 89 126 } 90 127 128 ////////////////////////// Les methodes de copie/share 129 130 //! Set array equal to \b a and return *this 91 131 template <class T> 92 132 TArray<T>& TArray<T>::Set(const TArray<T>& a) … … 94 134 if (this != &a) { 95 135 CloneOrShare(a); 96 if (mInfo) delete mInfo;136 if (mInfo) {delete mInfo; mInfo = NULL;} 97 137 if (a.mInfo) mInfo = new DVList(*(a.mInfo)); 98 138 } … … 100 140 } 101 141 142 //! Clone array \b a 102 143 template <class T> 103 144 void TArray<T>::Clone(const TArray<T>& a) … … 106 147 if (!UpdateSizes(a, exmsg)) throw( ParmError(exmsg) ); 107 148 mNDBlock.Clone(a.mNDBlock); 108 if (mInfo) delete mInfo;149 if (mInfo) {delete mInfo; mInfo = NULL;} 109 150 if (a.mInfo) mInfo = new DVList(*(a.mInfo)); 110 151 } 111 152 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 */ 112 159 template <class T> 113 160 void TArray<T>::ReSize(uint_4 ndim, uint_4 * siz, uint_4 step) … … 118 165 } 119 166 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 */ 120 175 template <class T> 121 176 void TArray<T>::Realloc(uint_4 ndim, uint_4 * siz, uint_4 step, bool force) … … 127 182 128 183 184 //! Compact dimensions in one or more is equal to 1. 129 185 template <class T> 130 186 TArray<T>& TArray<T>::CompactAllDimensions() … … 134 190 } 135 191 192 //! Compact dimensions if the last one is equal to 1. 136 193 template <class T> 137 194 TArray<T>& TArray<T>::CompactTrailingDimensions() … … 141 198 } 142 199 200 //! Give value (in \b double) for element at position \b ip.. 143 201 template <class T> 144 202 double TArray<T>::ValueAtPosition(uint_8 ip) const … … 150 208 } 151 209 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 */ 153 214 double TArray< complex<r_4> >::ValueAtPosition(uint_8 ip) const 154 215 { … … 162 223 } 163 224 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 */ 164 229 double TArray< complex<r_8> >::ValueAtPosition(uint_8 ip) const 165 230 { … … 173 238 } 174 239 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 */ 176 247 template <class T> 177 248 TArray<T> TArray<T>::PackElements(bool force) const … … 194 265 // SubArrays 195 266 // $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 */ 196 272 template <class T> 197 273 TArray<T> TArray<T>::SubArray(Range rx, Range ry, Range rz, Range rt, Range ru) const … … 232 308 // ------- Attention -------- 233 309 // 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 */ 235 317 template <class T> 236 318 TArray<T>& TArray<T>::SetSeq(Sequence seq) … … 261 343 // >>>> Operations avec 2nd membre de type scalaire 262 344 345 //! Fill an array with a constant value \b x 263 346 template <class T> 264 347 TArray<T>& TArray<T>::SetT(T x) … … 287 370 } 288 371 372 //! Add a constant value \b x to an array 289 373 template <class T> 290 374 TArray<T>& TArray<T>::Add(T x) … … 313 397 } 314 398 399 //! Substract a constant value \b x to an array 315 400 template <class T> 316 401 TArray<T>& TArray<T>::Sub(T x) … … 339 424 } 340 425 426 //! Multiply an array by a constant value \b x 341 427 template <class T> 342 428 TArray<T>& TArray<T>::Mul(T x) … … 365 451 } 366 452 453 //! Divide an array by a constant value \b x 367 454 template <class T> 368 455 TArray<T>& TArray<T>::Div(T x) … … 370 457 if (NbDimensions() < 1) 371 458 throw RangeCheckError("TArray<T>::Div(T ) - Not Allocated Array ! "); 459 if (x == (T) 0 ) 460 throw MathExc("TArray<T>::Div(T ) - Divide by zero ! "); 372 461 T * pe; 373 462 uint_8 j,k; … … 392 481 393 482 483 //! Inverse substract : A = \b x - A 394 484 template <class T> 395 485 TArray<T>& TArray<T>::SubInv(T x) … … 418 508 } 419 509 510 //! Inverse Divide : A(i,j,...) = x / A(i,j,...) 420 511 template <class T> 421 512 TArray<T>& TArray<T>::DivInv(T x) … … 446 537 447 538 // >>>> Operations avec 2nd membre de type tableau 539 //! Add two TArrays 448 540 template <class T> 449 541 TArray<T>& TArray<T>::AddElt(const TArray<T>& a) … … 480 572 } 481 573 574 //! Substract two TArrays 482 575 template <class T> 483 576 TArray<T>& TArray<T>::SubElt(const TArray<T>& a) … … 514 607 } 515 608 516 609 //! Multiply two TArrays (elements by elements) 517 610 template <class T> 518 611 TArray<T>& TArray<T>::MulElt(const TArray<T>& a) … … 550 643 551 644 645 //! Divide two TArrays (elements by elements) 552 646 template <class T> 553 647 TArray<T>& TArray<T>::DivElt(const TArray<T>& a) … … 584 678 } 585 679 680 //! Copy elements of \b a 586 681 template <class T> 587 682 TArray<T>& TArray<T>::CopyElt(const TArray<T>& a) … … 620 715 621 716 // Somme et produit des elements 717 //! Sum all elements 622 718 template <class T> 623 719 T TArray<T>::Sum() const … … 647 743 } 648 744 745 //! Multiply all elements 649 746 template <class T> 650 747 T TArray<T>::Product() const … … 680 777 // ---------------------------------------------------- 681 778 779 //! Return a string that contain the type \b T of the array 682 780 template <class T> 683 781 string TArray<T>::InfoString() const … … 689 787 } 690 788 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 */ 691 796 template <class T> 692 797 void TArray<T>::Print(ostream& os, int_4 maxprt, bool si) const … … 720 825 } 721 826 722 827 //! Clone if \b a is not temporary, share if temporary 723 828 template <class T> 724 829 void TArray<T>::CloneOrShare(const TArray<T>& a) … … 729 834 } 730 835 836 //! Share data with a 731 837 template <class T> 732 838 void TArray<T>::Share(const TArray<T>& a) -
trunk/SophyaLib/TArray/tarray.h
r813 r894 23 23 // ( See BaseArray class for data organisation in memory and related methods ) 24 24 25 //! Class for template arrays 26 /*! 27 This class implements arrays of dimensions up to 28 \ref BASEARRAY_MAXNDIMS "BASEARRAY_MAXNDIMS" 29 */ 25 30 template <class T> 26 31 class TArray : public BaseArray { … … 38 43 39 44 // A = B : partage les donnees si "a" est temporaire, clone sinon. 45 //! = operator between TArray 46 /*! \sa Set */ 40 47 inline TArray<T>& operator = (const TArray<T>& a) { return Set(a); } 41 48 virtual TArray<T>& Set(const TArray<T>& a); … … 54 61 55 62 // 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 */ 57 66 inline TArray<T> operator () (Range rx, Range ry, Range rz, Range rt=0, Range ru=0) const 58 67 { return SubArray(rx, ry, rz, rt, ru); } … … 75 84 inline T& ElemCheckBound(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it=0, uint_4 iu=0); 76 85 86 //! Return pointer to first element adress 77 87 inline T* Data() {return mNDBlock.Begin()+offset_;} 88 //! Return pointer to first element adress 78 89 inline const T* Data() const {return mNDBlock.Begin()+offset_;} 90 //! Return reference to datablock NDataBlock 79 91 inline NDataBlock<T>& DataBlock() {return mNDBlock;} 92 //! Return reference to datablock NDataBlock 80 93 inline const NDataBlock<T>& DataBlock() const {return mNDBlock;} 81 94 82 95 // Temporaire? 96 //! Are the array temporay ? 83 97 inline bool IsTemp(void) const {return mNDBlock.IsTemp();} 98 //! Set the array as temporay 84 99 inline void SetTemp(bool temp=false) const {mNDBlock.SetTemp(temp);} 85 100 … … 89 104 // Met les elements a une suite de valeurs 90 105 virtual TArray<T>& SetSeq(Sequence seq); 106 //! Fill TArray with Sequence \b seq 91 107 inline TArray<T>& operator = (Sequence seq) { return SetSeq(seq); } 92 108 // A = x (tous les elements a x) 93 109 virtual TArray<T>& SetT(T x); 110 //! Fill TArray with all elements equal to \b x 94 111 inline TArray<T>& operator = (T x) { return SetT(x); } 95 112 // A += -= *= /= x (ajoute, soustrait, ... x a tous les elements) 96 113 virtual TArray<T>& Add(T x); 114 //! Add \b x to all elements 97 115 inline TArray<T>& operator += (T x) { return Add(x); } 98 116 virtual TArray<T>& Sub(T x); 117 //! Substract \b x to all elements 99 118 inline TArray<T>& operator -= (T x) { return Sub(x); } 100 119 virtual TArray<T>& Mul(T x); 120 //! Multiply all elements by \b x 101 121 inline TArray<T>& operator *= (T x) { return Mul(x); } 102 122 virtual TArray<T>& Div(T x); 123 //! Divide all elements by \b x 103 124 inline TArray<T>& operator /= (T x) { return Div(x); } 104 125 virtual TArray<T>& SubInv(T x); // A ---> x-A … … 107 128 // A += -= (ajoute, soustrait element par element les deux tableaux ) 108 129 virtual TArray<T>& AddElt(const TArray<T>& a); 130 //! Operator TArray += TArray 109 131 inline TArray<T>& operator += (const TArray<T>& a) { return AddElt(a); } 110 132 virtual TArray<T>& SubElt(const TArray<T>& a); 133 //! Operator TArray -= TArray 111 134 inline TArray<T>& operator -= (const TArray<T>& a) { return SubElt(a); } 112 135 // Multiplication, division element par element les deux tableaux … … 133 156 void Share(const TArray<T>& a); 134 157 135 NDataBlock<T> mNDBlock; // Le bloc des donnees158 NDataBlock<T> mNDBlock; //!< Block for datas 136 159 }; 137 160 138 161 //////////////////////////////////////////////////////////////// 139 162 // Surcharge d'operateur << 163 //! Print TArray \b a on stream \b os 140 164 template <class T> 141 165 inline ostream& operator << (ostream& os, const TArray<T>& a) … … 145 169 // Surcharge d'operateurs A (+,-,*,/) (T) x 146 170 171 //! Operator TArray = TArray + constant 147 172 template <class T> inline TArray<T> operator + (const TArray<T>& a, T b) 148 173 {TArray<T> result(a); result.SetTemp(true); result.Add(b); return result;} 149 174 175 //! Operator TArray = constant + TArray 150 176 template <class T> inline TArray<T> operator + (T b,const TArray<T>& a) 151 177 {TArray<T> result(a); result.SetTemp(true); result.Add(b); return result;} 152 178 179 //! Operator TArray = TArray - constant 153 180 template <class T> inline TArray<T> operator - (const TArray<T>& a, T b) 154 181 {TArray<T> result(a); result.SetTemp(true); result.Sub(b); return result;} 155 182 183 //! Operator TArray = constant - TArray 156 184 template <class T> inline TArray<T> operator - (T b,const TArray<T>& a) 157 185 {TArray<T> result(a); result.SetTemp(true); result.SubInv(b); return result;} 158 186 187 //! Operator TArray = TArray * constant 159 188 template <class T> inline TArray<T> operator * (const TArray<T>& a, T b) 160 189 {TArray<T> result(a); result.SetTemp(true); result.Mul(b); return result;} 161 190 191 //! Operator TArray = constant * TArray 162 192 template <class T> inline TArray<T> operator * (T b,const TArray<T>& a) 163 193 {TArray<T> result(a); result.SetTemp(true); result.Mul(b); return result;} 164 194 195 //! Operator TArray = TArray / constant 165 196 template <class T> inline TArray<T> operator / (const TArray<T>& a, T b) 166 197 {TArray<T> result(a); result.SetTemp(true); result.DivInv(b); return result;} … … 169 200 // Surcharge d'operateurs C = A (+,-) B 170 201 202 //! Operator TArray = TArray + TArray 171 203 template <class T> 172 204 inline TArray<T> operator + (const TArray<T>& a,const TArray<T>& b) 173 205 {TArray<T> result(a); result.SetTemp(true); result.AddElt(b); return result;} 174 206 207 //! Operator TArray = TArray - TArray 175 208 template <class T> 176 209 inline TArray<T> operator - (const TArray<T>& a,const TArray<T>& b) … … 181 214 // inline element acces methods 182 215 // -------------------------------------------------- 216 217 //! Return element (ix,iy,iz,it,iu) value 183 218 template <class T> 184 219 inline T const& TArray<T>::Elem(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) const … … 189 224 } 190 225 226 //! Return element (ix,iy,iz,it,iu) value 191 227 template <class T> 192 228 inline T & TArray<T>::Elem(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) … … 197 233 } 198 234 235 //! Return element (ix,iy,iz,it,iu) value with Check of indexes bound first 199 236 template <class T> 200 237 inline T const& TArray<T>::ElemCheckBound(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) const … … 204 241 } 205 242 243 //! Return element (ix,iy,iz,it,iu) value with Check of indexes bound first 206 244 template <class T> 207 245 inline T & TArray<T>::ElemCheckBound(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) … … 211 249 } 212 250 251 //! Return element (ix,iy,iz) value 213 252 template <class T> 214 253 inline T const& TArray<T>::operator()(uint_4 ix, uint_4 iy, uint_4 iz) const … … 221 260 } 222 261 262 //! Return element (ix,iy,iz) value 223 263 template <class T> 224 264 inline T & TArray<T>::operator()(uint_4 ix, uint_4 iy, uint_4 iz) … … 231 271 } 232 272 273 //! Operator () : return element (ix,iy,iz,it,iu) value 233 274 template <class T> 234 275 inline T const& TArray<T>::operator()(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) const … … 242 283 } 243 284 285 //! Operator () : return element (ix,iy,iz,it,iu) value 244 286 template <class T> 245 287 inline T & TArray<T>::operator()(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) … … 254 296 255 297 298 //! Operator [] : return element at positon ip 256 299 template <class T> 257 300 inline T const& TArray<T>::operator[](uint_8 ip) const … … 263 306 } 264 307 308 //! Operator [] : return element at positon ip 265 309 template <class T> 266 310 inline T & TArray<T>::operator[](uint_8 ip) … … 273 317 274 318 319 //! Return the value of first element 275 320 template <class T> 276 321 inline T TArray<T>::toScalar() … … 281 326 282 327 // Typedef pour simplifier 328 //! To simplify, Array \<==\> TArray<r_8> 283 329 typedef TArray<r_8> Array; 284 330 -
trunk/SophyaLib/TArray/tarrinit.h
r762 r894 11 11 namespace SOPHYA { 12 12 13 //! Class to initialize the TArray's classes 13 14 class TArrayInitiator : public SophyaInitiator { 14 15 private: -
trunk/SophyaLib/TArray/tmatrix.cc
r850 r894 1 // $Id: tmatrix.cc,v 1. 5 2000-04-10 12:57:44ansari Exp $1 // $Id: tmatrix.cc,v 1.6 2000-04-12 17:42:21 ansari Exp $ 2 2 // C.Magneville 04/99 3 3 #include "machdefs.h" … … 12 12 //////////////////////////////////////////////////////////////// 13 13 //**** Createur, Destructeur 14 //! Default constructor 14 15 template <class T> 15 16 TMatrix<T>::TMatrix() … … 20 21 } 21 22 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 */ 22 30 template <class T> 23 31 TMatrix<T>::TMatrix(uint_4 r,uint_4 c, short mm) … … 30 38 } 31 39 40 //! Constructor by copy (share data if \b a is temporary). 32 41 template <class T> 33 42 TMatrix<T>::TMatrix(const TMatrix<T>& a) … … 37 46 } 38 47 48 //! Constructor by copy 49 /*! 50 \param share : if true, share data. If false copy data 51 */ 39 52 template <class T> 40 53 TMatrix<T>::TMatrix(const TMatrix<T>& a, bool share) … … 44 57 } 45 58 46 59 //! Constructor of a matrix from a TArray \b a 47 60 template <class T> 48 61 TMatrix<T>::TMatrix(const TArray<T>& a) … … 59 72 } 60 73 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 */ 61 80 template <class T> 62 81 TMatrix<T>::TMatrix(const TArray<T>& a, bool share, short mm ) … … 73 92 } 74 93 94 //! Destructor 75 95 template <class T> 76 96 TMatrix<T>::~TMatrix() 77 // Destructeur 78 { 79 80 } 81 97 { 98 } 99 100 //! Set matirx equal to \b a and return *this 82 101 template <class T> 83 102 TArray<T>& TMatrix<T>::Set(const TArray<T>& a) … … 95 114 } 96 115 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 */ 97 124 template <class T> 98 125 void TMatrix<T>::ReSize(uint_4 r, uint_4 c, short mm) … … 115 142 } 116 143 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 */ 117 153 template <class T> 118 154 void TMatrix<T>::Realloc(uint_4 r,uint_4 c, short mm, bool force) … … 136 172 137 173 // $CHECK$ Reza 03/2000 Doit-on declarer cette methode const ? 174 //! Return a submatrix define by \b Range \b rline and \b rcol 138 175 template <class T> 139 176 TMatrix<T> TMatrix<T>::SubMatrix(Range rline, Range rcol) const … … 151 188 //////////////////////////////////////////////////////////////// 152 189 // Transposition 190 //! Transpose matrix in place 153 191 template <class T> 154 192 TMatrix<T>& TMatrix<T>::Transpose() … … 163 201 164 202 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 */ 165 209 template <class T> 166 210 TMatrix<T> TMatrix<T>::Transpose(short mm) … … 175 219 } 176 220 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 */ 179 227 template <class T> 180 228 TMatrix<T> TMatrix<T>::Rearrange(short mm) … … 195 243 } 196 244 245 //! Set the matrix to the identity matrix \b imx 197 246 template <class T> 198 247 TMatrix<T>& TMatrix<T>::SetIdentity(IdentityMatrix imx) … … 215 264 //////////////////////////////////////////////////////////////// 216 265 //**** Impression 266 //! Return info on number of rows, column and type \b T 217 267 template <class T> 218 268 string TMatrix<T>::InfoString() const … … 226 276 } 227 277 278 //! Print matrix 279 /*! 280 \param maxprt : maximum numer of print 281 \param si : if true, display attached DvList 282 \sa SetMaxPrint 283 */ 228 284 template <class T> 229 285 void TMatrix<T>::Print(ostream& os, int_4 maxprt, bool si) const … … 252 308 //////////////////////////////////////////////////////////////// 253 309 310 //! Return the matrix product C = (*this)*B 311 /*! 312 \param mm : define the memory mapping type for the return matrix 313 */ 254 314 template <class T> 255 315 TMatrix<T> TMatrix<T>::Multiply(const TMatrix<T>& b, short mm) const -
trunk/SophyaLib/TArray/tmatrix.h
r813 r894 8 8 9 9 namespace SOPHYA { 10 11 //! Class of matrixes 12 /*! 13 \sa TArray 14 */ 10 15 11 16 template <class T> … … 23 28 // Pour verifiez la compatibilite de dimensions lors de l'affectation 24 29 virtual TArray<T>& Set(const TArray<T>& a); 30 //! Operator = between matrices 25 31 inline TMatrix<T>& operator = (const TMatrix<T>& a) 26 32 { Set(a); return(*this); } 27 33 28 34 // Size - Changing the Size 35 //! return number of rows 29 36 inline uint_4 NRows() const {return Size(marowi_); } 37 //! return number of columns 30 38 inline uint_4 NCols() const {return Size(macoli_); } 39 //! return number of columns 31 40 inline uint_4 NCol() const {return Size(macoli_); } // back-compat Peida 32 41 … … 36 45 // Sub-matrix extraction $CHECK$ Reza 03/2000 Doit-on declarer ces methode const ? 37 46 TMatrix<T> SubMatrix(Range rline, Range rcol) const ; 47 //! () : Return submatrix define by \b Range \b rline and \b rcol 38 48 inline TMatrix<T> operator () (Range rline, Range rcol) const 39 49 { return SubMatrix(rline, rcol); } 40 50 // Lignes et colonnes de la matrice 51 //! Return submatrix define by line \b ir (line vector) 41 52 inline TMatrix<T> Row(uint_4 ir) const 42 53 { return SubMatrix(Range(ir,ir), Range(0,NCols()-1)); } 54 //! Return submatrix define by column \b ic (column vector) 43 55 inline TMatrix<T> Column(uint_4 ic) const 44 56 { return SubMatrix(Range(0,NRows()-1), Range(ic,ic)); } … … 58 70 // A = x (matrice diagonale Identite) 59 71 virtual TMatrix<T>& SetIdentity(IdentityMatrix imx); 72 // = : fill matrix with an identity matrix \b imx 60 73 inline TMatrix<T>& operator = (IdentityMatrix imx) { return SetIdentity(imx); } 61 74 75 // = : fill matrix with a Sequence \b seq 62 76 inline TMatrix<T>& operator = (Sequence seq) { SetSeq(seq); return(*this); } 63 77 64 78 // Operations diverses avec une constante 79 //! = : fill matrix with constant value \b x 65 80 inline TMatrix<T>& operator = (T x) { SetT(x); return(*this); } 81 //! += : add constant value \b x to matrix 66 82 inline TMatrix<T>& operator += (T x) { Add(x); return(*this); } 83 //! -= : substract constant value \b x to matrix 67 84 inline TMatrix<T>& operator -= (T x) { Sub(x); return(*this); } 85 //! *= : multiply matrix by constant value \b x 68 86 inline TMatrix<T>& operator *= (T x) { Mul(x); return(*this); } 87 //! /= : divide matrix by constant value \b x 69 88 inline TMatrix<T>& operator /= (T x) { Div(x); return(*this); } 70 89 71 90 // operations avec matrices 91 //! += : add a matrix 72 92 inline TMatrix<T>& operator += (const TMatrix<T>& a) { AddElt(a); return(*this); } 93 //! -= : substract a matrix 73 94 inline TMatrix<T>& operator -= (const TMatrix<T>& a) { SubElt(a); return(*this); } 74 // Produit matriciel Multiply : C = (*this)*B75 95 TMatrix<T> Multiply(const TMatrix<T>& b, short mm=SameMemoryMapping) const; 96 //! *= : matrix product : C = (*this)*B 76 97 inline TMatrix<T>& operator *= (const TMatrix<T>& b) 77 98 { this->Set(Multiply(b)); return(*this); } … … 85 106 86 107 // ---- inline acces methods ------ 108 //! () : return element for line \b r and column \b c 87 109 template <class T> 88 110 inline T const& TMatrix<T>::operator()(uint_4 r, uint_4 c) const … … 96 118 } 97 119 120 //! () : return element for line \b r and column \b c 98 121 template <class T> 99 122 inline T & TMatrix<T>::operator()(uint_4 r, uint_4 c) … … 113 136 // Doit-on le faire aussi pour les constantes ? - Fin de $CHECK$ Reza 3/4/2000 114 137 138 //! + : add matrixes \b a and \b b 115 139 template <class T> 116 140 inline TMatrix<T> operator + (const TMatrix<T>& a,const TMatrix<T>& b) 117 141 {TMatrix<T> result(a); result.SetTemp(true); result.AddElt(b); return result;} 118 142 143 //! - : substract matrixes \b a and \b b 119 144 template <class T> 120 145 inline TMatrix<T> operator - (const TMatrix<T>& a,const TMatrix<T>& b) … … 122 147 123 148 // Surcharge d'operateurs C = A * B 124 149 //! - : multiply matrixes \b a and \b b 125 150 template <class T> inline TMatrix<T> operator * (const TMatrix<T>& a, const TMatrix<T>& b) 126 151 { TMatrix<T> result(a); result.SetTemp(true); return(result.Multiply(b)); } 127 152 153 //! Define Matrix to be TMatrix<r_8> 128 154 typedef TMatrix<r_8> Matrix; 129 155 -
trunk/SophyaLib/TArray/tvector.cc
r813 r894 1 // $Id: tvector.cc,v 1. 3 2000-04-05 15:44:17ansari Exp $1 // $Id: tvector.cc,v 1.4 2000-04-12 17:42:30 ansari Exp $ 2 2 // C.Magneville 04/99 3 3 #include "machdefs.h" … … 9 9 //**** Createur, Destructeur 10 10 11 //! Default constructor 11 12 template <class T> 12 13 TVector<T>::TVector() … … 15 16 } 16 17 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 */ 17 25 template <class T> 18 26 TVector<T>::TVector(uint_4 n, short lcv, short mm) … … 24 32 } 25 33 26 34 //! Constructor by copy (share if \b a is temporary) 27 35 template <class T> 28 36 TVector<T>::TVector(const TVector<T>& a) … … 32 40 } 33 41 42 //! Constructor by copy 43 /*! 44 \param share : if true, share data. If false copy data 45 */ 34 46 template <class T> 35 47 TVector<T>::TVector(const TVector<T>& a, bool share) … … 39 51 } 40 52 53 //! Constructor from a TArray 41 54 template <class T> 42 55 TVector<T>::TVector(const TArray<T>& a) … … 48 61 49 62 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 */ 50 71 template <class T> 51 72 TVector<T>::TVector(const TArray<T>& a, bool share, short mm, short lcv ) … … 61 82 } 62 83 84 //! Destructor 63 85 template <class T> 64 86 TVector<T>::~TVector() 65 // Destructeur66 87 { 67 68 88 } 69 89 90 //! Resize the vector 91 /*! 92 \param n : number of elements 93 \param lcv : line or column vector ? 94 \sa SelectVectorType 95 */ 70 96 template <class T> 71 97 void TVector<T>::ReSize(uint_4 n, short lcv) … … 82 108 } 83 109 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 */ 84 118 template <class T> 85 119 void TVector<T>::Realloc(uint_4 n, short lcv, bool force) … … 97 131 98 132 // $CHECK$ Reza 03/2000 Doit-on declarer cette methode const ? 133 //! Return a subvector define by \b Range \b relt 99 134 template <class T> 100 135 TVector<T> TVector<T>::SubVector(Range relt) const … … 109 144 } 110 145 146 //! Return the norm \f$ \sum{V(i)^2} \f$ 111 147 template <class T> 112 148 T TVector<T>::Norm2() const … … 117 153 } 118 154 155 //! Return info on number of rows, column and type \b T 119 156 template <class T> 120 157 string TVector<T>::InfoString() const -
trunk/SophyaLib/TArray/tvector.h
r813 r894 8 8 namespace SOPHYA { 9 9 10 //! Class of vector (line or column) 11 /*! 12 \sa TMatrix TArray 13 */ 10 14 template <class T> 11 15 class TVector : public TMatrix<T> { … … 21 25 virtual ~TVector(); 22 26 27 //! Operator = 23 28 inline TVector<T>& operator = (const TVector<T>& a) 24 29 { Set(a); return(*this); } … … 31 36 // Sub-Vector extraction $CHECK$ Reza 03/2000 Doit-on declarer cette methode const ? 32 37 TVector<T> SubVector(Range relt) const ; 38 //! Extract a vector define by Range \b relt 33 39 inline TVector<T> operator () (Range relt) const 34 40 { return SubVector(relt); } 35 41 36 42 // Informations pointeur/data 43 //! return the number of elements 37 44 inline uint_4 NElts() const {return Size(); } 38 45 … … 42 49 43 50 // Operateur d'affectation 51 //! Fill the 44 52 inline TMatrix<T>& operator = (Sequence seq) { SetSeq(seq); return(*this); } 45 53 46 54 // Operations diverses avec une constante 55 //! Set vector elements to constant value \b x 47 56 inline TVector<T>& operator = (T x) { SetT(x); return(*this); } 57 //! Add constant value \b x to vector elements 48 58 inline TVector<T>& operator += (T x) { Add(x); return(*this); } 59 //! Substract constant value \b x to vector elements 49 60 inline TVector<T>& operator -= (T x) { Sub(x); return(*this); } 61 //! Multiply vector elements by constant value \b x 50 62 inline TVector<T>& operator *= (T x) { Mul(x); return(*this); } 63 //! Divide vector elements by constant value \b x 51 64 inline TVector<T>& operator /= (T x) { Div(x); return(*this); } 52 65 53 66 // operations avec matrices 67 //! += : add a vector in place 54 68 inline TVector<T>& operator += (const TVector<T>& a) { AddElt(a); return(*this); } 69 //! += : substract a vector in place 55 70 inline TVector<T>& operator -= (const TVector<T>& a) { SubElt(a); return(*this); } 56 71 … … 63 78 64 79 // ---- inline acces methods ------ 80 81 //! Return the value of element \b n 65 82 template <class T> 66 83 inline T const& TVector<T>::operator()(uint_4 n) const … … 73 90 } 74 91 92 //! Return the value of element \b n 75 93 template <class T> 76 94 inline T & TVector<T>::operator()(uint_4 n) … … 84 102 85 103 // Typedef pour simplifier et compatibilite Peida 104 //! Define Vector to be TVector<r_8> 86 105 typedef TVector<r_8> Vector; 87 106 -
trunk/SophyaLib/TArray/utilarr.cc
r850 r894 8 8 // Classe utilitaires 9 9 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 */ 10 17 RandomSequence::RandomSequence(int typ, double m, double s) 11 18 { … … 15 22 } 16 23 24 //! Return random sequence values. 17 25 double RandomSequence::Rand() 18 26 { … … 23 31 24 32 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 */ 25 42 Sequence::Sequence(double start, double step, Arr_DoubleFunctionOfX f) 26 43 : rseq_(RandomSequence::Gaussian) … … 32 49 } 33 50 51 //! Constructor 52 /*! 53 \param rseq : RandomSequence 54 55 See \ref SequenceOperat "operator()" 56 */ 34 57 Sequence::Sequence(RandomSequence rseq) 35 58 { … … 41 64 } 42 65 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 */ 43 79 double Sequence::operator () (uint_4 k) 44 80 { … … 51 87 } 52 88 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 */ 53 101 Range::Range(uint_4 start, uint_4 end, uint_4 size, uint_4 step) 54 102 { … … 77 125 78 126 127 ////////////////////////////////////////////////////////// 128 //! Constructor of a (n,n) diagonal matrix with value diag on the diagonal 79 129 IdentityMatrix::IdentityMatrix(double diag, uint_4 n) 80 130 { -
trunk/SophyaLib/TArray/utilarr.h
r850 r894 13 13 /* Quelques utilitaires pour les tableaux (Array) */ 14 14 15 //! define a function of double which returns a double 15 16 typedef double (* Arr_DoubleFunctionOfX) (double x); 17 //! define a function of float which returns a float 16 18 typedef float (* Arr_FloatFunctionOfX) (float x); 17 19 20 ////////////////////////////////////////////////////////// 21 //! Class to generate a random sequence of values 18 22 class RandomSequence { 19 23 public: 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 21 30 RandomSequence(int typ = RandomSequence::Gaussian, double m=0., double s=1.); 22 31 double Rand(); 23 32 protected: 24 int typ_; 25 double mean_, sig_; 33 int typ_; //!< random generation type 34 double mean_, sig_; //!< generation parameters mean and sigma (if needed) 26 35 }; 27 36 28 37 38 ////////////////////////////////////////////////////////// 39 //! Class to generate a sequence of values 29 40 class Sequence { 30 41 public: 31 42 explicit Sequence (double start=0., double step=1., Arr_DoubleFunctionOfX f=NULL); 32 43 explicit Sequence (RandomSequence rseq); 44 45 //! return start value of the sequence 33 46 inline double & Start() { return start_; } 47 //! return step value of the sequence 34 48 inline double & Step() { return step_; } 35 49 double operator () (uint_4 k); 36 50 protected: 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 41 56 }; 42 57 58 ////////////////////////////////////////////////////////// 59 //! Class to define a range of indexes 43 60 class Range { 44 61 public: 45 62 explicit Range(uint_4 start=0, uint_4 end=0, uint_4 size=1, uint_4 step=1); 63 //! Return the start index 46 64 inline uint_4 & Start() { return start_; } 65 //! Return the last index 47 66 inline uint_4 & End() { return end_; } 67 //! Return the size 48 68 inline uint_4 & Size() { return size_; } 69 //! Return the step 49 70 inline uint_4 & Step() { return step_; } 50 71 protected: 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 52 76 }; 53 77 78 ////////////////////////////////////////////////////////// 79 //! Class to define an identity matrix 54 80 class IdentityMatrix { 55 81 public: 56 82 explicit IdentityMatrix(double diag=1., uint_4 n=0); 83 //! return the size of the identity matrix 57 84 inline uint_4 Size() { return size_; } 85 //! return the value of the diagonal elements 58 86 inline double Diag() { return diag_; } 59 87 protected: 60 uint_4 size_; 61 double diag_; 88 uint_4 size_; //!< size of the matrix 89 double diag_; //!< value of the diagonal elements 62 90 }; 63 91 … … 65 93 66 94 #endif 67
Note:
See TracChangeset
for help on using the changeset viewer.