Changeset 894 in Sophya for trunk/SophyaLib/TArray/tarray.cc
- Timestamp:
- Apr 12, 2000, 7:42:33 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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)
Note:
See TracChangeset
for help on using the changeset viewer.