Changeset 1156 in Sophya for trunk/SophyaLib/TArray
- Timestamp:
- Aug 29, 2000, 6:10:32 PM (25 years ago)
- Location:
- trunk/SophyaLib/TArray
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/TArray/basarr.cc
r1103 r1156 21 21 {"???", "Size(int )", "IsPacked(int )" 22 22 ,"Stride(int )", "ElemCheckBound()", "operator()" }; 23 uint_4BaseArray::max_nprt_ = 50;24 uint_4BaseArray::prt_lev_ = 0;23 int_4 BaseArray::max_nprt_ = 50; 24 int_4 BaseArray::prt_lev_ = 0; 25 25 short BaseArray::default_memory_mapping = CMemoryMapping; 26 26 short BaseArray::default_vector_type = ColumnVector; 27 uint_8BaseArray::openmp_size_threshold = 200000;27 sa_size_t BaseArray::openmp_size_threshold = 200000; 28 28 29 29 // ------ Methodes statiques globales -------- … … 34 34 \param lev : print level 35 35 */ 36 void BaseArray::SetMaxPrint( uint_4 nprt, uint_4 lev)36 void BaseArray::SetMaxPrint(int_4 nprt, int_4 lev) 37 37 { 38 38 max_nprt_ = nprt; … … 44 44 \param thr : thresold value 45 45 */ 46 void BaseArray::SetOpenMPSizeThreshold( uint_8thr)46 void BaseArray::SetOpenMPSizeThreshold(sa_size_t thr) 47 47 { 48 48 openmp_size_threshold = thr; … … 58 58 \return Total size of the array 59 59 */ 60 uint_8 BaseArray::ComputeTotalSize(uint_4 ndim, const uint_4 * siz, uint_4 step, uint_8offset)61 { 62 uint_8rs = step;63 for( uint_4k=0; k<ndim; k++) rs *= siz[k];60 sa_size_t BaseArray::ComputeTotalSize(int_4 ndim, const sa_size_t * siz, sa_size_t step, sa_size_t offset) 61 { 62 sa_size_t rs = step; 63 for(sa_size_t k=0; k<ndim; k++) rs *= siz[k]; 64 64 return(rs+offset); 65 65 } … … 251 251 { 252 252 ndim_ = 0; 253 for(int k=0; k<BASEARRAY_MAXNDIMS; k++) step_[k] = size_[k] = 0;253 for(int_4 k=0; k<BASEARRAY_MAXNDIMS; k++) step_[k] = size_[k] = 0; 254 254 totsize_ = 0; 255 255 minstep_ = 0; … … 295 295 if (arrtype_ == 0) { // Simple TArray, not a matrix 296 296 smo = true; 297 for( uint_4 k=0; k<ndim_; k++)297 for(int_4 k=0; k<ndim_; k++) 298 298 if (size_[k] != a.size_[k]) return(false); 299 299 return(true); … … 304 304 (size_[macoli_] != a.size_[a.macoli_]) ) return(false); 305 305 if (ndim_ > 2) 306 for( uint_4 k=2; k<ndim_; k++)306 for(int_4 k=2; k<ndim_; k++) 307 307 if (size_[k] != a.size_[k]) return(false); 308 308 if ( (macoli_ == a.macoli_) && (marowi_ == a.marowi_) || … … 316 316 { 317 317 if (ndim_ < 2) return; 318 uint_4 ndim = 0;319 uint_4size[BASEARRAY_MAXNDIMS];320 uint_4step[BASEARRAY_MAXNDIMS];321 for( uint_4 k=0; k<ndim_; k++) {318 int_4 ndim = 0; 319 sa_size_t size[BASEARRAY_MAXNDIMS]; 320 sa_size_t step[BASEARRAY_MAXNDIMS]; 321 for(int_4 k=0; k<ndim_; k++) { 322 322 if (size_[k] < 2) continue; 323 323 size[ndim] = size_[k]; … … 339 339 { 340 340 if (ndim_ < 2) return; 341 uint_4 ndim = 0;342 uint_4size[BASEARRAY_MAXNDIMS];343 uint_4step[BASEARRAY_MAXNDIMS];344 for( uint_4 k=0; k<ndim_; k++) {341 int_4 ndim = 0; 342 sa_size_t size[BASEARRAY_MAXNDIMS]; 343 sa_size_t step[BASEARRAY_MAXNDIMS]; 344 for(int_4 k=0; k<ndim_; k++) { 345 345 size[ndim] = size_[k]; 346 346 step[ndim] = step_[k]; … … 354 354 355 355 //! return minimum value for step[ndim] 356 int BaseArray::MinStepKA() const357 { 358 for( uint_4 ka=0; ka<ndim_; ka++)356 int_4 BaseArray::MinStepKA() const 357 { 358 for(int_4 ka=0; ka<ndim_; ka++) 359 359 if (step_[ka] == minstep_) return((int)ka); 360 360 return(0); … … 362 362 363 363 //! return maximum value for step[ndim] 364 int BaseArray::MaxSizeKA() const365 { 366 int ka = 0;367 uint_4mx = size_[0];368 for( uint_4 k=1; k<ndim_; k++)364 int_4 BaseArray::MaxSizeKA() const 365 { 366 int_4 ka = 0; 367 sa_size_t mx = size_[0]; 368 for(int_4 k=1; k<ndim_; k++) 369 369 if (size_[k] > mx) { ka = k; mx = size_[k]; } 370 370 return(ka); … … 377 377 // -------------------------------------------------- 378 378 //! return position of first element for vector \b i alond \b ka th axe. 379 uint_8 BaseArray::Offset(uint_4 ka, uint_8i) const379 sa_size_t BaseArray::Offset(int_4 ka, sa_size_t i) const 380 380 { 381 381 … … 383 383 //#ifdef SO_BOUNDCHECKING 384 384 if (ka >= ndim_) 385 throw RangeCheckError("BaseArray::Offset( uint_4 ka, uint_8i) Axe KA Error");385 throw RangeCheckError("BaseArray::Offset(int_4 ka, sa_size_t i) Axe KA Error"); 386 386 if ( i*size_[ka] >= totsize_ ) 387 throw RangeCheckError("BaseArray::Offset( uint_4 ka, uint_8i) Index Error");387 throw RangeCheckError("BaseArray::Offset(int_4 ka, sa_size_t i) Index Error"); 388 388 //#endif 389 uint_4idx[BASEARRAY_MAXNDIMS];390 uint_4 k;391 uint_8rest = i;389 sa_size_t idx[BASEARRAY_MAXNDIMS]; 390 int_4 k; 391 sa_size_t rest = i; 392 392 idx[ka] = 0; 393 393 for(k=0; k<ndim_; k++) { … … 395 395 idx[k] = rest%size_[k]; rest /= size_[k]; 396 396 } 397 uint_8off = offset_;397 sa_size_t off = offset_; 398 398 for(k=0; k<ndim_; k++) off += idx[k]*step_[k]; 399 399 return (off); … … 401 401 402 402 //! return position of element \b ip. 403 uint_8 BaseArray::Offset(uint_8ip) const403 sa_size_t BaseArray::Offset(sa_size_t ip) const 404 404 { 405 405 if ( (ndim_ < 1) || (ip == 0) ) return(offset_); 406 406 //#ifdef SO_BOUNDCHECKING 407 407 if (ip >= totsize_) 408 throw RangeCheckError("BaseArray::Offset( uint_8ip) Out of range index ip");408 throw RangeCheckError("BaseArray::Offset(sa_size_t ip) Out of range index ip"); 409 409 //#endif 410 410 411 uint_4idx[BASEARRAY_MAXNDIMS];412 uint_4 k;413 uint_8rest = ip;411 sa_size_t idx[BASEARRAY_MAXNDIMS]; 412 int_4 k; 413 sa_size_t rest = ip; 414 414 for(k=0; k<ndim_; k++) { 415 415 idx[k] = rest%size_[k]; rest /= size_[k]; … … 417 417 //#ifdef SO_BOUNDCHECKING 418 418 if (rest != 0) 419 throw PError("BaseArray::Offset( uint_8ip) GUG !!! rest != 0");419 throw PError("BaseArray::Offset(sa_size_t ip) GUG !!! rest != 0"); 420 420 //#endif 421 421 // if (rest != 0) cerr << " BUG ---- BaseArray::Offset( " << ip << " )" << rest << endl; … … 423 423 // for(k=0; k<ndim_; k++) cerr << idx[k] << "," ; 424 424 // cerr << " ZZZZ " << endl; 425 uint_8off = offset_;425 sa_size_t off = offset_; 426 426 for(k=0; k<ndim_; k++) off += idx[k]*step_[k]; 427 427 return (off); … … 429 429 430 430 //! return various parameters for double loop operations on two arrays. 431 void BaseArray::GetOpeParams(const BaseArray& a, bool smo, int & ax, int& axa, uint_8& step,432 uint_8& stepa, uint_8& gpas, uint_8& naxa)431 void BaseArray::GetOpeParams(const BaseArray& a, bool smo, int_4& ax, int_4& axa, sa_size_t& step, 432 sa_size_t& stepa, sa_size_t& gpas, sa_size_t& naxa) 433 433 { 434 434 if (smo) { // Same memory organisation … … 465 465 os << "\n--- " << InfoString() ; 466 466 os << " ND=" << ndim_ << " SizeX*Y*...= " ; 467 for( uint_4 k=0; k<ndim_; k++) {467 for(int_4 k=0; k<ndim_; k++) { 468 468 os << size_[k]; 469 469 if (k<ndim_-1) os << "x"; … … 472 472 if (prt_lev_ > 0) { 473 473 os << " TotSize= " << totsize_ << " Step(X Y ...)=" ; 474 for( uint_4 k=0; k<ndim_; k++) os << step_[k] << " " ;474 for(int_4 k=0; k<ndim_; k++) os << step_[k] << " " ; 475 475 os << " Offset= " << offset_ << endl; 476 476 } … … 509 509 \return string \b exmsg for explanation in case of problems 510 510 */ 511 bool BaseArray::UpdateSizes( uint_4 ndim, const uint_4 * siz, uint_4 step, uint_8offset, string & exmsg)511 bool BaseArray::UpdateSizes(int_4 ndim, const sa_size_t * siz, sa_size_t step, sa_size_t offset, string & exmsg) 512 512 { 513 513 if (ndim >= BASEARRAY_MAXNDIMS) { … … 524 524 525 525 totsize_ = 1; 526 uint_4 k;526 int_4 k; 527 527 for(k=0; k<BASEARRAY_MAXNDIMS; k++) { 528 528 size_[k] = 1; … … 560 560 \return string \b exmsg for explanation in case of problems 561 561 */ 562 bool BaseArray::UpdateSizes( uint_4 ndim, const uint_4 * siz, const uint_4 * step, uint_8offset, string & exmsg)562 bool BaseArray::UpdateSizes(int_4 ndim, const sa_size_t * siz, const sa_size_t * step, sa_size_t offset, string & exmsg) 563 563 { 564 564 if (ndim >= BASEARRAY_MAXNDIMS) { … … 570 570 571 571 totsize_ = 1; 572 uint_4 k;572 int_4 k; 573 573 for(k=0; k<BASEARRAY_MAXNDIMS; k++) { 574 574 size_[k] = 1; 575 575 step_[k] = 0; 576 576 } 577 uint_4minstep = step[0];577 sa_size_t minstep = step[0]; 578 578 for(k=0; k<ndim; k++) { 579 579 size_[k] = siz[k] ; … … 588 588 exmsg += " Size Error"; return false; 589 589 } 590 uint_8plast = 0;590 sa_size_t plast = 0; 591 591 for(k=0; k<ndim; k++) plast += (siz[k]-1)*step[k]; 592 592 if (plast == minstep*totsize_ ) moystep_ = minstep; … … 623 623 624 624 totsize_ = 1; 625 uint_4 k;625 int_4 k; 626 626 for(k=0; k<BASEARRAY_MAXNDIMS; k++) { 627 627 size_[k] = 1; 628 628 step_[k] = 0; 629 629 } 630 uint_4minstep = a.step_[0];630 sa_size_t minstep = a.step_[0]; 631 631 for(k=0; k<a.ndim_; k++) { 632 632 size_[k] = a.size_[k] ; … … 663 663 \return string \b exmsg for explanation in case of problems 664 664 */ 665 void BaseArray::UpdateSubArraySizes(BaseArray & ra, uint_4 ndim, uint_4 * siz, uint_4 * pos, uint_4* step) const665 void BaseArray::UpdateSubArraySizes(BaseArray & ra, int_4 ndim, sa_size_t * siz, sa_size_t * pos, sa_size_t * step) const 666 666 { 667 667 if ( (ndim > ndim_) || (ndim < 1) ) 668 668 throw(SzMismatchError("BaseArray::UpdateSubArraySizes( ... ) NDim Error") ); 669 uint_4 k;669 int_4 k; 670 670 for(k=0; k<ndim; k++) 671 671 if ( (siz[k]*step[k]+pos[k]) > size_[k] ) 672 672 throw(SzMismatchError("BaseArray::UpdateSubArraySizes( ... ) Size/Pos Error") ); 673 uint_8offset = offset_;673 sa_size_t offset = offset_; 674 674 for(k=0; k<ndim_; k++) { 675 675 offset += pos[k]*step_[k]; -
trunk/SophyaLib/TArray/basarr.h
r1099 r1156 40 40 41 41 // threshold for parallel routine call 42 static void SetOpenMPSizeThreshold( uint_8thr=200000);42 static void SetOpenMPSizeThreshold(sa_size_t thr=200000); 43 43 //! Get Size threshold for parallel routine call 44 static inline uint_8GetOpenMPSizeThreshold() { return openmp_size_threshold; }45 46 static void SetMaxPrint( uint_4 nprt=50, uint_4 lev=0);44 static inline sa_size_t GetOpenMPSizeThreshold() { return openmp_size_threshold; } 45 46 static void SetMaxPrint(int_4 nprt=50, int_4 lev=0); 47 47 //! Get maximum number of printed elements 48 static inline uint_4 GetMaxPrint() { return max_nprt_; }49 //! Maximum number of printed elements arintlevel50 static inline uint_4 GetPrintLevel() { return prt_lev_; }48 static inline int_4 GetMaxPrint() { return max_nprt_; } 49 //! Get print level 50 static inline int_4 GetPrintLevel() { return prt_lev_; } 51 51 52 52 static short SetDefaultMemoryMapping(short mm=CMemoryMapping); … … 70 70 // Array dimensions 71 71 //! Return number of dimensions 72 inline uint_4 NbDimensions() const { return( ndim_ ); }72 inline int_4 NbDimensions() const { return( ndim_ ); } 73 73 74 74 //! Return total size of the array 75 inline uint_8Size() const { return(totsize_); }75 inline sa_size_t Size() const { return(totsize_); } 76 76 //! Return size along the first dimension 77 inline uint_4SizeX() const { return(size_[0]); }77 inline sa_size_t SizeX() const { return(size_[0]); } 78 78 //! Return size along the second dimension 79 inline uint_4SizeY() const { return(size_[1]); }79 inline sa_size_t SizeY() const { return(size_[1]); } 80 80 //! Return size along the third dimension 81 inline uint_4SizeZ() const { return(size_[2]); }81 inline sa_size_t SizeZ() const { return(size_[2]); } 82 82 //! Return size along the \b ka th dimension 83 inline uint_4 Size(intka) const { return(size_[CheckDI(ka,1)]); }84 85 int MaxSizeKA() const ;83 inline sa_size_t Size(int_4 ka) const { return(size_[CheckDI(ka,1)]); } 84 85 int_4 MaxSizeKA() const ; 86 86 87 87 //! Get memory organization … … 89 89 { return ( (marowi_ == 1) ? CMemoryMapping : FortranMemoryMapping) ; } 90 90 //! line index dimension 91 inline int RowsKA() const {return marowi_; }91 inline int_4 RowsKA() const {return marowi_; } 92 92 //! column index dimension 93 inline int ColsKA() const {return macoli_; }93 inline int_4 ColsKA() const {return macoli_; } 94 94 //! Index dimension of the elements of a vector 95 inline int VectKA() const {return veceli_; }95 inline int_4 VectKA() const {return veceli_; } 96 96 void SetMemoryMapping(short mm=AutoMemoryMapping); 97 97 … … 111 111 inline bool IsPackedZ() const { return(step_[2] == 1); } 112 112 //! return true if array is packed along the \b ka th dimension 113 inline bool IsPacked(int ka) const { return(step_[CheckDI(ka,2)] == 1); }113 inline bool IsPacked(int_4 ka) const { return(step_[CheckDI(ka,2)] == 1); } 114 114 115 115 //! return the minimum step value along all the dimensions 116 inline uint_4MinStep() const { return(minstep_); }116 inline sa_size_t MinStep() const { return(minstep_); } 117 117 //! return the average step value along all the dimensions 118 inline uint_4AvgStep() const { return(moystep_); }118 inline sa_size_t AvgStep() const { return(moystep_); } 119 119 //! return the step along the first dimension 120 inline uint_4StepX() const { return(step_[0]); }120 inline sa_size_t StepX() const { return(step_[0]); } 121 121 //! return the step along the second dimension 122 inline uint_4StepY() const { return(step_[1]); }122 inline sa_size_t StepY() const { return(step_[1]); } 123 123 //! return the step along the third dimension 124 inline uint_4StepZ() const { return(step_[2]); }124 inline sa_size_t StepZ() const { return(step_[2]); } 125 125 //! return the step along the \b ka th dimension 126 inline uint_4 Step(intka) const { return(step_[CheckDI(ka,3)]); }127 128 int MinStepKA() const ;126 inline sa_size_t Step(int_4 ka) const { return(step_[CheckDI(ka,3)]); } 127 128 int_4 MinStepKA() const ; 129 129 130 130 // Offset of element ip 131 uint_8 Offset(uint_8ip=0) const ;131 sa_size_t Offset(sa_size_t ip=0) const ; 132 132 // Offset of the i'th vector along axe ka 133 uint_8 Offset(uint_4 ka, uint_8i) const ;134 inline uint_8 Offset(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it=0, uint_4iu=0) const;133 sa_size_t Offset(int_4 ka, sa_size_t i) const ; 134 inline sa_size_t Offset(sa_size_t ix, sa_size_t iy, sa_size_t iz, sa_size_t it=0, sa_size_t iu=0) const; 135 135 136 136 // an abstract element acces methode 137 virtual MuTyV & ValueAtPosition( uint_8ip) const = 0;137 virtual MuTyV & ValueAtPosition(sa_size_t ip) const = 0; 138 138 139 139 // Pour recuperer pas et numero d'axe pour operations sur deux arrays 140 void GetOpeParams(const BaseArray& a, bool smo, int & ax, int& axa, uint_8& step,141 uint_8& stepa, uint_8& gpas, uint_8& naxa);140 void GetOpeParams(const BaseArray& a, bool smo, int_4& ax, int_4& axa, sa_size_t& step, 141 sa_size_t& stepa, sa_size_t& gpas, sa_size_t& naxa); 142 142 // Impression, I/O, ... 143 143 void Show(ostream& os, bool si=false) const; … … 150 150 151 151 protected: 152 inline int CheckDI(intka, int msg) const ;153 inline void CheckBound( uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4iu, int msg) const ;152 inline int_4 CheckDI(int_4 ka, int msg) const ; 153 inline void CheckBound(sa_size_t ix, sa_size_t iy, sa_size_t iz, sa_size_t it, sa_size_t iu, int msg) const ; 154 154 // Changing Sizes/NDim ... return true if OK 155 bool UpdateSizes( uint_4 ndim, const uint_4 * siz, uint_4 step, uint_8offset, string & exmsg);156 bool UpdateSizes( uint_4 ndim, const uint_4 * siz, const uint_4 * step, uint_8offset, string & exmsg);155 bool UpdateSizes(sa_size_t ndim, const sa_size_t * siz, sa_size_t step, sa_size_t offset, string & exmsg); 156 bool UpdateSizes(sa_size_t ndim, const sa_size_t * siz, const sa_size_t * step, sa_size_t offset, string & exmsg); 157 157 bool UpdateSizes(const BaseArray& a, string & exmsg); 158 static uint_8 ComputeTotalSize(uint_4 ndim, const uint_4 * siz, uint_4 step, uint_8offset) ;158 static sa_size_t ComputeTotalSize(sa_size_t ndim, const sa_size_t * siz, sa_size_t step, sa_size_t offset) ; 159 159 // Organisation memoire 160 160 static short SelectMemoryMapping(short mm); … … 164 164 165 165 // Pour Extraction de sous-tableau 166 virtual void UpdateSubArraySizes(BaseArray & ra, uint_4 ndim, uint_4 * siz, uint_4 * pos, uint_4* step) const;167 168 uint_4ndim_; //!< number of dimensions of array169 uint_4size_[BASEARRAY_MAXNDIMS]; //!< array of the size in each dimension170 uint_8totsize_; //!< Total number of elements171 uint_8offset_; //!< global offset -\> position of elem[0] in DataBlock166 virtual void UpdateSubArraySizes(BaseArray & ra, sa_size_t ndim, sa_size_t * siz, sa_size_t * pos, sa_size_t * step) const; 167 168 int_4 ndim_; //!< number of dimensions of array 169 sa_size_t size_[BASEARRAY_MAXNDIMS]; //!< array of the size in each dimension 170 sa_size_t totsize_; //!< Total number of elements 171 sa_size_t offset_; //!< global offset -\> position of elem[0] in DataBlock 172 172 //! two consecutive elements distance in a given dimension 173 uint_4step_[BASEARRAY_MAXNDIMS];174 uint_4minstep_; //!< minimal step (in any axes)175 uint_4moystep_; //!< mean step, if == 0 --\> non regular steps173 sa_size_t step_[BASEARRAY_MAXNDIMS]; 174 sa_size_t minstep_; //!< minimal step (in any axes) 175 sa_size_t moystep_; //!< mean step, if == 0 --\> non regular steps 176 176 int_2 marowi_; //!< For matrices, Row index in dimensions 177 177 int_2 macoli_; //!< For matrices, Column index in dimensions … … 181 181 182 182 static char * ck_op_msg_[6]; //!< Operation messages for CheckDI() CheckBound() 183 static uint_4 max_nprt_; //!< maximum number of printed elements184 static uint_4 prt_lev_; //!< Print level183 static int_4 max_nprt_; //!< maximum number of printed elements 184 static int_4 prt_lev_; //!< Print level 185 185 static short default_memory_mapping; //!< Default memory mapping 186 186 static short default_vector_type; //!< Default vector type Row/Column 187 static uint_8openmp_size_threshold; //!< Size limit for parallel routine calls187 static sa_size_t openmp_size_threshold; //!< Size limit for parallel routine calls 188 188 }; 189 189 … … 192 192 // -------------------------------------------------- 193 193 //! to verify the compatibility of the dimension index 194 inline int BaseArray::CheckDI(intka, int msg) const194 inline int_4 BaseArray::CheckDI(int_4 ka, int msg) const 195 195 { 196 if ( (ka < 0) || ( (uint_4)ka >= ndim_) ) {196 if ( (ka < 0) || (ka >= ndim_) ) { 197 197 string txt = "BaseArray::CheckDimensionIndex/Error "; txt += ck_op_msg_[msg]; 198 198 throw(RangeCheckError(txt)); … … 202 202 203 203 //! to verify the compatibility of the indexes in all dimensions 204 inline void BaseArray::CheckBound( uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4iu, int msg) const204 inline void BaseArray::CheckBound(sa_size_t ix, sa_size_t iy, sa_size_t iz, sa_size_t it, sa_size_t iu, int msg) const 205 205 { 206 if ( (ix >= size_[0]) || (iy >= size_[1]) || (iz > size_[2]) || 207 (it >= size_[3]) || (iu >= size_[4]) ) { 206 if ( (ix >= size_[0]) || (ix < 0) || (iy >= size_[1]) || (iy < 0) || 207 (iz >= size_[2]) || (iz < 0) || (it >= size_[3]) || (it < 0) || 208 (iu >= size_[4]) || (iu < 0) ) { 208 209 string txt = "BaseArray::CheckArrayBound/Error "; txt += ck_op_msg_[msg]; 209 210 throw(RangeCheckError(txt)); … … 218 219 // -------------------------------------------------- 219 220 //! Offset of element (ix,iy,iz,it,iu) 220 inline uint_8 BaseArray::Offset(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4iu) const221 inline sa_size_t BaseArray::Offset(sa_size_t ix, sa_size_t iy, sa_size_t iz, sa_size_t it, sa_size_t iu) const 221 222 { 222 223 #ifdef SO_BOUNDCHECKING -
trunk/SophyaLib/TArray/fioarr.cc
r926 r1156 93 93 uint_4 itab[5]; 94 94 is.Get(itab,5); 95 96 // Checking version number 97 if (itab[0] < 2) 98 FileFormatExc("FIO_TArray<T>::ReadSelf() - Unsupported (old V<2) version"); 99 95 100 if (dobj == NULL) { 96 101 if (itab[1] == 12) dobj = new TMatrix<T>; … … 99 104 } 100 105 // On lit les tailles, etc ... 101 is.Get(dobj->ndim_); 102 is.Get(dobj->size_, BASEARRAY_MAXNDIMS); 103 is.Get(dobj->totsize_); 104 is.Get(dobj->step_, BASEARRAY_MAXNDIMS); 105 is.Get(dobj->minstep_); 106 is.Get(dobj->moystep_); 107 is.Get(dobj->offset_); 108 is.Get(dobj->marowi_); 109 is.Get(dobj->macoli_); 110 is.Get(dobj->veceli_); 106 // On ecrit les tailles, etc ... 107 int_4 tmpi4s[5]; 108 is.Get(tmpi4s, 5); 109 dobj->ndim_ = tmpi4s[0]; 110 dobj->marowi_ = tmpi4s[1]; 111 dobj->macoli_ = tmpi4s[2]; 112 dobj->veceli_ = tmpi4s[3]; 113 // tmpi4s[4] Reserved for future use 114 115 // Tous les sa_size_t sont ecrit/lu en int_8 afin de maintenir la compatibilite 116 // entre version du programme utilisant int_4 OU int_8 pour sa_size_t 117 int_8 tmpi8s[BASEARRAY_MAXNDIMS]; 118 119 is.Get(tmpi8s, BASEARRAY_MAXNDIMS); 120 for(int kk=0; kk<BASEARRAY_MAXNDIMS; kk++) 121 dobj->size_[kk] = tmpi8s[kk]; 122 is.Get(tmpi8s, BASEARRAY_MAXNDIMS); 123 for(int kk=0; kk<BASEARRAY_MAXNDIMS; kk++) 124 dobj->step_[kk] = tmpi8s[kk]; 125 126 is.Get(tmpi8s, 5); 127 dobj->totsize_ = tmpi8s[0]; 128 dobj->offset_ = tmpi8s[1]; 129 dobj->minstep_ = tmpi8s[2]; 130 dobj->moystep_ = tmpi8s[3]; 131 // tmpi8s[4] Reserved for future use 132 111 133 // On lit le datablock 112 134 is >> dobj->DataBlock(); … … 132 154 133 155 uint_4 itab[5]; 134 itab[0] = 1; // Numero de version a 1156 itab[0] = 2; // Numero de version a 2 depuis Aout 2000 - Reza 135 157 itab[1] = typa; // Real object type 136 158 itab[2] = (dobj->mInfo != NULL) ? 1 : 0; 137 159 itab[3] = itab[4] = 0; 138 160 os.Put(itab,5); 161 139 162 // On ecrit les tailles, etc ... 140 os.Put(dobj->ndim_); 141 os.Put(dobj->size_, BASEARRAY_MAXNDIMS); 142 os.Put(dobj->totsize_); 143 os.Put(dobj->step_, BASEARRAY_MAXNDIMS); 144 os.Put(dobj->minstep_); 145 os.Put(dobj->moystep_); 146 os.Put(dobj->offset_); 147 os.Put(dobj->marowi_); 148 os.Put(dobj->macoli_); 149 os.Put(dobj->veceli_); 163 int_4 tmpi4s[5]; 164 // os.Put(dobj->ndim_); 165 // os.Put(dobj->marowi_); 166 // os.Put(dobj->macoli_); 167 // os.Put(dobj->veceli_); 168 tmpi4s[0] = dobj->ndim_; 169 tmpi4s[1] = dobj->marowi_; 170 tmpi4s[2] = dobj->macoli_; 171 tmpi4s[3] = dobj->veceli_; 172 tmpi4s[4] = 0; // Reserved for future use 173 os.Put(tmpi4s, 5); 174 175 // Tous les sa_size_t sont ecrit en int_8 afin de pouvoir etre ecrit/relu 176 // entre version du programme utilisant int_4 OU int_8 pour sa_size_t 177 int_8 tmpi8s[BASEARRAY_MAXNDIMS]; 178 179 // os.Put(dobj->size_, BASEARRAY_MAXNDIMS); 180 for(int kk=0; kk<BASEARRAY_MAXNDIMS; kk++) 181 tmpi8s[kk] = dobj->size_[kk]; 182 os.Put(tmpi8s, BASEARRAY_MAXNDIMS); 183 // os.Put(dobj->step_, BASEARRAY_MAXNDIMS); 184 for(int kk=0; kk<BASEARRAY_MAXNDIMS; kk++) 185 tmpi8s[kk] = dobj->step_[kk]; 186 os.Put(tmpi8s, BASEARRAY_MAXNDIMS); 187 188 // os.Put(dobj->totsize_); 189 // os.Put(dobj->offset_); 190 // os.Put(dobj->minstep_); 191 // os.Put(dobj->moystep_); 192 tmpi8s[0] = dobj->totsize_; 193 tmpi8s[1] = dobj->offset_; 194 tmpi8s[2] = dobj->minstep_; 195 tmpi8s[3] = dobj->moystep_; 196 tmpi8s[4] = 0; // Reserved for future use 197 os.Put(tmpi8s, 5); 198 150 199 // On ecrit le datablock 151 200 os << dobj->DataBlock(); -
trunk/SophyaLib/TArray/matharr.cc
r1099 r1156 29 29 throw RangeCheckError("MathArray<T>::ApplyFunctionInPlace(TArray<T> & a..) Not Allocated Array a !"); 30 30 T * pe; 31 uint_8j,k;31 sa_size_t j,k; 32 32 if (a.AvgStep() > 0) { // regularly spaced elements 33 uint_8step = a.AvgStep();34 uint_8maxx = a.Size()*step;33 sa_size_t step = a.AvgStep(); 34 sa_size_t maxx = a.Size()*step; 35 35 pe = a.Data(); 36 36 for(k=0; k<maxx; k+=step ) pe[k] = (T)(f((double)pe[k])); 37 37 } 38 38 else { // Non regular data spacing ... 39 uint_4 ka = a.MaxSizeKA();40 uint_8step = a.Step(ka);41 uint_8gpas = a.Size(ka)*step;42 uint_8naxa = a.Size()/a.Size(ka);39 int_4 ka = a.MaxSizeKA(); 40 sa_size_t step = a.Step(ka); 41 sa_size_t gpas = a.Size(ka)*step; 42 sa_size_t naxa = a.Size()/a.Size(ka); 43 43 for(j=0; j<naxa; j++) { 44 44 pe = a.DataBlock().Begin()+a.Offset(ka,j); … … 61 61 throw RangeCheckError("MathArray<T>::ApplyFunctionInPlace(TArray<T> & a..) Not Allocated Array a !"); 62 62 T * pe; 63 uint_8j,k;63 sa_size_t j,k; 64 64 if (a.AvgStep() > 0) { // regularly spaced elements 65 uint_8step = a.AvgStep();66 uint_8maxx = a.Size()*step;65 sa_size_t step = a.AvgStep(); 66 sa_size_t maxx = a.Size()*step; 67 67 pe = a.Data(); 68 68 for(k=0; k<maxx; k+=step ) pe[k] = (T)(f((float)pe[k])); 69 69 } 70 70 else { // Non regular data spacing ... 71 uint_4 ka = a.MaxSizeKA();72 uint_8step = a.Step(ka);73 uint_8gpas = a.Size(ka)*step;74 uint_8naxa = a.Size()/a.Size(ka);71 int_4 ka = a.MaxSizeKA(); 72 sa_size_t step = a.Step(ka); 73 sa_size_t gpas = a.Size(ka)*step; 74 sa_size_t naxa = a.Size()/a.Size(ka); 75 75 for(j=0; j<naxa; j++) { 76 76 pe = a.DataBlock().Begin()+a.Offset(ka,j); … … 119 119 throw RangeCheckError("MathArray<T>::MeanSigma(TArray<T> const & a..) Not Allocated Array a !"); 120 120 const T * pe; 121 uint_8j,k;121 sa_size_t j,k; 122 122 mean=0.; 123 123 sig = 0.; 124 124 double valok; 125 125 if (a.AvgStep() > 0) { // regularly spaced elements 126 uint_8step = a.AvgStep();127 uint_8maxx = a.Size()*step;126 sa_size_t step = a.AvgStep(); 127 sa_size_t maxx = a.Size()*step; 128 128 pe = a.Data(); 129 129 for(k=0; k<maxx; k+=step ) { … … 133 133 } 134 134 else { // Non regular data spacing ... 135 uint_4 ka = a.MaxSizeKA();136 uint_8step = a.Step(ka);137 uint_8gpas = a.Size(ka)*step;138 uint_8naxa = a.Size()/a.Size(ka);135 int_4 ka = a.MaxSizeKA(); 136 sa_size_t step = a.Step(ka); 137 sa_size_t gpas = a.Size(ka)*step; 138 sa_size_t naxa = a.Size()/a.Size(ka); 139 139 for(j=0; j<naxa; j++) { 140 140 pe = a.DataBlock().Begin()+a.Offset(ka,j); -
trunk/SophyaLib/TArray/tarray.cc
r1113 r1156 39 39 */ 40 40 template <class T> 41 TArray<T>::TArray( uint_4 ndim, const uint_4 * siz, uint_4step)41 TArray<T>::TArray(int_4 ndim, const sa_size_t * siz, sa_size_t step) 42 42 : BaseArray() , mNDBlock(ComputeTotalSize(ndim, siz, step, 1)) 43 43 { 44 string exmsg = "TArray<T>::TArray( uint_4, uint_4 *, uint_4)";44 string exmsg = "TArray<T>::TArray(int_4, sa_size_t *, sa_size_t)"; 45 45 if (!UpdateSizes(ndim, siz, step, 0, exmsg)) throw( ParmError(exmsg) ); 46 46 } … … 51 51 */ 52 52 template <class T> 53 TArray<T>::TArray( uint_4 nx, uint_4 ny, uint_4 nz, uint_4 nt, uint_4nu)53 TArray<T>::TArray(sa_size_t nx, sa_size_t ny, sa_size_t nz, sa_size_t nt, sa_size_t nu) 54 54 : BaseArray() , mNDBlock(nx*((ny>0)?ny:1)*((nz>0)?nz:1)*((nt>0)?nt:1)*((nu>0)?nu:1)) 55 55 { 56 uint_4size[BASEARRAY_MAXNDIMS];56 sa_size_t size[BASEARRAY_MAXNDIMS]; 57 57 size[0] = nx; size[1] = ny; size[2] = nz; 58 58 size[3] = nt; size[4] = nu; 59 int ndim = 1;59 int_4 ndim = 1; 60 60 if ((size[1] > 0) && (size[2] > 0) && (size[3] > 0) && (size[4] > 0) ) ndim = 5; 61 61 else if ((size[1] > 0) && (size[2] > 0) && (size[3] > 0) ) ndim = 4; … … 63 63 else if (size[1] > 0) ndim = 2; 64 64 else ndim = 1; 65 string exmsg = "TArray<T>::TArray( uint_4, uint_4, uint_4)";65 string exmsg = "TArray<T>::TArray(sa_size_t, sa_size_t, sa_size_t, sa_size_t, sa_size_t)"; 66 66 if (!UpdateSizes(ndim, size, 1, 0, exmsg)) throw( ParmError(exmsg) ); 67 67 } … … 77 77 */ 78 78 template <class T> 79 TArray<T>::TArray( uint_4 ndim, const uint_4 * siz, NDataBlock<T> & db, bool share, uint_4 step, uint_8offset)79 TArray<T>::TArray(int_4 ndim, const sa_size_t * siz, NDataBlock<T> & db, bool share, sa_size_t step, sa_size_t offset) 80 80 : BaseArray() , mNDBlock(db, share) 81 81 { 82 string exmsg = "TArray<T>::TArray( uint_4, uint_4*, NDataBlock<T> & ... )";82 string exmsg = "TArray<T>::TArray(int_4, sa_size_t *, NDataBlock<T> & ... )"; 83 83 if (!UpdateSizes(ndim, siz, step, offset, exmsg)) throw( ParmError(exmsg) ); 84 84 … … 97 97 */ 98 98 template <class T> 99 TArray<T>::TArray( uint_4 ndim, const uint_4 * siz, T* values, uint_4 step, uint_8offset, Bridge* br)99 TArray<T>::TArray(int_4 ndim, const sa_size_t * siz, T* values, sa_size_t step, sa_size_t offset, Bridge* br) 100 100 : BaseArray() , mNDBlock(ComputeTotalSize(ndim, siz, step, 1), values, br) 101 101 { 102 string exmsg = "TArray<T>::TArray( uint_4, uint_4*, T* ... )";102 string exmsg = "TArray<T>::TArray(int_4, sa_size_t *, T* ... )"; 103 103 if (!UpdateSizes(ndim, siz, step, offset, exmsg)) throw( ParmError(exmsg) ); 104 104 } … … 225 225 */ 226 226 template <class T> 227 void TArray<T>::ReSize( uint_4 ndim, uint_4 * siz, uint_4step)227 void TArray<T>::ReSize(int_4 ndim, sa_size_t * siz, sa_size_t step) 228 228 { 229 229 if (arrtype_ != 0) { … … 247 247 */ 248 248 template <class T> 249 void TArray<T>::Realloc( uint_4 ndim, uint_4 * siz, uint_4step, bool force)249 void TArray<T>::Realloc(int_4 ndim, sa_size_t * siz, sa_size_t step, bool force) 250 250 { 251 251 if (arrtype_ != 0) { … … 279 279 //! Give value (in \b double) for element at position \b ip.. 280 280 template <class T> 281 MuTyV & TArray<T>::ValueAtPosition( uint_8ip) const281 MuTyV & TArray<T>::ValueAtPosition(sa_size_t ip) const 282 282 { 283 283 #ifdef SO_BOUNDCHECKING 284 if (ip >= totsize_) throw( ParmError("TArray<T>::ValueAtPosition( uint_8ip) Out-of-bound Error") );284 if (ip >= totsize_) throw( ParmError("TArray<T>::ValueAtPosition(sa_size_t ip) Out-of-bound Error") ); 285 285 #endif 286 286 my_mtv = *(mNDBlock.Begin()+Offset(ip)); … … 326 326 if (NbDimensions() < 1) 327 327 throw RangeCheckError("TArray<T>::operator () (Range, ...) - Not Allocated Array ! "); 328 uint_4 ndim = 0;329 uint_4size[BASEARRAY_MAXNDIMS];330 uint_4step[BASEARRAY_MAXNDIMS];331 uint_4pos[BASEARRAY_MAXNDIMS];328 int_4 ndim = 0; 329 sa_size_t size[BASEARRAY_MAXNDIMS]; 330 sa_size_t step[BASEARRAY_MAXNDIMS]; 331 sa_size_t pos[BASEARRAY_MAXNDIMS]; 332 332 size[0] = rx.Size(); 333 333 size[1] = ry.Size(); … … 373 373 374 374 T * pe; 375 uint_8j,k;376 int ka;375 sa_size_t j,k; 376 int_4 ka; 377 377 if (arrtype_ == 0) ka = 0; 378 378 else ka = macoli_; 379 uint_8step = Step(ka);380 uint_8gpas = Size(ka);381 uint_8naxa = Size()/Size(ka);379 sa_size_t step = Step(ka); 380 sa_size_t gpas = Size(ka); 381 sa_size_t naxa = Size()/Size(ka); 382 382 for(j=0; j<naxa; j++) { 383 383 pe = mNDBlock.Begin()+Offset(ka,j); … … 401 401 throw RangeCheckError("TArray<T>::SetT(T ) - Not Allocated Array ! "); 402 402 T * pe; 403 uint_8j,k;403 sa_size_t j,k; 404 404 if (AvgStep() > 0) { // regularly spaced elements 405 uint_8step = AvgStep();406 uint_8maxx = totsize_*step;405 sa_size_t step = AvgStep(); 406 sa_size_t maxx = totsize_*step; 407 407 pe = Data(); 408 408 for(k=0; k<maxx; k+=step ) pe[k] = x; 409 409 } 410 410 else { // Non regular data spacing ... 411 uint_4 ka = MaxSizeKA();412 uint_8step = Step(ka);413 uint_8gpas = Size(ka)*step;414 uint_8naxa = Size()/Size(ka);411 int_4 ka = MaxSizeKA(); 412 sa_size_t step = Step(ka); 413 sa_size_t gpas = Size(ka)*step; 414 sa_size_t naxa = Size()/Size(ka); 415 415 for(j=0; j<naxa; j++) { 416 416 pe = mNDBlock.Begin()+Offset(ka,j); … … 428 428 throw RangeCheckError("TArray<T>::Add(T ) - Not Allocated Array ! "); 429 429 T * pe; 430 uint_8j,k;430 sa_size_t j,k; 431 431 if (AvgStep() > 0) { // regularly spaced elements 432 uint_8step = AvgStep();433 uint_8maxx = totsize_*step;432 sa_size_t step = AvgStep(); 433 sa_size_t maxx = totsize_*step; 434 434 pe = Data(); 435 435 for(k=0; k<maxx; k+=step ) pe[k] += x; 436 436 } 437 437 else { // Non regular data spacing ... 438 uint_4 ka = MaxSizeKA();439 uint_8step = Step(ka);440 uint_8gpas = Size(ka)*step;441 uint_8naxa = Size()/Size(ka);438 int_4 ka = MaxSizeKA(); 439 sa_size_t step = Step(ka); 440 sa_size_t gpas = Size(ka)*step; 441 sa_size_t naxa = Size()/Size(ka); 442 442 for(j=0; j<naxa; j++) { 443 443 pe = mNDBlock.Begin()+Offset(ka,j); … … 459 459 throw RangeCheckError("TArray<T>::Sub(T ) - Not Allocated Array ! "); 460 460 T * pe; 461 uint_8j,k;461 sa_size_t j,k; 462 462 if (AvgStep() > 0) { // regularly spaced elements 463 uint_8step = AvgStep();464 uint_8maxx = totsize_*step;463 sa_size_t step = AvgStep(); 464 sa_size_t maxx = totsize_*step; 465 465 pe = Data(); 466 466 if (fginv) … … 470 470 } 471 471 else { // Non regular data spacing ... 472 uint_4 ka = MaxSizeKA();473 uint_8step = Step(ka);474 uint_8gpas = Size(ka)*step;475 uint_8naxa = Size()/Size(ka);472 int_4 ka = MaxSizeKA(); 473 sa_size_t step = Step(ka); 474 sa_size_t gpas = Size(ka)*step; 475 sa_size_t naxa = Size()/Size(ka); 476 476 for(j=0; j<naxa; j++) { 477 477 pe = mNDBlock.Begin()+Offset(ka,j); … … 492 492 throw RangeCheckError("TArray<T>::Mul(T ) - Not Allocated Array ! "); 493 493 T * pe; 494 uint_8j,k;494 sa_size_t j,k; 495 495 if (AvgStep() > 0) { // regularly spaced elements 496 uint_8step = AvgStep();497 uint_8maxx = totsize_*step;496 sa_size_t step = AvgStep(); 497 sa_size_t maxx = totsize_*step; 498 498 pe = Data(); 499 499 for(k=0; k<maxx; k+=step ) pe[k] *= x; 500 500 } 501 501 else { // Non regular data spacing ... 502 uint_4 ka = MaxSizeKA();503 uint_8step = Step(ka);504 uint_8gpas = Size(ka)*step;505 uint_8naxa = Size()/Size(ka);502 int_4 ka = MaxSizeKA(); 503 sa_size_t step = Step(ka); 504 sa_size_t gpas = Size(ka)*step; 505 sa_size_t naxa = Size()/Size(ka); 506 506 for(j=0; j<naxa; j++) { 507 507 pe = mNDBlock.Begin()+Offset(ka,j); … … 525 525 throw MathExc("TArray<T>::Div(T ) - Divide by zero ! "); 526 526 T * pe; 527 uint_8j,k;527 sa_size_t j,k; 528 528 if (AvgStep() > 0) { // regularly spaced elements 529 uint_8step = AvgStep();530 uint_8maxx = totsize_*step;529 sa_size_t step = AvgStep(); 530 sa_size_t maxx = totsize_*step; 531 531 pe = Data(); 532 532 if (fginv) … … 536 536 } 537 537 else { // Non regular data spacing ... 538 uint_4 ka = MaxSizeKA();539 uint_8step = Step(ka);540 uint_8gpas = Size(ka)*step;541 uint_8naxa = Size()/Size(ka);538 int_4 ka = MaxSizeKA(); 539 sa_size_t step = Step(ka); 540 sa_size_t gpas = Size(ka)*step; 541 sa_size_t naxa = Size()/Size(ka); 542 542 for(j=0; j<naxa; j++) { 543 543 pe = mNDBlock.Begin()+Offset(ka,j); … … 552 552 553 553 554 554 //! Replace array elements values by their opposite ( a(i) -> -a(i) ) 555 template <class T> 556 TArray<T>& TArray<T>::NegateElt() 557 { 558 if (NbDimensions() < 1) 559 throw RangeCheckError("TArray<T>::NegateElt() - Not Allocated Array ! "); 560 T * pe; 561 sa_size_t j,k; 562 if (AvgStep() > 0) { // regularly spaced elements 563 sa_size_t step = AvgStep(); 564 sa_size_t maxx = totsize_*step; 565 pe = Data(); 566 for(k=0; k<maxx; k+=step ) pe[k] = -pe[k]; 567 } 568 else { // Non regular data spacing ... 569 int_4 ka = MaxSizeKA(); 570 sa_size_t step = Step(ka); 571 sa_size_t gpas = Size(ka)*step; 572 sa_size_t naxa = Size()/Size(ka); 573 for(j=0; j<naxa; j++) { 574 pe = mNDBlock.Begin()+Offset(ka,j); 575 for(k=0; k<gpas; k+=step) pe[k] = -pe[k]; 576 } 577 } 578 return(*this); 579 } 555 580 556 581 // >>>> Operations avec 2nd membre de type tableau … … 567 592 T * pe; 568 593 const T * pea; 569 uint_8j,k,ka;594 sa_size_t j,k,ka; 570 595 if (smo && (AvgStep() > 0) && (a.AvgStep() > 0)) { // regularly spaced elements 571 uint_8step = AvgStep();572 uint_8stepa = a.AvgStep();573 uint_8maxx = totsize_*step;596 sa_size_t step = AvgStep(); 597 sa_size_t stepa = a.AvgStep(); 598 sa_size_t maxx = totsize_*step; 574 599 pe = Data(); 575 600 pea = a.Data(); … … 577 602 } 578 603 else { // Non regular data spacing ... 579 int ax,axa;580 uint_8step, stepa;581 uint_8gpas, naxa;604 int_4 ax,axa; 605 sa_size_t step, stepa; 606 sa_size_t gpas, naxa; 582 607 GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa); 583 608 for(j=0; j<naxa; j++) { … … 606 631 T * pe; 607 632 const T * pea; 608 uint_8j,k,ka;633 sa_size_t j,k,ka; 609 634 if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) ) { // regularly spaced elements 610 uint_8step = AvgStep();611 uint_8stepa = a.AvgStep();612 uint_8maxx = totsize_*step;635 sa_size_t step = AvgStep(); 636 sa_size_t stepa = a.AvgStep(); 637 sa_size_t maxx = totsize_*step; 613 638 pe = Data(); 614 639 pea = a.Data(); … … 619 644 } 620 645 else { // Non regular data spacing ... 621 int ax,axa;622 uint_8step, stepa;623 uint_8gpas, naxa;646 int_4 ax,axa; 647 sa_size_t step, stepa; 648 sa_size_t gpas, naxa; 624 649 GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa); 625 650 for(j=0; j<naxa; j++) { … … 648 673 T * pe; 649 674 const T * pea; 650 uint_8j,k,ka;675 sa_size_t j,k,ka; 651 676 if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) ) { // regularly spaced elements 652 uint_8step = AvgStep();653 uint_8stepa = a.AvgStep();654 uint_8maxx = totsize_*step;677 sa_size_t step = AvgStep(); 678 sa_size_t stepa = a.AvgStep(); 679 sa_size_t maxx = totsize_*step; 655 680 pe = Data(); 656 681 pea = a.Data(); … … 658 683 } 659 684 else { // Non regular data spacing ... 660 int ax,axa;661 uint_8step, stepa;662 uint_8gpas, naxa;685 int_4 ax,axa; 686 sa_size_t step, stepa; 687 sa_size_t gpas, naxa; 663 688 GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa); 664 689 for(j=0; j<naxa; j++) { … … 689 714 T * pe; 690 715 const T * pea; 691 uint_8j,k,ka;716 sa_size_t j,k,ka; 692 717 if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) ) { // regularly spaced elements 693 uint_8step = AvgStep();694 uint_8stepa = a.AvgStep();695 uint_8maxx = totsize_*step;718 sa_size_t step = AvgStep(); 719 sa_size_t stepa = a.AvgStep(); 720 sa_size_t maxx = totsize_*step; 696 721 pe = Data(); 697 722 pea = a.Data(); … … 711 736 } 712 737 else { // Non regular data spacing ... 713 int ax,axa;714 uint_8step, stepa;715 uint_8gpas, naxa;738 int_4 ax,axa; 739 sa_size_t step, stepa; 740 sa_size_t gpas, naxa; 716 741 GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa); 717 742 for(j=0; j<naxa; j++) { … … 748 773 T * pe; 749 774 const T * pea; 750 uint_8j,k,ka;775 sa_size_t j,k,ka; 751 776 if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) ) { // regularly spaced elements 752 uint_8step = AvgStep();753 uint_8stepa = a.AvgStep();754 uint_8maxx = totsize_*step;777 sa_size_t step = AvgStep(); 778 sa_size_t stepa = a.AvgStep(); 779 sa_size_t maxx = totsize_*step; 755 780 pe = Data(); 756 781 pea = a.Data(); … … 758 783 } 759 784 else { // Non regular data spacing ... 760 int ax,axa;761 uint_8step, stepa;762 uint_8gpas, naxa;785 int_4 ax,axa; 786 sa_size_t step, stepa; 787 sa_size_t gpas, naxa; 763 788 GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa); 764 789 for(j=0; j<naxa; j++) { … … 782 807 783 808 T * pe; 784 uint_8j,k,ka;785 uint_8offa;809 sa_size_t j,k,ka; 810 sa_size_t offa; 786 811 // Non regular data spacing ... 787 int ax,axa;788 uint_8step, stepa;789 uint_8gpas, naxa;812 int_4 ax,axa; 813 sa_size_t step, stepa; 814 sa_size_t gpas, naxa; 790 815 GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa); 791 816 for(j=0; j<naxa; j++) { … … 812 837 T ret=0; 813 838 const T * pe; 814 uint_8j,k;839 sa_size_t j,k; 815 840 if (AvgStep() > 0) { // regularly spaced elements 816 uint_8step = AvgStep();817 uint_8maxx = totsize_*step;841 sa_size_t step = AvgStep(); 842 sa_size_t maxx = totsize_*step; 818 843 pe = Data(); 819 844 for(k=0; k<maxx; k+=step ) ret += pe[k]; 820 845 } 821 846 else { // Non regular data spacing ... 822 uint_4 ka = MaxSizeKA();823 uint_8step = Step(ka);824 uint_8gpas = Size(ka)*step;825 uint_8naxa = Size()/Size(ka);847 int_4 ka = MaxSizeKA(); 848 sa_size_t step = Step(ka); 849 sa_size_t gpas = Size(ka)*step; 850 sa_size_t naxa = Size()/Size(ka); 826 851 for(j=0; j<naxa; j++) { 827 852 pe = mNDBlock.Begin()+Offset(ka,j); … … 840 865 T ret=(T)1; 841 866 const T * pe; 842 uint_8j,k;867 sa_size_t j,k; 843 868 if (AvgStep() > 0) { // regularly spaced elements 844 uint_8step = AvgStep();845 uint_8maxx = totsize_*step;869 sa_size_t step = AvgStep(); 870 sa_size_t maxx = totsize_*step; 846 871 pe = Data(); 847 872 for(k=0; k<maxx; k+=step ) ret *= pe[k]; 848 873 } 849 874 else { // Non regular data spacing ... 850 uint_4 ka = MaxSizeKA();851 uint_8step = Step(ka);852 uint_8gpas = Size(ka)*step;853 uint_8naxa = Size()/Size(ka);875 int_4 ka = MaxSizeKA(); 876 sa_size_t step = Step(ka); 877 sa_size_t gpas = Size(ka)*step; 878 sa_size_t naxa = Size()/Size(ka); 854 879 for(j=0; j<naxa; j++) { 855 880 pe = mNDBlock.Begin()+Offset(ka,j); … … 868 893 T ret=0; 869 894 const T * pe; 870 uint_8j,k;895 sa_size_t j,k; 871 896 if (AvgStep() > 0) { // regularly spaced elements 872 uint_8step = AvgStep();873 uint_8maxx = totsize_*step;897 sa_size_t step = AvgStep(); 898 sa_size_t maxx = totsize_*step; 874 899 pe = Data(); 875 900 for(k=0; k<maxx; k+=step ) ret += pe[k]*pe[k]; 876 901 } 877 902 else { // Non regular data spacing ... 878 uint_4 ka = MaxSizeKA();879 uint_8step = Step(ka);880 uint_8gpas = Size(ka)*step;881 uint_8naxa = Size()/Size(ka);903 int_4 ka = MaxSizeKA(); 904 sa_size_t step = Step(ka); 905 sa_size_t gpas = Size(ka)*step; 906 sa_size_t naxa = Size()/Size(ka); 882 907 for(j=0; j<naxa; j++) { 883 908 pe = mNDBlock.Begin()+Offset(ka,j); … … 896 921 { 897 922 const T * pe; 898 uint_8j,k;899 uint_4 ka = MaxSizeKA();900 uint_8step = Step(ka);901 uint_8gpas = Size(ka)*step;902 uint_8naxa = Size()/Size(ka);923 sa_size_t j,k; 924 int_4 ka = MaxSizeKA(); 925 sa_size_t step = Step(ka); 926 sa_size_t gpas = Size(ka)*step; 927 sa_size_t naxa = Size()/Size(ka); 903 928 min = (*this)[0]; 904 929 max = (*this)[0]; … … 948 973 { 949 974 if (maxprt < 0) maxprt = max_nprt_; 950 uint_4npr = 0;975 sa_size_t npr = 0; 951 976 Show(os, si); 952 977 if (ndim_ < 1) return; 953 uint_4k0,k1,k2,k3,k4;978 sa_size_t k0,k1,k2,k3,k4; 954 979 for(k4=0; k4<size_[4]; k4++) { 955 980 if (size_[4] > 1) cout << "\n ----- Dimension 5 (U) K4= " << k4 << endl; … … 963 988 if(k0 > 0) os << ", "; 964 989 os << Elem(k0, k1, k2, k3, k4); npr++; 965 if (npr >= ( uint_4) maxprt) {990 if (npr >= (sa_size_t) maxprt) { 966 991 if (npr < totsize_) os << "\n .... " << endl; return; 967 992 } -
trunk/SophyaLib/TArray/tarray.h
r1113 r1156 29 29 // Creation / destruction 30 30 TArray(); 31 TArray( uint_4 ndim, const uint_4 * siz, uint_4step =1);32 TArray( uint_4 nx, uint_4 ny=0, uint_4 nz=0, uint_4 nt=0, uint_4nu=0);33 TArray( uint_4 ndim, const uint_4 * siz, NDataBlock<T> & db, bool share=false, uint_4 step=1, uint_8offset=0);34 TArray( uint_4 ndim, const uint_4 * siz, T* values, uint_4 step=1, uint_8offset=0, Bridge* br=NULL);31 TArray(int_4 ndim, const sa_size_t * siz, sa_size_t step =1); 32 TArray(sa_size_t nx, sa_size_t ny=0, sa_size_t nz=0, sa_size_t nt=0, sa_size_t nu=0); 33 TArray(int_4 ndim, const sa_size_t * siz, NDataBlock<T> & db, bool share=false, sa_size_t step=1, sa_size_t offset=0); 34 TArray(int_4 ndim, const sa_size_t * siz, T* values, sa_size_t step=1, sa_size_t offset=0, Bridge* br=NULL); 35 35 TArray(const TArray<T>& a); 36 36 TArray(const TArray<T>& a, bool share); … … 57 57 58 58 void Share(const TArray<T>& a); 59 void ReSize( uint_4 ndim, uint_4 * siz, uint_4step=1);60 void Realloc( uint_4 ndim, uint_4 * siz, uint_4step=1, bool force=false);59 void ReSize(int_4 ndim, sa_size_t * siz, sa_size_t step=1); 60 void Realloc(int_4 ndim, sa_size_t * siz, sa_size_t step=1, bool force=false); 61 61 62 62 // Compacts size=1 array dimensions … … 88 88 // ---- Access to data 89 89 // Definition of virtual element acces method inherited from BaseArray class 90 virtual MuTyV & ValueAtPosition( uint_8ip) const;90 virtual MuTyV & ValueAtPosition(sa_size_t ip) const; 91 91 92 92 // Data Access: operator overloaded inline acces methods 93 inline T const& operator()( uint_4 ix, uint_4 iy, uint_4iz) const ;94 inline T& operator()( uint_4 ix, uint_4 iy, uint_4iz);95 inline T const& operator()( uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4iu=0) const ;96 inline T& operator()( uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4iu=0);97 inline T const& operator[]( uint_8ip) const ;98 inline T& operator[]( uint_8ip);99 100 inline T const& Elem( uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it=0, uint_4iu=0) const ;101 inline T& Elem( uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it=0, uint_4iu=0);102 inline T const& ElemCheckBound( uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it=0, uint_4iu=0) const ;103 inline T& ElemCheckBound( uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it=0, uint_4iu=0);93 inline T const& operator()(sa_size_t ix, sa_size_t iy, sa_size_t iz) const ; 94 inline T& operator()(sa_size_t ix, sa_size_t iy, sa_size_t iz); 95 inline T const& operator()(sa_size_t ix, sa_size_t iy, sa_size_t iz, sa_size_t it, sa_size_t iu=0) const ; 96 inline T& operator()(sa_size_t ix, sa_size_t iy, sa_size_t iz, sa_size_t it, sa_size_t iu=0); 97 inline T const& operator[](sa_size_t ip) const ; 98 inline T& operator[](sa_size_t ip); 99 100 inline T const& Elem(sa_size_t ix, sa_size_t iy, sa_size_t iz, sa_size_t it=0, sa_size_t iu=0) const ; 101 inline T& Elem(sa_size_t ix, sa_size_t iy, sa_size_t iz, sa_size_t it=0, sa_size_t iu=0); 102 inline T const& ElemCheckBound(sa_size_t ix, sa_size_t iy, sa_size_t iz, sa_size_t it=0, sa_size_t iu=0) const ; 103 inline T& ElemCheckBound(sa_size_t ix, sa_size_t iy, sa_size_t iz, sa_size_t it=0, sa_size_t iu=0); 104 104 105 105 //! Return pointer to first element adress … … 143 143 inline TArray<T>& operator /= (T x) { return Div(x); } 144 144 145 // applique le signe moins a tous les elements 146 virtual TArray<T>& NegateElt(); 147 145 148 // A += -= (ajoute, soustrait element par element les deux tableaux ) 146 149 virtual TArray<T>& AddElt(const TArray<T>& a); … … 238 241 239 242 //////////////////////////////////////////////////////////////// 243 // Surcharge d'operateurs B = -A 244 245 /*! \ingroup TArray \fn operator - (const TArray<T>&) 246 \brief Operator - Returns an array with elements equal to the opposite of 247 the original array elements. */ 248 template <class T> inline TArray<T> operator - (const TArray<T>& a) 249 {TArray<T> result; result.CloneOrShare(a); result.SetTemp(true); 250 result.NegateElt(); return result;} 251 252 //////////////////////////////////////////////////////////////// 240 253 // Surcharge d'operateurs C = A (+,-) B 241 254 … … 265 278 //! Return element (ix,iy,iz,it,iu) value 266 279 template <class T> 267 inline T const& TArray<T>::Elem( uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4iu) const280 inline T const& TArray<T>::Elem(sa_size_t ix, sa_size_t iy, sa_size_t iz, sa_size_t it, sa_size_t iu) const 268 281 { 269 282 return ( *( mNDBlock.Begin()+ offset_+ … … 274 287 //! Return element (ix,iy,iz,it,iu) value 275 288 template <class T> 276 inline T & TArray<T>::Elem( uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4iu)289 inline T & TArray<T>::Elem(sa_size_t ix, sa_size_t iy, sa_size_t iz, sa_size_t it, sa_size_t iu) 277 290 { 278 291 return ( *( mNDBlock.Begin()+ offset_+ … … 283 296 //! Return element (ix,iy,iz,it,iu) value with Check of indexes bound first 284 297 template <class T> 285 inline T const& TArray<T>::ElemCheckBound( uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4iu) const298 inline T const& TArray<T>::ElemCheckBound(sa_size_t ix, sa_size_t iy, sa_size_t iz, sa_size_t it, sa_size_t iu) const 286 299 { 287 300 CheckBound(ix, iy, iz, it, iu, 4); … … 291 304 //! Return element (ix,iy,iz,it,iu) value with Check of indexes bound first 292 305 template <class T> 293 inline T & TArray<T>::ElemCheckBound( uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4iu)306 inline T & TArray<T>::ElemCheckBound(sa_size_t ix, sa_size_t iy, sa_size_t iz, sa_size_t it, sa_size_t iu) 294 307 { 295 308 CheckBound(ix, iy, iz, it, iu, 4); … … 299 312 //! Return element (ix,iy,iz) value 300 313 template <class T> 301 inline T const& TArray<T>::operator()( uint_4 ix, uint_4 iy, uint_4iz) const314 inline T const& TArray<T>::operator()(sa_size_t ix, sa_size_t iy, sa_size_t iz) const 302 315 { 303 316 #ifdef SO_BOUNDCHECKING … … 310 323 //! Return element (ix,iy,iz) value 311 324 template <class T> 312 inline T & TArray<T>::operator()( uint_4 ix, uint_4 iy, uint_4iz)325 inline T & TArray<T>::operator()(sa_size_t ix, sa_size_t iy, sa_size_t iz) 313 326 { 314 327 #ifdef SO_BOUNDCHECKING … … 321 334 //! Operator () : return element (ix,iy,iz,it,iu) value 322 335 template <class T> 323 inline T const& TArray<T>::operator()( uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4iu) const336 inline T const& TArray<T>::operator()(sa_size_t ix, sa_size_t iy, sa_size_t iz, sa_size_t it, sa_size_t iu) const 324 337 { 325 338 #ifdef SO_BOUNDCHECKING … … 333 346 //! Operator () : return element (ix,iy,iz,it,iu) value 334 347 template <class T> 335 inline T & TArray<T>::operator()( uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4iu)348 inline T & TArray<T>::operator()(sa_size_t ix, sa_size_t iy, sa_size_t iz, sa_size_t it, sa_size_t iu) 336 349 { 337 350 #ifdef SO_BOUNDCHECKING … … 346 359 //! Operator [] : return element at positon ip 347 360 template <class T> 348 inline T const& TArray<T>::operator[]( uint_8ip) const361 inline T const& TArray<T>::operator[](sa_size_t ip) const 349 362 { 350 363 #ifdef SO_BOUNDCHECKING … … 356 369 //! Operator [] : return element at positon ip 357 370 template <class T> 358 inline T & TArray<T>::operator[]( uint_8ip)371 inline T & TArray<T>::operator[](sa_size_t ip) 359 372 { 360 373 #ifdef SO_BOUNDCHECKING … … 365 378 366 379 367 //! Return the value of first element380 //! Converts to a scalar (value of first element) if the array size is equal to 1 368 381 template <class T> 369 382 inline T TArray<T>::toScalar() -
trunk/SophyaLib/TArray/tmatrix.cc
r1103 r1156 1 // $Id: tmatrix.cc,v 1.1 5 2000-07-27 00:00:09ansari Exp $1 // $Id: tmatrix.cc,v 1.16 2000-08-29 16:10:30 ansari Exp $ 2 2 // C.Magneville 04/99 3 3 #include "machdefs.h" … … 33 33 */ 34 34 template <class T> 35 TMatrix<T>::TMatrix( uint_4 r,uint_4c, short mm)35 TMatrix<T>::TMatrix(sa_size_t r,sa_size_t c, short mm) 36 36 // Construit une matrice de r lignes et c colonnes. 37 37 : TArray<T>() 38 38 { 39 39 if ( (r == 0) || (c == 0) ) 40 throw ParmError("TMatrix<T>::TMatrix( uint_4 r,uint_4c) NRows or NCols = 0");40 throw ParmError("TMatrix<T>::TMatrix(sa_size_t r,sa_size_t c) NRows or NCols = 0"); 41 41 arrtype_ = 1; // Type = Matrix 42 42 ReSize(r, c, mm); … … 175 175 */ 176 176 template <class T> 177 void TMatrix<T>::ReSize( uint_4 r, uint_4c, short mm)177 void TMatrix<T>::ReSize(sa_size_t r, sa_size_t c, short mm) 178 178 { 179 179 if(r==0||c==0) … … 181 181 if ((arrtype_ == 2) && (r > 1) && (c > 1)) 182 182 throw(SzMismatchError("TMatrix::ReSize r>1&&c>1 for Vector ")); 183 uint_4size[BASEARRAY_MAXNDIMS];184 for(int kk=0; kk<BASEARRAY_MAXNDIMS; kk++) size[kk] = 0;183 sa_size_t size[BASEARRAY_MAXNDIMS]; 184 for(int_4 kk=0; kk<BASEARRAY_MAXNDIMS; kk++) size[kk] = 0; 185 185 if (mm == SameMemoryMapping) mm = GetMemoryMapping(); 186 186 else if ( (mm != CMemoryMapping) && (mm != FortranMemoryMapping) ) … … 206 206 */ 207 207 template <class T> 208 void TMatrix<T>::Realloc( uint_4 r,uint_4c, short mm, bool force)208 void TMatrix<T>::Realloc(sa_size_t r,sa_size_t c, short mm, bool force) 209 209 { 210 210 if(r==0||c==0) … … 212 212 if ((arrtype_ == 2) && (r > 1) && (c > 1)) 213 213 throw(SzMismatchError("TMatrix::Realloc r>1&&c>1 for Vector ")); 214 uint_4size[BASEARRAY_MAXNDIMS];215 for(int kk=0; kk<BASEARRAY_MAXNDIMS; kk++) size[kk] = 0;214 sa_size_t size[BASEARRAY_MAXNDIMS]; 215 for(int_4 kk=0; kk<BASEARRAY_MAXNDIMS; kk++) size[kk] = 0; 216 216 if (mm == SameMemoryMapping) mm = GetMemoryMapping(); 217 217 else if ( (mm != CMemoryMapping) && (mm != FortranMemoryMapping) ) … … 249 249 { 250 250 short vt = (marowi_ == veceli_) ? ColumnVector : RowVector; 251 uint_4 rci = macoli_;251 int_4 rci = macoli_; 252 252 macoli_ = marowi_; 253 253 marowi_ = rci; … … 268 268 if (mm == SameMemoryMapping) mm = GetMemoryMapping(); 269 269 TMatrix<T> tm(NCols(), NRows(), mm); 270 for( uint_4i=0; i<NRows(); i++)271 for( uint_4j=0; j<NCols(); j++)270 for(sa_size_t i=0; i<NRows(); i++) 271 for(sa_size_t j=0; j<NCols(); j++) 272 272 tm(j,i) = (*this)(i,j); 273 273 tm.SetTemp(true); … … 292 292 293 293 TMatrix<T> tm(NRows(), NCols(), mm); 294 for( uint_4i=0; i<NRows(); i++)295 for( uint_4j=0; j<NCols(); j++)294 for(sa_size_t i=0; i<NRows(); i++) 295 for(sa_size_t j=0; j<NCols(); j++) 296 296 tm(i,j) = (*this)(i,j); 297 297 tm.SetTemp(true); … … 304 304 { 305 305 if (ndim_ == 0) { 306 uint_4sz = imx.Size();306 sa_size_t sz = imx.Size(); 307 307 if (sz < 1) sz = 1; 308 308 ReSize(sz, sz); … … 312 312 throw SzMismatchError("TMatrix::operator= (IdentityMatrix) NRows() != NCols()") ; 313 313 *this = (T) 0; 314 for( uint_4i=0; i<NRows(); i++) (*this)(i,i) = diag;314 for(sa_size_t i=0; i<NRows(); i++) (*this)(i,i) = diag; 315 315 316 316 return (*this); … … 343 343 { 344 344 if (maxprt < 0) maxprt = max_nprt_; 345 uint_4npr = 0;345 sa_size_t npr = 0; 346 346 Show(os, si); 347 347 if (ndim_ < 1) return; 348 uint_4kc,kr;348 sa_size_t kc,kr; 349 349 for(kr=0; kr<size_[marowi_]; kr++) { 350 350 if ( (size_[marowi_] > 1) && (size_[macoli_] > 10) ) cout << "----- Ligne Line= " << kr << endl; … … 352 352 if(kc > 0) os << ", "; 353 353 os << (*this)(kr, kc); npr++; 354 if (npr >= ( uint_4) maxprt) {354 if (npr >= (sa_size_t) maxprt) { 355 355 if (npr < totsize_) os << "\n .... " << endl; return; 356 356 } … … 380 380 const T * peb; 381 381 T sum; 382 uint_4r,c,k;383 uint_4stepa = Step(ColsKA());384 uint_4stepb = b.Step(RowsKA());382 sa_size_t r,c,k; 383 sa_size_t stepa = Step(ColsKA()); 384 sa_size_t stepb = b.Step(RowsKA()); 385 385 // Calcul de C=rm = A*B (A=*this) 386 386 for(r=0; r<rm.NRows(); r++) // Boucle sur les lignes de A -
trunk/SophyaLib/TArray/tmatrix.h
r1103 r1156 15 15 // Creation / destruction 16 16 TMatrix(); 17 TMatrix( uint_4 r,uint_4c, short mm=BaseArray::AutoMemoryMapping);17 TMatrix(sa_size_t r,sa_size_t c, short mm=BaseArray::AutoMemoryMapping); 18 18 TMatrix(const TMatrix<T>& a); 19 19 TMatrix(const TMatrix<T>& a, bool share); … … 42 42 // Size - Changing the Size 43 43 //! return number of rows 44 inline uint_4NRows() const {return Size(marowi_); }44 inline sa_size_t NRows() const {return Size(marowi_); } 45 45 //! return number of columns 46 inline uint_4NCols() const {return Size(macoli_); }46 inline sa_size_t NCols() const {return Size(macoli_); } 47 47 //! return number of columns 48 inline uint_4NCol() const {return Size(macoli_); } // back-compat Peida49 50 void ReSize( uint_4 r,uint_4c, short mm=BaseArray::SameMemoryMapping); // Reallocation de place51 void Realloc( uint_4 r,uint_4c, short mm=BaseArray::SameMemoryMapping, bool force=false);48 inline sa_size_t NCol() const {return Size(macoli_); } // back-compat Peida 49 50 void ReSize(sa_size_t r,sa_size_t c, short mm=BaseArray::SameMemoryMapping); // Reallocation de place 51 void Realloc(sa_size_t r,sa_size_t c, short mm=BaseArray::SameMemoryMapping, bool force=false); 52 52 53 53 // Sub-matrix extraction $CHECK$ Reza 03/2000 Doit-on declarer ces methode const ? … … 58 58 // Lignes et colonnes de la matrice 59 59 //! Return submatrix define by line \b ir (line vector) 60 inline TMatrix<T> Row( uint_4ir) const60 inline TMatrix<T> Row(sa_size_t ir) const 61 61 { return SubMatrix(Range(ir,ir), Range(0,NCols()-1)); } 62 62 //! Return submatrix define by column \b ic (column vector) 63 inline TMatrix<T> Column( uint_4ic) const63 inline TMatrix<T> Column(sa_size_t ic) const 64 64 { return SubMatrix(Range(0,NRows()-1), Range(ic,ic)); } 65 65 66 66 // Inline element acces methods 67 inline T const& operator()( uint_4 r,uint_4c) const;68 inline T& operator()( uint_4 r,uint_4c);67 inline T const& operator()(sa_size_t r,sa_size_t c) const; 68 inline T& operator()(sa_size_t r,sa_size_t c); 69 69 70 70 // Operations matricielles … … 116 116 //! () : return element for line \b r and column \b c 117 117 template <class T> 118 inline T const& TMatrix<T>::operator()( uint_4 r, uint_4c) const118 inline T const& TMatrix<T>::operator()(sa_size_t r, sa_size_t c) const 119 119 { 120 120 #ifdef SO_BOUNDCHECKING … … 128 128 //! () : return element for line \b r and column \b c 129 129 template <class T> 130 inline T & TMatrix<T>::operator()( uint_4 r, uint_4c)130 inline T & TMatrix<T>::operator()(sa_size_t r, sa_size_t c) 131 131 { 132 132 #ifdef SO_BOUNDCHECKING … … 188 188 result.Div(b, true); return result;} 189 189 190 //////////////////////////////////////////////////////////////// 191 // Surcharge d'operateurs B = -A 192 193 /*! \ingroup TMatrix \fn operator - (const TMatrix<T>&) 194 \brief Operator - Returns a matrix with elements equal to the opposite of 195 the original matrix elements. */ 196 template <class T> inline TMatrix<T> operator - (const TMatrix<T>& a) 197 {TMatrix<T> result; result.CloneOrShare(a); result.SetTemp(true); 198 result.NegateElt(); return result;} 199 190 200 191 201 // Surcharge d'operateurs C = A (+,-) B -
trunk/SophyaLib/TArray/tvector.cc
r1103 r1156 1 // $Id: tvector.cc,v 1.1 0 2000-07-27 00:00:10ansari Exp $1 // $Id: tvector.cc,v 1.11 2000-08-29 16:10:31 ansari Exp $ 2 2 // C.Magneville 04/99 3 3 #include "machdefs.h" … … 31 31 */ 32 32 template <class T> 33 TVector<T>::TVector( uint_4n, short lcv, short mm)33 TVector<T>::TVector(sa_size_t n, short lcv, short mm) 34 34 // Constructeur 35 35 : TMatrix<T>(1,1,mm) … … 121 121 */ 122 122 template <class T> 123 void TVector<T>::ReSize( uint_4n, short lcv)123 void TVector<T>::ReSize(sa_size_t n, short lcv) 124 124 { 125 125 if( n == 0 ) 126 126 throw(SzMismatchError("TVector::ReSize() n = 0 ")); 127 uint_4r,c;127 sa_size_t r,c; 128 128 if (lcv == SameVectorType) lcv = GetVectorType(); 129 129 else if ( (lcv != ColumnVector) && (lcv != RowVector) ) lcv = GetDefaultVectorType(); … … 143 143 */ 144 144 template <class T> 145 void TVector<T>::Realloc( uint_4n, short lcv, bool force)145 void TVector<T>::Realloc(sa_size_t n, short lcv, bool force) 146 146 { 147 147 if( n == 0 ) 148 148 throw(SzMismatchError("TVector::Realloc() n = 0 ")); 149 uint_4r,c;149 sa_size_t r,c; 150 150 if (lcv == SameVectorType) lcv = GetVectorType(); 151 151 else if ( (lcv != ColumnVector) && (lcv != RowVector) ) lcv = GetDefaultVectorType(); … … 175 175 { 176 176 T ret = 0; 177 for( uint_8k=0; k<Size(); k++) ret += (*this)(k)*(*this)(k);177 for(sa_size_t k=0; k<Size(); k++) ret += (*this)(k)*(*this)(k); 178 178 return ret; 179 179 } -
trunk/SophyaLib/TArray/tvector.h
r1103 r1156 14 14 // Creation / destruction 15 15 TVector(); 16 TVector( uint_4n, short lcv=AutoVectorType, short mm=AutoMemoryMapping);16 TVector(sa_size_t n, short lcv=AutoVectorType, short mm=AutoMemoryMapping); 17 17 TVector(const TVector<T>& v); 18 18 TVector(const TVector<T>& v, bool share); … … 39 39 40 40 // Gestion taille/Remplissage 41 void ReSize( uint_4n, short lcv=SameVectorType );42 void Realloc( uint_4n, short lcv=SameVectorType, bool force=false);41 void ReSize(sa_size_t n, short lcv=SameVectorType ); 42 void Realloc(sa_size_t n, short lcv=SameVectorType, bool force=false); 43 43 44 44 // Sub-Vector extraction $CHECK$ Reza 03/2000 Doit-on declarer cette methode const ? … … 50 50 // Informations pointeur/data 51 51 //! return the number of elements 52 inline uint_4NElts() const {return Size(); }52 inline sa_size_t NElts() const {return Size(); } 53 53 54 54 // Inline element acces methods 55 inline T const& operator()( uint_4n) const;56 inline T& operator()( uint_4n);55 inline T const& operator()(sa_size_t n) const; 56 inline T& operator()(sa_size_t n); 57 57 58 58 // Operateur d'affectation … … 89 89 //! Return the value of element \b n 90 90 template <class T> 91 inline T const& TVector<T>::operator()( uint_4n) const91 inline T const& TVector<T>::operator()(sa_size_t n) const 92 92 { 93 93 #ifdef SO_BOUNDCHECKING … … 100 100 //! Return the value of element \b n 101 101 template <class T> 102 inline T & TVector<T>::operator()( uint_4n)102 inline T & TVector<T>::operator()(sa_size_t n) 103 103 { 104 104 #ifdef SO_BOUNDCHECKING -
trunk/SophyaLib/TArray/utilarr.cc
r1103 r1156 48 48 } 49 49 50 MuTyV & RandomSequence::Value( uint_8k) const50 MuTyV & RandomSequence::Value(sa_size_t k) const 51 51 { 52 52 if (typ_ == Flat) retv_ = drandpm1()*sig_ + mean_; … … 96 96 */ 97 97 98 MuTyV & RegularSequence::Value ( uint_8k) const98 MuTyV & RegularSequence::Value (sa_size_t k) const 99 99 { 100 100 double x = start_+(double)k*step_; … … 108 108 } 109 109 110 MuTyV & EnumeratedSequence::Value ( uint_8k) const110 MuTyV & EnumeratedSequence::Value (sa_size_t k) const 111 111 { 112 112 if (k >= vecv_.size()) retv_ = 0; … … 117 117 EnumeratedSequence & EnumeratedSequence::operator , (MuTyV const & v) 118 118 { 119 vecv_.push_back(v); 120 return(*this); 121 } 122 123 EnumeratedSequence & EnumeratedSequence::operator = (MuTyV const & v) 124 { 125 vecv_.clear(); 119 126 vecv_.push_back(v); 120 127 return(*this); … … 139 146 \warning If not \b size is fixed and \b end recomputed 140 147 */ 141 Range::Range( uint_4 start, uint_4 end, uint_4 size, uint_4step)148 Range::Range(sa_size_t start, sa_size_t end, sa_size_t size, sa_size_t step) 142 149 { 143 150 start_ = start; … … 155 162 156 163 /* 157 Range & Range::operator = ( uint_4start)164 Range & Range::operator = (sa_size_t start) 158 165 { 159 166 start_ = start; … … 173 180 174 181 //! Constructor of a (n,n) diagonal matrix with value diag on the diagonal 175 IdentityMatrix::IdentityMatrix(double diag, uint_4n)182 IdentityMatrix::IdentityMatrix(double diag, sa_size_t n) 176 183 { 177 184 size_ = n; -
trunk/SophyaLib/TArray/utilarr.h
r1103 r1156 32 32 public: 33 33 virtual ~Sequence(); 34 virtual MuTyV & Value( uint_8k) const = 0;35 inline MuTyV & operator () ( uint_8k) const { return(Value(k)) ; }34 virtual MuTyV & Value(sa_size_t k) const = 0; 35 inline MuTyV & operator () (sa_size_t k) const { return(Value(k)) ; } 36 36 }; 37 37 … … 46 46 explicit RandomSequence(int typ = RandomSequence::Gaussian, double m=0., double s=1.); 47 47 virtual ~RandomSequence(); 48 virtual MuTyV & Value( uint_8k) const ;48 virtual MuTyV & Value(sa_size_t k) const ; 49 49 double Rand(); 50 50 … … 68 68 inline double & Step() { return step_; } 69 69 70 virtual MuTyV & Value( uint_8k) const ;70 virtual MuTyV & Value(sa_size_t k) const ; 71 71 72 72 protected: … … 80 80 public: 81 81 virtual ~EnumeratedSequence(); 82 virtual MuTyV & Value( uint_8k) const ;82 virtual MuTyV & Value(sa_size_t k) const ; 83 83 EnumeratedSequence & operator , (MuTyV const & v); 84 EnumeratedSequence & operator = (MuTyV const & v); 84 85 private: 85 86 vector<MuTyV> vecv_; … … 87 88 }; 88 89 89 inline EnumeratedSequence operator , (MuTyV const & a, MuTyV const & b)90 { EnumeratedSequence seq; return ((seq,a),b) ; }90 //inline EnumeratedSequence operator , (MuTyV const & a, MuTyV const & b) 91 //{ EnumeratedSequence seq; return ((seq,a),b) ; } 91 92 92 93 ////////////////////////////////////////////////////////// … … 94 95 class Range { 95 96 public: 96 explicit Range( uint_4 start=0, uint_4 end=0, uint_4 size=1, uint_4step=1);97 explicit Range(sa_size_t start=0, sa_size_t end=0, sa_size_t size=1, sa_size_t step=1); 97 98 //! Return the start index 98 inline uint_4& Start() { return start_; }99 inline sa_size_t & Start() { return start_; } 99 100 //! Return the last index 100 inline uint_4& End() { return end_; }101 inline sa_size_t & End() { return end_; } 101 102 //! Return the size 102 inline uint_4& Size() { return size_; }103 inline sa_size_t & Size() { return size_; } 103 104 //! Return the step 104 inline uint_4& Step() { return step_; }105 inline sa_size_t & Step() { return step_; } 105 106 protected: 106 uint_4start_; //!< start index107 uint_4end_; //!< end index108 uint_4size_; //!< size109 uint_4step_; //!< step107 sa_size_t start_; //!< start index 108 sa_size_t end_; //!< end index 109 sa_size_t size_; //!< size 110 sa_size_t step_; //!< step 110 111 }; 111 112 … … 114 115 class IdentityMatrix { 115 116 public: 116 explicit IdentityMatrix(double diag=1., uint_4n=0);117 explicit IdentityMatrix(double diag=1., sa_size_t n=0); 117 118 //! return the size of the identity matrix 118 inline uint_4Size() { return size_; }119 inline sa_size_t Size() { return size_; } 119 120 //! return the value of the diagonal elements 120 121 inline double Diag() { return diag_; } 121 122 protected: 122 uint_4size_; //!< size of the matrix123 sa_size_t size_; //!< size of the matrix 123 124 double diag_; //!< value of the diagonal elements 124 125 };
Note:
See TracChangeset
for help on using the changeset viewer.