Changeset 1156 in Sophya for trunk/SophyaLib/TArray


Ignore:
Timestamp:
Aug 29, 2000, 6:10:32 PM (25 years ago)
Author:
ansari
Message:

Introduction du type sa_size_t (taille des tableaux), operateur - (TArray::operator - et NegateElt()) - Reza 29/8/2000

Location:
trunk/SophyaLib/TArray
Files:
12 edited

Legend:

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

    r1103 r1156  
    2121     {"???", "Size(int )", "IsPacked(int )"
    2222     ,"Stride(int )", "ElemCheckBound()", "operator()" };
    23 uint_4 BaseArray::max_nprt_ = 50;
    24 uint_4 BaseArray::prt_lev_ = 0;
     23int_4 BaseArray::max_nprt_ = 50;
     24int_4 BaseArray::prt_lev_ = 0;
    2525short  BaseArray::default_memory_mapping = CMemoryMapping;
    2626short  BaseArray::default_vector_type = ColumnVector;
    27 uint_8 BaseArray::openmp_size_threshold = 200000;
     27sa_size_t BaseArray::openmp_size_threshold = 200000;
    2828
    2929// ------ Methodes statiques globales --------
     
    3434  \param lev  : print level
    3535*/
    36 void BaseArray::SetMaxPrint(uint_4 nprt, uint_4 lev)
     36void BaseArray::SetMaxPrint(int_4 nprt, int_4 lev)
    3737{
    3838  max_nprt_ = nprt;
     
    4444  \param thr : thresold value
    4545*/
    46 void BaseArray::SetOpenMPSizeThreshold(uint_8 thr)
     46void BaseArray::SetOpenMPSizeThreshold(sa_size_t thr)
    4747{
    4848  openmp_size_threshold = thr;
     
    5858  \return Total size of the array
    5959*/
    60 uint_8 BaseArray::ComputeTotalSize(uint_4 ndim, const uint_4 * siz, uint_4 step, uint_8 offset)
    61 {
    62   uint_8 rs = step;
    63   for(uint_4 k=0; k<ndim; k++) rs *= siz[k];
     60sa_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];
    6464  return(rs+offset);
    6565}
     
    251251{
    252252  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;
    254254  totsize_ = 0;
    255255  minstep_ = 0;
     
    295295  if (arrtype_ == 0) {  // Simple TArray, not a matrix
    296296    smo = true;
    297     for(uint_4 k=0; k<ndim_; k++)
     297    for(int_4 k=0; k<ndim_; k++)
    298298      if (size_[k] != a.size_[k])  return(false);
    299299    return(true);
     
    304304         (size_[macoli_] != a.size_[a.macoli_])  ) return(false);
    305305    if (ndim_ > 2) 
    306       for(uint_4 k=2; k<ndim_; k++)
     306      for(int_4 k=2; k<ndim_; k++)
    307307        if (size_[k] != a.size_[k])  return(false);
    308308    if ( (macoli_ == a.macoli_) && (marowi_ == a.marowi_) ||
     
    316316{
    317317  if (ndim_ < 2)  return;
    318   uint_4 ndim = 0;
    319   uint_4 size[BASEARRAY_MAXNDIMS];
    320   uint_4 step[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++) {
    322322    if (size_[k] < 2)  continue;
    323323    size[ndim] = size_[k];
     
    339339{
    340340  if (ndim_ < 2)  return;
    341   uint_4 ndim = 0;
    342   uint_4 size[BASEARRAY_MAXNDIMS];
    343   uint_4 step[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++) {
    345345    size[ndim] = size_[k];
    346346    step[ndim] = step_[k];
     
    354354
    355355//! return minimum value for step[ndim]
    356 int  BaseArray::MinStepKA() const
    357 {
    358   for(uint_4 ka=0; ka<ndim_; ka++)
     356int_4  BaseArray::MinStepKA() const
     357{
     358  for(int_4 ka=0; ka<ndim_; ka++)
    359359    if (step_[ka] == minstep_) return((int)ka);
    360360  return(0);
     
    362362
    363363//! return maximum value for step[ndim]
    364 int  BaseArray::MaxSizeKA() const
    365 {
    366   int ka = 0;
    367   uint_4 mx = size_[0];
    368   for(uint_4 k=1; k<ndim_; k++) 
     364int_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++) 
    369369    if (size_[k] > mx) {  ka = k;  mx = size_[k]; }
    370370  return(ka);
     
    377377// --------------------------------------------------
    378378//! return position of first element for vector \b i alond \b ka th axe.
    379 uint_8 BaseArray::Offset(uint_4 ka, uint_8 i) const
     379sa_size_t BaseArray::Offset(int_4 ka, sa_size_t i) const
    380380{
    381381
     
    383383  //#ifdef SO_BOUNDCHECKING
    384384  if (ka >= ndim_)
    385     throw RangeCheckError("BaseArray::Offset(uint_4 ka, uint_8 i) Axe KA Error");
     385    throw RangeCheckError("BaseArray::Offset(int_4 ka, sa_size_t i) Axe KA Error");
    386386  if ( i*size_[ka] >= totsize_ ) 
    387     throw RangeCheckError("BaseArray::Offset(uint_4 ka, uint_8 i) Index Error");
     387    throw RangeCheckError("BaseArray::Offset(int_4 ka, sa_size_t i) Index Error");
    388388  //#endif
    389   uint_4 idx[BASEARRAY_MAXNDIMS];
    390   uint_4 k;
    391   uint_8 rest = i;
     389  sa_size_t idx[BASEARRAY_MAXNDIMS];
     390  int_4 k;
     391  sa_size_t rest = i;
    392392  idx[ka] = 0;
    393393  for(k=0; k<ndim_; k++) {
     
    395395    idx[k] = rest%size_[k];   rest /= size_[k];
    396396  }
    397   uint_8 off = offset_;
     397  sa_size_t off = offset_;
    398398  for(k=0; k<ndim_; k++)  off += idx[k]*step_[k];
    399399  return (off);
     
    401401
    402402//! return position of element \b ip.
    403 uint_8 BaseArray::Offset(uint_8 ip) const
     403sa_size_t BaseArray::Offset(sa_size_t ip) const
    404404{
    405405  if ( (ndim_ < 1) || (ip == 0) )  return(offset_);
    406406  //#ifdef SO_BOUNDCHECKING
    407407  if (ip >= totsize_)
    408     throw RangeCheckError("BaseArray::Offset(uint_8 ip) Out of range index ip");
     408    throw RangeCheckError("BaseArray::Offset(sa_size_t ip) Out of range index ip");
    409409  //#endif
    410410
    411   uint_4 idx[BASEARRAY_MAXNDIMS];
    412   uint_4 k;
    413   uint_8 rest = ip;
     411  sa_size_t idx[BASEARRAY_MAXNDIMS];
     412  int_4 k;
     413  sa_size_t rest = ip;
    414414  for(k=0; k<ndim_; k++) {
    415415    idx[k] = rest%size_[k];   rest /= size_[k];
     
    417417  //#ifdef SO_BOUNDCHECKING
    418418  if (rest != 0)
    419     throw PError("BaseArray::Offset(uint_8 ip) GUG !!! rest != 0");
     419    throw PError("BaseArray::Offset(sa_size_t ip) GUG !!! rest != 0");
    420420  //#endif
    421421//   if (rest != 0) cerr << " BUG ---- BaseArray::Offset( " << ip << " )" << rest << endl;
     
    423423//   for(k=0; k<ndim_; k++) cerr << idx[k] << "," ;
    424424//   cerr << " ZZZZ " << endl;
    425   uint_8 off = offset_;
     425  sa_size_t off = offset_;
    426426  for(k=0; k<ndim_; k++)  off += idx[k]*step_[k];
    427427  return (off);
     
    429429
    430430//! 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)
     431void 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)
    433433{
    434434  if (smo) { // Same memory organisation
     
    465465  os << "\n--- " << InfoString() ;
    466466  os << " ND=" << ndim_ << " SizeX*Y*...= " ;
    467   for(uint_4 k=0; k<ndim_; k++) {
     467  for(int_4 k=0; k<ndim_; k++) {
    468468    os << size_[k];
    469469    if (k<ndim_-1)  os << "x";
     
    472472  if (prt_lev_ > 0) {
    473473    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] << "  " ;
    475475    os << " Offset= " << offset_  << endl;
    476476  }
     
    509509  \return string \b exmsg for explanation in case of problems
    510510 */
    511 bool BaseArray::UpdateSizes(uint_4 ndim, const uint_4 * siz, uint_4 step, uint_8 offset, string & exmsg)
     511bool BaseArray::UpdateSizes(int_4 ndim, const sa_size_t * siz, sa_size_t step, sa_size_t offset, string & exmsg)
    512512{
    513513  if (ndim >= BASEARRAY_MAXNDIMS) {
     
    524524
    525525  totsize_ = 1;
    526   uint_4 k;
     526  int_4 k;
    527527  for(k=0; k<BASEARRAY_MAXNDIMS; k++) {
    528528    size_[k] = 1;
     
    560560  \return string \b exmsg for explanation in case of problems
    561561 */
    562 bool BaseArray::UpdateSizes(uint_4 ndim, const uint_4 * siz, const uint_4 * step, uint_8 offset, string & exmsg)
     562bool BaseArray::UpdateSizes(int_4 ndim, const sa_size_t * siz, const sa_size_t * step, sa_size_t offset, string & exmsg)
    563563{
    564564  if (ndim >= BASEARRAY_MAXNDIMS) {
     
    570570
    571571  totsize_ = 1;
    572   uint_4 k;
     572  int_4 k;
    573573  for(k=0; k<BASEARRAY_MAXNDIMS; k++) {
    574574    size_[k] = 1;
    575575    step_[k] = 0;
    576576  }
    577   uint_4 minstep = step[0];
     577  sa_size_t minstep = step[0];
    578578  for(k=0; k<ndim; k++) {
    579579    size_[k] = siz[k] ;
     
    588588    exmsg += " Size Error";  return false;
    589589  }
    590   uint_8 plast = 0;
     590  sa_size_t plast = 0;
    591591  for(k=0; k<ndim; k++)   plast += (siz[k]-1)*step[k];
    592592  if (plast == minstep*totsize_ )  moystep_ = minstep;
     
    623623
    624624  totsize_ = 1;
    625   uint_4 k;
     625  int_4 k;
    626626  for(k=0; k<BASEARRAY_MAXNDIMS; k++) {
    627627    size_[k] = 1;
    628628    step_[k] = 0;
    629629  }
    630   uint_4 minstep = a.step_[0];
     630  sa_size_t minstep = a.step_[0];
    631631  for(k=0; k<a.ndim_; k++) {
    632632    size_[k] = a.size_[k] ;
     
    663663  \return string \b exmsg for explanation in case of problems
    664664 */
    665 void BaseArray::UpdateSubArraySizes(BaseArray & ra, uint_4 ndim, uint_4 * siz, uint_4 * pos, uint_4 * step) const
     665void BaseArray::UpdateSubArraySizes(BaseArray & ra, int_4 ndim, sa_size_t * siz, sa_size_t * pos, sa_size_t * step) const
    666666{
    667667  if ( (ndim > ndim_) || (ndim < 1) )
    668668    throw(SzMismatchError("BaseArray::UpdateSubArraySizes( ... ) NDim Error") );
    669   uint_4 k;
     669  int_4 k;
    670670  for(k=0; k<ndim; k++)
    671671    if ( (siz[k]*step[k]+pos[k]) > size_[k] ) 
    672672      throw(SzMismatchError("BaseArray::UpdateSubArraySizes( ... ) Size/Pos Error") );
    673   uint_8 offset = offset_;
     673  sa_size_t offset = offset_;
    674674  for(k=0; k<ndim_; k++) {
    675675    offset += pos[k]*step_[k];
  • trunk/SophyaLib/TArray/basarr.h

    r1099 r1156  
    4040
    4141  // threshold for parallel routine call
    42   static void    SetOpenMPSizeThreshold(uint_8 thr=200000);
     42  static void    SetOpenMPSizeThreshold(sa_size_t thr=200000);
    4343  //! Get Size threshold for parallel routine call
    44   static inline uint_8 GetOpenMPSizeThreshold() { 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);   
    4747  //! Get maximum number of printed elements
    48   static inline uint_4 GetMaxPrint() { return max_nprt_; }
    49   //! Maximum number of printed elements arint level
    50   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_; }
    5151
    5252  static short   SetDefaultMemoryMapping(short mm=CMemoryMapping);
     
    7070  // Array dimensions
    7171  //! Return number of dimensions
    72   inline uint_4 NbDimensions() const { return( ndim_ ); }
     72  inline int_4 NbDimensions() const { return( ndim_ ); }
    7373
    7474  //! Return total size of the array
    75   inline uint_8 Size() const { return(totsize_); }
     75  inline sa_size_t Size() const { return(totsize_); }
    7676  //! Return size along the first dimension
    77   inline uint_4 SizeX() const { return(size_[0]); }
     77  inline sa_size_t SizeX() const { return(size_[0]); }
    7878  //! Return size along the second dimension
    79   inline uint_4 SizeY() const { return(size_[1]); }
     79  inline sa_size_t SizeY() const { return(size_[1]); }
    8080  //! Return size along the third dimension
    81   inline uint_4 SizeZ() const { return(size_[2]); }
     81  inline sa_size_t SizeZ() const { return(size_[2]); }
    8282  //! Return size along the \b ka th dimension
    83   inline uint_4 Size(int ka) 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 ;
    8686
    8787  //! Get memory organization
     
    8989         { return ( (marowi_ == 1) ? CMemoryMapping : FortranMemoryMapping) ; }
    9090  //! line index dimension
    91   inline int    RowsKA() const {return marowi_; }
     91  inline int_4    RowsKA() const {return marowi_; }
    9292  //! column index dimension
    93   inline int    ColsKA() const {return macoli_; }
     93  inline int_4    ColsKA() const {return macoli_; }
    9494  //! Index dimension of the elements of a vector
    95   inline int    VectKA() const {return veceli_; }
     95  inline int_4    VectKA() const {return veceli_; }
    9696  void          SetMemoryMapping(short mm=AutoMemoryMapping);
    9797
     
    111111  inline bool   IsPackedZ() const { return(step_[2] == 1); }
    112112  //! 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); }
    114114
    115115  //! return the minimum step value along all the dimensions
    116   inline uint_4 MinStep() const  { return(minstep_); }
     116  inline sa_size_t MinStep() const  { return(minstep_); }
    117117  //! return the average step value along all the dimensions
    118   inline uint_4 AvgStep() const  { return(moystep_); }
     118  inline sa_size_t AvgStep() const  { return(moystep_); }
    119119  //! return the step along the first dimension
    120   inline uint_4 StepX() const { return(step_[0]); }
     120  inline sa_size_t StepX() const { return(step_[0]); }
    121121  //! return the step along the second dimension
    122   inline uint_4 StepY() const { return(step_[1]); }
     122  inline sa_size_t StepY() const { return(step_[1]); }
    123123  //! return the step along the third dimension
    124   inline uint_4 StepZ() const { return(step_[2]); }
     124  inline sa_size_t StepZ() const { return(step_[2]); }
    125125  //! return the step along the \b ka th dimension
    126   inline uint_4 Step(int ka) 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 ;
    129129
    130130  // Offset of element ip
    131   uint_8 Offset(uint_8 ip=0) const ;
     131  sa_size_t Offset(sa_size_t ip=0) const ;
    132132  // Offset of the i'th vector along axe ka
    133   uint_8  Offset(uint_4 ka, uint_8 i) const ;
    134   inline uint_8  Offset(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it=0, uint_4 iu=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; 
    135135
    136136  // an abstract element acces methode
    137   virtual MuTyV & ValueAtPosition(uint_8 ip) const = 0;
     137  virtual MuTyV & ValueAtPosition(sa_size_t ip) const = 0;
    138138
    139139  // 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);
    142142  // Impression, I/O, ...
    143143  void           Show(ostream& os, bool si=false) const;
     
    150150
    151151protected:
    152   inline int CheckDI(int ka, int msg) const ;
    153   inline void CheckBound(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu, 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 ;
    154154  // Changing Sizes/NDim ... return true if OK
    155   bool UpdateSizes(uint_4 ndim, const uint_4 * siz, uint_4 step, uint_8 offset, string & exmsg);
    156   bool UpdateSizes(uint_4 ndim, const uint_4 * siz, const uint_4 * step, uint_8 offset, 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);
    157157  bool UpdateSizes(const BaseArray& a, string & exmsg);
    158   static uint_8 ComputeTotalSize(uint_4 ndim, const uint_4 * siz, uint_4 step, uint_8 offset) ;
     158  static sa_size_t ComputeTotalSize(sa_size_t ndim, const sa_size_t * siz, sa_size_t step, sa_size_t offset) ;
    159159  //  Organisation memoire
    160160  static short SelectMemoryMapping(short mm);
     
    164164
    165165  // 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_4 ndim_; //!< number of dimensions of array
    169   uint_4 size_[BASEARRAY_MAXNDIMS]; //!< array of the size in each dimension
    170   uint_8 totsize_; //!< Total number of elements
    171   uint_8 offset_;  //!< global offset -\> position of elem[0] in DataBlock
     166  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
    172172  //! two consecutive elements distance in a given dimension
    173   uint_4 step_[BASEARRAY_MAXNDIMS];
    174   uint_4 minstep_; //!< minimal step (in any axes)
    175   uint_4 moystep_; //!< mean step, if == 0 --\> non regular steps
     173  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
    176176  int_2  marowi_; //!< For matrices, Row index in dimensions
    177177  int_2  macoli_; //!< For matrices, Column index in dimensions
     
    181181
    182182  static char * ck_op_msg_[6]; //!< Operation messages for CheckDI() CheckBound()
    183   static uint_4 max_nprt_; //!< maximum number of printed elements
    184   static uint_4 prt_lev_;  //!< Print level
     183  static int_4 max_nprt_; //!< maximum number of printed elements
     184  static int_4 prt_lev_;  //!< Print level
    185185  static short default_memory_mapping; //!< Default memory mapping
    186186  static short default_vector_type;    //!< Default vector type Row/Column
    187   static uint_8 openmp_size_threshold; //!< Size limit for parallel routine calls
     187  static sa_size_t openmp_size_threshold; //!< Size limit for parallel routine calls
    188188};
    189189
     
    192192// --------------------------------------------------
    193193//! to verify the compatibility of the dimension index
    194 inline int BaseArray::CheckDI(int ka, int msg)  const
     194inline int_4 BaseArray::CheckDI(int_4 ka, int msg)  const
    195195{
    196   if ( (ka < 0) || ((uint_4) ka >= ndim_) ) {
     196  if ( (ka < 0) || (ka >= ndim_) ) {
    197197    string txt = "BaseArray::CheckDimensionIndex/Error ";   txt += ck_op_msg_[msg];
    198198    throw(RangeCheckError(txt));
     
    202202
    203203//! 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_4 iu, int msg)  const
     204inline 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
    205205{
    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) )  {
    208209    string txt = "BaseArray::CheckArrayBound/Error ";   txt += ck_op_msg_[msg];
    209210    throw(RangeCheckError(txt));
     
    218219// --------------------------------------------------
    219220//! 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_4 iu) const
     221inline 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
    221222{
    222223#ifdef SO_BOUNDCHECKING
  • trunk/SophyaLib/TArray/fioarr.cc

    r926 r1156  
    9393  uint_4 itab[5];
    9494  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
    95100  if (dobj == NULL) {
    96101    if (itab[1] == 12)   dobj = new TMatrix<T>;
     
    99104  }
    100105// 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
    111133// On lit le datablock
    112134  is >> dobj->DataBlock();
     
    132154
    133155  uint_4 itab[5];
    134   itab[0] = 1;  // Numero de version a 1
     156  itab[0] = 2;  // Numero de version a 2 depuis Aout 2000  - Reza
    135157  itab[1] = typa;  // Real object type
    136158  itab[2] = (dobj->mInfo != NULL) ? 1 : 0;
    137159  itab[3] = itab[4] = 0;
    138160  os.Put(itab,5);
     161
    139162// 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 
    150199// On ecrit le datablock
    151200  os << dobj->DataBlock();
  • trunk/SophyaLib/TArray/matharr.cc

    r1099 r1156  
    2929    throw RangeCheckError("MathArray<T>::ApplyFunctionInPlace(TArray<T> & a..) Not Allocated Array a !");
    3030  T * pe;
    31   uint_8 j,k;
     31  sa_size_t j,k;
    3232  if (a.AvgStep() > 0)   {  // regularly spaced elements
    33     uint_8 step = a.AvgStep();
    34     uint_8 maxx = a.Size()*step;
     33    sa_size_t step = a.AvgStep();
     34    sa_size_t maxx = a.Size()*step;
    3535    pe = a.Data();
    3636    for(k=0; k<maxx; k+=step )  pe[k] = (T)(f((double)pe[k]));
    3737  }
    3838  else {    // Non regular data spacing ...
    39     uint_4 ka = a.MaxSizeKA();
    40     uint_8 step = a.Step(ka);
    41     uint_8 gpas = a.Size(ka)*step;
    42     uint_8 naxa = 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);
    4343    for(j=0; j<naxa; j++)  {
    4444      pe = a.DataBlock().Begin()+a.Offset(ka,j);
     
    6161    throw RangeCheckError("MathArray<T>::ApplyFunctionInPlace(TArray<T> & a..) Not Allocated Array a !");
    6262  T * pe;
    63   uint_8 j,k;
     63  sa_size_t j,k;
    6464  if (a.AvgStep() > 0)   {  // regularly spaced elements
    65     uint_8 step = a.AvgStep();
    66     uint_8 maxx = a.Size()*step;
     65    sa_size_t step = a.AvgStep();
     66    sa_size_t maxx = a.Size()*step;
    6767    pe = a.Data();
    6868    for(k=0; k<maxx; k+=step )  pe[k] = (T)(f((float)pe[k]));
    6969  }
    7070  else {    // Non regular data spacing ...
    71     uint_4 ka = a.MaxSizeKA();
    72     uint_8 step = a.Step(ka);
    73     uint_8 gpas = a.Size(ka)*step;
    74     uint_8 naxa = 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);
    7575    for(j=0; j<naxa; j++)  {
    7676      pe = a.DataBlock().Begin()+a.Offset(ka,j);
     
    119119    throw RangeCheckError("MathArray<T>::MeanSigma(TArray<T> const & a..) Not Allocated Array a !");
    120120  const T * pe;
    121   uint_8 j,k;
     121  sa_size_t j,k;
    122122  mean=0.;
    123123  sig = 0.;
    124124  double valok;
    125125  if (a.AvgStep() > 0)   {  // regularly spaced elements
    126     uint_8 step = a.AvgStep();
    127     uint_8 maxx = a.Size()*step;
     126    sa_size_t step = a.AvgStep();
     127    sa_size_t maxx = a.Size()*step;
    128128    pe = a.Data();
    129129    for(k=0; k<maxx; k+=step )  {
     
    133133  }
    134134  else {    // Non regular data spacing ...
    135     uint_4 ka = a.MaxSizeKA();
    136     uint_8 step = a.Step(ka);
    137     uint_8 gpas = a.Size(ka)*step;
    138     uint_8 naxa = 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);
    139139    for(j=0; j<naxa; j++)  {
    140140      pe = a.DataBlock().Begin()+a.Offset(ka,j);
  • trunk/SophyaLib/TArray/tarray.cc

    r1113 r1156  
    3939 */
    4040template <class T>
    41 TArray<T>::TArray(uint_4 ndim, const uint_4 * siz, uint_4 step)
     41TArray<T>::TArray(int_4 ndim, const sa_size_t * siz, sa_size_t step)
    4242  : BaseArray() , mNDBlock(ComputeTotalSize(ndim, siz, step, 1))
    4343{
    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)";
    4545  if (!UpdateSizes(ndim, siz, step, 0, exmsg))  throw( ParmError(exmsg) );
    4646}
     
    5151 */
    5252template <class T>
    53 TArray<T>::TArray(uint_4 nx, uint_4 ny, uint_4 nz, uint_4 nt, uint_4 nu)
     53TArray<T>::TArray(sa_size_t nx, sa_size_t ny, sa_size_t nz, sa_size_t nt, sa_size_t nu)
    5454  : BaseArray() , mNDBlock(nx*((ny>0)?ny:1)*((nz>0)?nz:1)*((nt>0)?nt:1)*((nu>0)?nu:1))
    5555{
    56   uint_4 size[BASEARRAY_MAXNDIMS];
     56  sa_size_t size[BASEARRAY_MAXNDIMS];
    5757  size[0] = nx;   size[1] = ny;   size[2] = nz;
    5858  size[3] = nt;   size[4] = nu;
    59   int ndim = 1;
     59  int_4 ndim = 1;
    6060  if ((size[1] > 0) && (size[2] > 0) && (size[3] > 0) && (size[4] > 0) ) ndim = 5;
    6161  else if ((size[1] > 0) && (size[2] > 0) && (size[3] > 0) ) ndim = 4;
     
    6363  else if (size[1] > 0)  ndim = 2;
    6464  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)";
    6666  if (!UpdateSizes(ndim, size, 1, 0, exmsg))  throw( ParmError(exmsg) );
    6767}
     
    7777 */
    7878template <class T>
    79 TArray<T>::TArray(uint_4 ndim, const uint_4 * siz, NDataBlock<T> & db, bool share, uint_4 step, uint_8 offset)
     79TArray<T>::TArray(int_4 ndim, const sa_size_t * siz, NDataBlock<T> & db, bool share, sa_size_t step, sa_size_t offset)
    8080  : BaseArray() , mNDBlock(db, share)
    8181{
    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> & ... )";
    8383  if (!UpdateSizes(ndim, siz, step, offset, exmsg))  throw( ParmError(exmsg) );
    8484 
     
    9797 */
    9898template <class T>
    99 TArray<T>::TArray(uint_4 ndim, const uint_4 * siz, T* values, uint_4 step, uint_8 offset, Bridge* br)
     99TArray<T>::TArray(int_4 ndim, const sa_size_t * siz, T* values, sa_size_t step, sa_size_t offset, Bridge* br)
    100100  : BaseArray() , mNDBlock(ComputeTotalSize(ndim, siz, step, 1), values, br)
    101101{
    102   string exmsg = "TArray<T>::TArray(uint_4, uint_4 *, T* ... )";
     102  string exmsg = "TArray<T>::TArray(int_4, sa_size_t *, T* ... )";
    103103  if (!UpdateSizes(ndim, siz, step, offset, exmsg))  throw( ParmError(exmsg) );
    104104}
     
    225225 */
    226226template <class T>
    227 void TArray<T>::ReSize(uint_4 ndim, uint_4 * siz, uint_4 step)
     227void TArray<T>::ReSize(int_4 ndim, sa_size_t * siz, sa_size_t step)
    228228{
    229229  if (arrtype_ != 0) {
     
    247247 */
    248248template <class T>
    249 void TArray<T>::Realloc(uint_4 ndim, uint_4 * siz, uint_4 step, bool force)
     249void TArray<T>::Realloc(int_4 ndim, sa_size_t * siz, sa_size_t step, bool force)
    250250{
    251251  if (arrtype_ != 0) {
     
    279279//! Give value (in \b double) for element at position \b ip..
    280280template <class T>
    281 MuTyV & TArray<T>::ValueAtPosition(uint_8 ip) const
     281MuTyV & TArray<T>::ValueAtPosition(sa_size_t ip) const
    282282{
    283283#ifdef SO_BOUNDCHECKING
    284   if (ip >= totsize_)  throw( ParmError("TArray<T>::ValueAtPosition(uint_8 ip) Out-of-bound Error") );
     284  if (ip >= totsize_)  throw( ParmError("TArray<T>::ValueAtPosition(sa_size_t ip) Out-of-bound Error") );
    285285#endif
    286286  my_mtv = *(mNDBlock.Begin()+Offset(ip));
     
    326326  if (NbDimensions() < 1)
    327327    throw RangeCheckError("TArray<T>::operator () (Range, ...) - Not Allocated Array ! ");
    328   uint_4 ndim = 0;
    329   uint_4 size[BASEARRAY_MAXNDIMS];
    330   uint_4 step[BASEARRAY_MAXNDIMS];
    331   uint_4 pos[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];
    332332  size[0] = rx.Size();
    333333  size[1] = ry.Size();
     
    373373 
    374374  T * pe;
    375   uint_8 j,k;
    376   int ka;
     375  sa_size_t j,k;
     376  int_4 ka;
    377377  if (arrtype_ == 0)  ka = 0;
    378378  else ka = macoli_;
    379   uint_8 step = Step(ka);
    380   uint_8 gpas = Size(ka);
    381   uint_8 naxa = 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);
    382382  for(j=0; j<naxa; j++)  {
    383383    pe = mNDBlock.Begin()+Offset(ka,j);
     
    401401    throw RangeCheckError("TArray<T>::SetT(T )  - Not Allocated Array ! ");
    402402  T * pe;
    403   uint_8 j,k;
     403  sa_size_t j,k;
    404404  if (AvgStep() > 0)   {  // regularly spaced elements
    405     uint_8 step = AvgStep();
    406     uint_8 maxx = totsize_*step;
     405    sa_size_t step = AvgStep();
     406    sa_size_t maxx = totsize_*step;
    407407    pe = Data();
    408408    for(k=0; k<maxx; k+=step )  pe[k] = x;
    409409  }
    410410  else {    // Non regular data spacing ...
    411     uint_4 ka = MaxSizeKA();
    412     uint_8 step = Step(ka);
    413     uint_8 gpas = Size(ka)*step;
    414     uint_8 naxa = 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);
    415415    for(j=0; j<naxa; j++)  {
    416416      pe = mNDBlock.Begin()+Offset(ka,j);
     
    428428    throw RangeCheckError("TArray<T>::Add(T )  - Not Allocated Array ! ");
    429429  T * pe;
    430   uint_8 j,k;
     430  sa_size_t j,k;
    431431  if (AvgStep() > 0)   {  // regularly spaced elements
    432     uint_8 step = AvgStep();
    433     uint_8 maxx = totsize_*step;
     432    sa_size_t step = AvgStep();
     433    sa_size_t maxx = totsize_*step;
    434434    pe = Data();
    435435    for(k=0; k<maxx; k+=step )  pe[k] += x;
    436436  }
    437437  else {    // Non regular data spacing ...
    438     uint_4 ka = MaxSizeKA();
    439     uint_8 step = Step(ka);
    440     uint_8 gpas = Size(ka)*step;
    441     uint_8 naxa = 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);
    442442    for(j=0; j<naxa; j++)  {
    443443      pe = mNDBlock.Begin()+Offset(ka,j);
     
    459459    throw RangeCheckError("TArray<T>::Sub(T )  - Not Allocated Array ! ");
    460460  T * pe;
    461   uint_8 j,k;
     461  sa_size_t j,k;
    462462  if (AvgStep() > 0)   {  // regularly spaced elements
    463     uint_8 step = AvgStep();
    464     uint_8 maxx = totsize_*step;
     463    sa_size_t step = AvgStep();
     464    sa_size_t maxx = totsize_*step;
    465465    pe = Data();
    466466    if (fginv)
     
    470470  }
    471471  else {    // Non regular data spacing ...
    472     uint_4 ka = MaxSizeKA();
    473     uint_8 step = Step(ka);
    474     uint_8 gpas = Size(ka)*step;
    475     uint_8 naxa = 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);
    476476    for(j=0; j<naxa; j++)  {
    477477      pe = mNDBlock.Begin()+Offset(ka,j);
     
    492492    throw RangeCheckError("TArray<T>::Mul(T )  - Not Allocated Array ! ");
    493493  T * pe;
    494   uint_8 j,k;
     494  sa_size_t j,k;
    495495  if (AvgStep() > 0)   {  // regularly spaced elements
    496     uint_8 step = AvgStep();
    497     uint_8 maxx = totsize_*step;
     496    sa_size_t step = AvgStep();
     497    sa_size_t maxx = totsize_*step;
    498498    pe = Data();
    499499    for(k=0; k<maxx; k+=step )  pe[k] *= x;
    500500  }
    501501  else {    // Non regular data spacing ...
    502     uint_4 ka = MaxSizeKA();
    503     uint_8 step = Step(ka);
    504     uint_8 gpas = Size(ka)*step;
    505     uint_8 naxa = 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);
    506506    for(j=0; j<naxa; j++)  {
    507507      pe = mNDBlock.Begin()+Offset(ka,j);
     
    525525    throw MathExc("TArray<T>::Div(T )  - Divide by zero ! ");
    526526  T * pe;
    527   uint_8 j,k;
     527  sa_size_t j,k;
    528528  if (AvgStep() > 0)   {  // regularly spaced elements
    529     uint_8 step = AvgStep();
    530     uint_8 maxx = totsize_*step;
     529    sa_size_t step = AvgStep();
     530    sa_size_t maxx = totsize_*step;
    531531    pe = Data();
    532532    if (fginv)
     
    536536  }
    537537  else {    // Non regular data spacing ...
    538     uint_4 ka = MaxSizeKA();
    539     uint_8 step = Step(ka);
    540     uint_8 gpas = Size(ka)*step;
    541     uint_8 naxa = 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);
    542542    for(j=0; j<naxa; j++)  {
    543543      pe = mNDBlock.Begin()+Offset(ka,j);
     
    552552
    553553
    554 
     554//! Replace array elements values by their opposite ( a(i) -> -a(i) )
     555template <class T>
     556TArray<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}
    555580
    556581//  >>>> Operations avec 2nd membre de type tableau
     
    567592  T * pe;
    568593  const T * pea;
    569   uint_8 j,k,ka;
     594  sa_size_t j,k,ka;
    570595  if (smo && (AvgStep() > 0) && (a.AvgStep() > 0))   {  // regularly spaced elements
    571     uint_8 step = AvgStep();
    572     uint_8 stepa = a.AvgStep();
    573     uint_8 maxx = totsize_*step;
     596    sa_size_t step = AvgStep();
     597    sa_size_t stepa = a.AvgStep();
     598    sa_size_t maxx = totsize_*step;
    574599    pe = Data();
    575600    pea = a.Data();
     
    577602  }
    578603  else {    // Non regular data spacing ...
    579     int ax,axa;
    580     uint_8 step, stepa;
    581     uint_8 gpas, naxa;
     604    int_4 ax,axa;
     605    sa_size_t step, stepa;
     606    sa_size_t gpas, naxa;
    582607    GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
    583608    for(j=0; j<naxa; j++)  {
     
    606631  T * pe;
    607632  const T * pea;
    608   uint_8 j,k,ka;
     633  sa_size_t j,k,ka;
    609634  if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
    610     uint_8 step = AvgStep();
    611     uint_8 stepa = a.AvgStep();
    612     uint_8 maxx = totsize_*step;
     635    sa_size_t step = AvgStep();
     636    sa_size_t stepa = a.AvgStep();
     637    sa_size_t maxx = totsize_*step;
    613638    pe = Data();
    614639    pea = a.Data();
     
    619644  }
    620645  else {    // Non regular data spacing ...
    621     int ax,axa;
    622     uint_8 step, stepa;
    623     uint_8 gpas, naxa;
     646    int_4 ax,axa;
     647    sa_size_t step, stepa;
     648    sa_size_t gpas, naxa;
    624649    GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
    625650    for(j=0; j<naxa; j++)  {
     
    648673  T * pe;
    649674  const T * pea;
    650   uint_8 j,k,ka;
     675  sa_size_t j,k,ka;
    651676  if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
    652     uint_8 step = AvgStep();
    653     uint_8 stepa = a.AvgStep();
    654     uint_8 maxx = totsize_*step;
     677    sa_size_t step = AvgStep();
     678    sa_size_t stepa = a.AvgStep();
     679    sa_size_t maxx = totsize_*step;
    655680    pe = Data();
    656681    pea = a.Data();
     
    658683  }
    659684  else {    // Non regular data spacing ...
    660     int ax,axa;
    661     uint_8 step, stepa;
    662     uint_8 gpas, naxa;
     685    int_4 ax,axa;
     686    sa_size_t step, stepa;
     687    sa_size_t gpas, naxa;
    663688    GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
    664689    for(j=0; j<naxa; j++)  {
     
    689714  T * pe;
    690715  const T * pea;
    691   uint_8 j,k,ka;
     716  sa_size_t j,k,ka;
    692717  if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
    693     uint_8 step = AvgStep();
    694     uint_8 stepa = a.AvgStep();
    695     uint_8 maxx = totsize_*step;
     718    sa_size_t step = AvgStep();
     719    sa_size_t stepa = a.AvgStep();
     720    sa_size_t maxx = totsize_*step;
    696721    pe = Data();
    697722    pea = a.Data();
     
    711736  }
    712737  else {    // Non regular data spacing ...
    713     int ax,axa;
    714     uint_8 step, stepa;
    715     uint_8 gpas, naxa;
     738    int_4 ax,axa;
     739    sa_size_t step, stepa;
     740    sa_size_t gpas, naxa;
    716741    GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
    717742    for(j=0; j<naxa; j++)  {
     
    748773  T * pe;
    749774  const T * pea;
    750   uint_8 j,k,ka;
     775  sa_size_t j,k,ka;
    751776  if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
    752     uint_8 step = AvgStep();
    753     uint_8 stepa = a.AvgStep();
    754     uint_8 maxx = totsize_*step;
     777    sa_size_t step = AvgStep();
     778    sa_size_t stepa = a.AvgStep();
     779    sa_size_t maxx = totsize_*step;
    755780    pe = Data();
    756781    pea = a.Data();
     
    758783  }
    759784  else {    // Non regular data spacing ...
    760     int ax,axa;
    761     uint_8 step, stepa;
    762     uint_8 gpas, naxa;
     785    int_4 ax,axa;
     786    sa_size_t step, stepa;
     787    sa_size_t gpas, naxa;
    763788    GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
    764789    for(j=0; j<naxa; j++)  {
     
    782807
    783808  T * pe;
    784   uint_8 j,k,ka;
    785   uint_8 offa;
     809  sa_size_t j,k,ka;
     810  sa_size_t offa;
    786811  // Non regular data spacing ...
    787   int ax,axa;
    788   uint_8 step, stepa;
    789   uint_8 gpas, naxa;
     812  int_4 ax,axa;
     813  sa_size_t step, stepa;
     814  sa_size_t gpas, naxa;
    790815  GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
    791816  for(j=0; j<naxa; j++)  {
     
    812837  T ret=0;
    813838  const T * pe;
    814   uint_8 j,k;
     839  sa_size_t j,k;
    815840  if (AvgStep() > 0)   {  // regularly spaced elements
    816     uint_8 step = AvgStep();
    817     uint_8 maxx = totsize_*step;
     841    sa_size_t step = AvgStep();
     842    sa_size_t maxx = totsize_*step;
    818843    pe = Data();
    819844    for(k=0; k<maxx; k+=step )  ret += pe[k];
    820845  }
    821846  else {    // Non regular data spacing ...
    822     uint_4 ka = MaxSizeKA();
    823     uint_8 step = Step(ka);
    824     uint_8 gpas = Size(ka)*step;
    825     uint_8 naxa = 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);
    826851    for(j=0; j<naxa; j++)  {
    827852      pe = mNDBlock.Begin()+Offset(ka,j);
     
    840865  T ret=(T)1;
    841866  const T * pe;
    842   uint_8 j,k;
     867  sa_size_t j,k;
    843868  if (AvgStep() > 0)   {  // regularly spaced elements
    844     uint_8 step = AvgStep();
    845     uint_8 maxx = totsize_*step;
     869    sa_size_t step = AvgStep();
     870    sa_size_t maxx = totsize_*step;
    846871    pe = Data();
    847872    for(k=0; k<maxx; k+=step )  ret *= pe[k];
    848873  }
    849874  else {    // Non regular data spacing ...
    850     uint_4 ka = MaxSizeKA();
    851     uint_8 step = Step(ka);
    852     uint_8 gpas = Size(ka)*step;
    853     uint_8 naxa = 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);
    854879    for(j=0; j<naxa; j++)  {
    855880      pe = mNDBlock.Begin()+Offset(ka,j);
     
    868893  T ret=0;
    869894  const T * pe;
    870   uint_8 j,k;
     895  sa_size_t j,k;
    871896  if (AvgStep() > 0)   {  // regularly spaced elements
    872     uint_8 step = AvgStep();
    873     uint_8 maxx = totsize_*step;
     897    sa_size_t step = AvgStep();
     898    sa_size_t maxx = totsize_*step;
    874899    pe = Data();
    875900    for(k=0; k<maxx; k+=step )  ret += pe[k]*pe[k];
    876901  }
    877902  else {    // Non regular data spacing ...
    878     uint_4 ka = MaxSizeKA();
    879     uint_8 step = Step(ka);
    880     uint_8 gpas = Size(ka)*step;
    881     uint_8 naxa = 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);
    882907    for(j=0; j<naxa; j++)  {
    883908      pe = mNDBlock.Begin()+Offset(ka,j);
     
    896921{
    897922  const T * pe;
    898   uint_8 j,k;
    899   uint_4 ka = MaxSizeKA();
    900   uint_8 step = Step(ka);
    901   uint_8 gpas = Size(ka)*step;
    902   uint_8 naxa = 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);
    903928  min = (*this)[0];
    904929  max = (*this)[0];
     
    948973{
    949974  if (maxprt < 0)  maxprt = max_nprt_;
    950   uint_4 npr = 0;
     975  sa_size_t npr = 0;
    951976  Show(os, si);
    952977  if (ndim_ < 1) return;
    953   uint_4 k0,k1,k2,k3,k4;
     978  sa_size_t k0,k1,k2,k3,k4;
    954979  for(k4=0; k4<size_[4]; k4++) {
    955980    if (size_[4] > 1) cout << "\n ----- Dimension 5 (U) K4= " << k4 << endl;
     
    963988            if(k0 > 0) os << ", "; 
    964989            os << Elem(k0, k1, k2, k3, k4);     npr++;
    965             if (npr >= (uint_4) maxprt) {
     990            if (npr >= (sa_size_t) maxprt) {
    966991              if (npr < totsize_)  os << "\n     .... " << endl; return;
    967992            }
  • trunk/SophyaLib/TArray/tarray.h

    r1113 r1156  
    2929  // Creation / destruction
    3030  TArray();
    31   TArray(uint_4 ndim, const uint_4 * siz, uint_4 step =1);
    32   TArray(uint_4 nx, uint_4 ny=0, uint_4 nz=0, uint_4 nt=0, uint_4 nu=0);
    33   TArray(uint_4 ndim, const uint_4 * siz, NDataBlock<T> & db, bool share=false, uint_4 step=1, uint_8 offset=0);
    34   TArray(uint_4 ndim, const uint_4 * siz, T* values, uint_4 step=1, uint_8 offset=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);
    3535  TArray(const TArray<T>& a);
    3636  TArray(const TArray<T>& a, bool share);
     
    5757
    5858  void Share(const TArray<T>& a);
    59   void ReSize(uint_4 ndim, uint_4 * siz, uint_4 step=1);
    60   void Realloc(uint_4 ndim, uint_4 * siz, uint_4 step=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);
    6161
    6262  // Compacts size=1 array dimensions
     
    8888  // ---- Access to data
    8989  // Definition of virtual element acces method inherited from BaseArray class
    90   virtual MuTyV & ValueAtPosition(uint_8 ip) const;
     90  virtual MuTyV & ValueAtPosition(sa_size_t ip) const;
    9191
    9292  // Data Access: operator overloaded inline acces methods
    93   inline T const& operator()(uint_4 ix, uint_4 iy, uint_4 iz) const ;
    94   inline T&       operator()(uint_4 ix, uint_4 iy, uint_4 iz);
    95   inline T const& operator()(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu=0) const ;
    96   inline T&       operator()(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu=0);
    97   inline T const& operator[](uint_8 ip) const ;
    98   inline T&       operator[](uint_8 ip);
    99 
    100   inline T const& Elem(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it=0, uint_4 iu=0) const ;
    101   inline T&       Elem(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it=0, uint_4 iu=0);
    102   inline T const& ElemCheckBound(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it=0, uint_4 iu=0) const ;
    103   inline T&       ElemCheckBound(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it=0, uint_4 iu=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);
    104104
    105105  //! Return pointer to first element adress
     
    143143  inline  TArray<T>&  operator /= (T x)            { return Div(x); }
    144144
     145// applique le signe moins a tous les elements
     146  virtual TArray<T>&  NegateElt();
     147 
    145148// A += -=  (ajoute, soustrait element par element les deux tableaux )
    146149  virtual TArray<T>&  AddElt(const TArray<T>& a);
     
    238241
    239242////////////////////////////////////////////////////////////////
     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.  */
     248template <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////////////////////////////////////////////////////////////////
    240253// Surcharge d'operateurs C = A (+,-) B
    241254
     
    265278//! Return element (ix,iy,iz,it,iu) value
    266279template <class T>
    267 inline T const& TArray<T>::Elem(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) const
     280inline 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
    268281{
    269282  return ( *( mNDBlock.Begin()+ offset_+
     
    274287//! Return element (ix,iy,iz,it,iu) value
    275288template <class T>
    276 inline T & TArray<T>::Elem(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu)
     289inline T & TArray<T>::Elem(sa_size_t ix, sa_size_t iy, sa_size_t iz, sa_size_t it, sa_size_t iu)
    277290{
    278291  return ( *( mNDBlock.Begin()+ offset_+
     
    283296//! Return element (ix,iy,iz,it,iu) value with Check of indexes bound first
    284297template <class T>
    285 inline T const& TArray<T>::ElemCheckBound(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) const
     298inline 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
    286299{
    287300  CheckBound(ix, iy, iz, it, iu, 4);
     
    291304//! Return element (ix,iy,iz,it,iu) value with Check of indexes bound first
    292305template <class T>
    293 inline T & TArray<T>::ElemCheckBound(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu)
     306inline T & TArray<T>::ElemCheckBound(sa_size_t ix, sa_size_t iy, sa_size_t iz, sa_size_t it, sa_size_t iu)
    294307{
    295308  CheckBound(ix, iy, iz, it, iu, 4);
     
    299312//! Return element (ix,iy,iz) value
    300313template <class T>
    301 inline T const& TArray<T>::operator()(uint_4 ix, uint_4 iy, uint_4 iz) const
     314inline T const& TArray<T>::operator()(sa_size_t ix, sa_size_t iy, sa_size_t iz) const
    302315{
    303316#ifdef SO_BOUNDCHECKING
     
    310323//! Return element (ix,iy,iz) value
    311324template <class T>
    312 inline T & TArray<T>::operator()(uint_4 ix, uint_4 iy, uint_4 iz)
     325inline T & TArray<T>::operator()(sa_size_t ix, sa_size_t iy, sa_size_t iz)
    313326{
    314327#ifdef SO_BOUNDCHECKING
     
    321334//! Operator () : return element (ix,iy,iz,it,iu) value
    322335template <class T>
    323 inline T const& TArray<T>::operator()(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu) const
     336inline 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
    324337{
    325338#ifdef SO_BOUNDCHECKING
     
    333346//! Operator () : return element (ix,iy,iz,it,iu) value
    334347template <class T>
    335 inline T & TArray<T>::operator()(uint_4 ix, uint_4 iy, uint_4 iz, uint_4 it, uint_4 iu)
     348inline T & TArray<T>::operator()(sa_size_t ix, sa_size_t iy, sa_size_t iz, sa_size_t it, sa_size_t iu)
    336349{
    337350#ifdef SO_BOUNDCHECKING
     
    346359//! Operator [] : return element at positon ip
    347360template <class T>
    348 inline T const& TArray<T>::operator[](uint_8 ip) const
     361inline T const& TArray<T>::operator[](sa_size_t ip) const
    349362{
    350363#ifdef SO_BOUNDCHECKING
     
    356369//! Operator [] : return element at positon ip
    357370template <class T>
    358 inline T & TArray<T>::operator[](uint_8 ip)
     371inline T & TArray<T>::operator[](sa_size_t ip)
    359372{
    360373#ifdef SO_BOUNDCHECKING
     
    365378
    366379
    367 //! Return the value of first element
     380//! Converts to a scalar (value of first element) if the array size is equal to 1
    368381template <class T>
    369382inline T TArray<T>::toScalar()
  • trunk/SophyaLib/TArray/tmatrix.cc

    r1103 r1156  
    1 // $Id: tmatrix.cc,v 1.15 2000-07-27 00:00:09 ansari Exp $
     1// $Id: tmatrix.cc,v 1.16 2000-08-29 16:10:30 ansari Exp $
    22//                         C.Magneville          04/99
    33#include "machdefs.h"
     
    3333 */
    3434template <class T>
    35 TMatrix<T>::TMatrix(uint_4 r,uint_4 c, short mm)
     35TMatrix<T>::TMatrix(sa_size_t r,sa_size_t c, short mm)
    3636// Construit une matrice de r lignes et c colonnes.
    3737  :  TArray<T>()
    3838{
    3939  if ( (r == 0) || (c == 0) )
    40     throw ParmError("TMatrix<T>::TMatrix(uint_4 r,uint_4 c) NRows or NCols = 0");
     40    throw ParmError("TMatrix<T>::TMatrix(sa_size_t r,sa_size_t c) NRows or NCols = 0");
    4141  arrtype_ = 1;   // Type = Matrix
    4242  ReSize(r, c, mm);
     
    175175 */
    176176template <class T>
    177 void TMatrix<T>::ReSize(uint_4 r, uint_4 c, short mm)
     177void TMatrix<T>::ReSize(sa_size_t r, sa_size_t c, short mm)
    178178{
    179179  if(r==0||c==0)
     
    181181  if ((arrtype_ == 2) && (r > 1) && (c > 1))
    182182    throw(SzMismatchError("TMatrix::ReSize r>1&&c>1 for Vector "));
    183   uint_4 size[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;
    185185  if (mm == SameMemoryMapping) mm = GetMemoryMapping(); 
    186186  else if ( (mm != CMemoryMapping) && (mm != FortranMemoryMapping) )
     
    206206 */
    207207template <class T>
    208 void TMatrix<T>::Realloc(uint_4 r,uint_4 c, short mm, bool force)
     208void TMatrix<T>::Realloc(sa_size_t r,sa_size_t c, short mm, bool force)
    209209{
    210210  if(r==0||c==0)
     
    212212  if ((arrtype_ == 2) && (r > 1) && (c > 1))
    213213    throw(SzMismatchError("TMatrix::Realloc r>1&&c>1 for Vector "));
    214   uint_4 size[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;
    216216  if (mm == SameMemoryMapping) mm = GetMemoryMapping(); 
    217217  else if ( (mm != CMemoryMapping) && (mm != FortranMemoryMapping) )
     
    249249{
    250250  short vt = (marowi_ == veceli_) ? ColumnVector : RowVector;
    251   uint_4 rci = macoli_;
     251  int_4 rci = macoli_;
    252252  macoli_ = marowi_;
    253253  marowi_ = rci;
     
    268268  if (mm == SameMemoryMapping) mm = GetMemoryMapping(); 
    269269  TMatrix<T> tm(NCols(), NRows(), mm);
    270   for(uint_4 i=0; i<NRows(); i++)
    271     for(uint_4 j=0; j<NCols(); j++)
     270  for(sa_size_t i=0; i<NRows(); i++)
     271    for(sa_size_t j=0; j<NCols(); j++)
    272272      tm(j,i) = (*this)(i,j);
    273273  tm.SetTemp(true);
     
    292292 
    293293  TMatrix<T> tm(NRows(), NCols(), mm);
    294   for(uint_4 i=0; i<NRows(); i++)
    295     for(uint_4 j=0; j<NCols(); j++)
     294  for(sa_size_t i=0; i<NRows(); i++)
     295    for(sa_size_t j=0; j<NCols(); j++)
    296296      tm(i,j) = (*this)(i,j);
    297297  tm.SetTemp(true);
     
    304304{
    305305  if (ndim_ == 0) {
    306     uint_4 sz = imx.Size();
     306    sa_size_t sz = imx.Size();
    307307    if (sz < 1) sz = 1;
    308308    ReSize(sz, sz);
     
    312312    throw SzMismatchError("TMatrix::operator= (IdentityMatrix) NRows() != NCols()") ;
    313313  *this = (T) 0;
    314   for(uint_4 i=0; i<NRows(); i++) (*this)(i,i) = diag;
     314  for(sa_size_t i=0; i<NRows(); i++) (*this)(i,i) = diag;
    315315
    316316  return (*this);
     
    343343{
    344344  if (maxprt < 0)  maxprt = max_nprt_;
    345   uint_4 npr = 0;
     345  sa_size_t npr = 0;
    346346  Show(os, si);
    347347  if (ndim_ < 1)  return;
    348   uint_4 kc,kr; 
     348  sa_size_t kc,kr; 
    349349  for(kr=0; kr<size_[marowi_]; kr++) {
    350350    if ( (size_[marowi_] > 1) && (size_[macoli_] > 10) ) cout << "----- Ligne Line= " << kr << endl;
     
    352352      if(kc > 0) os << ", "; 
    353353      os << (*this)(kr, kc);   npr++;
    354       if (npr >= (uint_4) maxprt) {
     354      if (npr >= (sa_size_t) maxprt) {
    355355        if (npr < totsize_)  os << "\n     .... " << endl; return;
    356356      }
     
    380380  const T * peb;
    381381  T sum;
    382   uint_4 r,c,k;
    383   uint_4 stepa = Step(ColsKA());
    384   uint_4 stepb = 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());
    385385  // Calcul de C=rm = A*B   (A=*this)
    386386  for(r=0; r<rm.NRows(); r++)      // Boucle sur les lignes de A
  • trunk/SophyaLib/TArray/tmatrix.h

    r1103 r1156  
    1515  // Creation / destruction
    1616  TMatrix();
    17   TMatrix(uint_4 r,uint_4 c, short mm=BaseArray::AutoMemoryMapping);
     17  TMatrix(sa_size_t r,sa_size_t c, short mm=BaseArray::AutoMemoryMapping);
    1818  TMatrix(const TMatrix<T>& a);
    1919  TMatrix(const TMatrix<T>& a, bool share);
     
    4242  // Size - Changing the Size
    4343  //! return number of rows
    44   inline uint_4 NRows() const {return Size(marowi_); }
     44  inline sa_size_t NRows() const {return Size(marowi_); }
    4545  //! return number of columns
    46   inline uint_4 NCols() const {return Size(macoli_); }
     46  inline sa_size_t NCols() const {return Size(macoli_); }
    4747  //! return number of columns
    48   inline uint_4 NCol()  const {return Size(macoli_); } // back-compat Peida
    49 
    50   void ReSize(uint_4 r,uint_4 c, short mm=BaseArray::SameMemoryMapping);  // Reallocation de place
    51   void Realloc(uint_4 r,uint_4 c, 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);
    5252
    5353  // Sub-matrix extraction $CHECK$ Reza 03/2000  Doit-on declarer ces methode const ?
     
    5858  // Lignes et colonnes de la matrice
    5959  //! Return submatrix define by line \b ir (line vector)
    60   inline TMatrix<T> Row(uint_4 ir) const
     60  inline TMatrix<T> Row(sa_size_t ir) const
    6161                    { return SubMatrix(Range(ir,ir), Range(0,NCols()-1)); }
    6262  //! Return submatrix define by column \b ic (column vector)
    63   inline TMatrix<T> Column(uint_4 ic) const
     63  inline TMatrix<T> Column(sa_size_t ic) const
    6464                    { return SubMatrix(Range(0,NRows()-1), Range(ic,ic)); }
    6565
    6666  // Inline element acces methods
    67   inline T const& operator()(uint_4 r,uint_4 c) const;
    68   inline T&       operator()(uint_4 r,uint_4 c);
     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);
    6969
    7070  // Operations matricielles
     
    116116 //! () : return element for line \b r and column \b c
    117117template <class T>
    118 inline T const& TMatrix<T>::operator()(uint_4 r, uint_4 c) const
     118inline T const& TMatrix<T>::operator()(sa_size_t r, sa_size_t c) const
    119119{
    120120#ifdef SO_BOUNDCHECKING
     
    128128//! () : return element for line \b r and column \b c
    129129template <class T>
    130 inline T & TMatrix<T>::operator()(uint_4 r, uint_4 c)
     130inline T & TMatrix<T>::operator()(sa_size_t r, sa_size_t c)
    131131{
    132132#ifdef SO_BOUNDCHECKING
     
    188188    result.Div(b, true); return result;}
    189189
     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.  */
     196template <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
    190200
    191201// Surcharge d'operateurs C = A (+,-) B
  • trunk/SophyaLib/TArray/tvector.cc

    r1103 r1156  
    1 // $Id: tvector.cc,v 1.10 2000-07-27 00:00:10 ansari Exp $
     1// $Id: tvector.cc,v 1.11 2000-08-29 16:10:31 ansari Exp $
    22//                         C.Magneville          04/99
    33#include "machdefs.h"
     
    3131 */
    3232template <class T>
    33 TVector<T>::TVector(uint_4 n, short lcv, short mm)
     33TVector<T>::TVector(sa_size_t n, short lcv, short mm)
    3434// Constructeur
    3535  : TMatrix<T>(1,1,mm)
     
    121121 */
    122122template <class T>
    123 void TVector<T>::ReSize(uint_4 n, short lcv)
     123void TVector<T>::ReSize(sa_size_t n, short lcv)
    124124{
    125125  if( n == 0 )
    126126    throw(SzMismatchError("TVector::ReSize() n = 0 "));
    127   uint_4 r,c;
     127  sa_size_t r,c;
    128128  if (lcv == SameVectorType)  lcv = GetVectorType();
    129129  else if ( (lcv != ColumnVector) && (lcv != RowVector) ) lcv = GetDefaultVectorType();
     
    143143 */
    144144template <class T>
    145 void TVector<T>::Realloc(uint_4 n, short lcv, bool force)
     145void TVector<T>::Realloc(sa_size_t n, short lcv, bool force)
    146146{
    147147  if( n == 0 )
    148148    throw(SzMismatchError("TVector::Realloc() n = 0 "));
    149   uint_4 r,c;
     149  sa_size_t r,c;
    150150  if (lcv == SameVectorType)  lcv = GetVectorType();
    151151  else if ( (lcv != ColumnVector) && (lcv != RowVector) ) lcv = GetDefaultVectorType();
     
    175175{
    176176  T ret = 0;
    177   for(uint_8 k=0; k<Size(); k++)   ret += (*this)(k)*(*this)(k);
     177  for(sa_size_t k=0; k<Size(); k++)   ret += (*this)(k)*(*this)(k);
    178178  return ret;
    179179}
  • trunk/SophyaLib/TArray/tvector.h

    r1103 r1156  
    1414  // Creation / destruction
    1515  TVector();
    16   TVector(uint_4 n, short lcv=AutoVectorType, short mm=AutoMemoryMapping);
     16  TVector(sa_size_t n, short lcv=AutoVectorType, short mm=AutoMemoryMapping);
    1717  TVector(const TVector<T>& v);
    1818  TVector(const TVector<T>& v, bool share);
     
    3939   
    4040  // Gestion taille/Remplissage
    41   void ReSize(uint_4 n, short lcv=SameVectorType );
    42   void Realloc(uint_4 n, 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);
    4343
    4444  // Sub-Vector extraction $CHECK$ Reza 03/2000  Doit-on declarer cette methode const ?
     
    5050  // Informations pointeur/data
    5151  //! return the number of elements
    52   inline uint_4 NElts() const {return Size(); }
     52  inline sa_size_t NElts() const {return Size(); }
    5353 
    5454  // Inline element acces methods
    55   inline T const& operator()(uint_4 n) const;
    56   inline T&       operator()(uint_4 n);
     55  inline T const& operator()(sa_size_t n) const;
     56  inline T&       operator()(sa_size_t n);
    5757
    5858  // Operateur d'affectation
     
    8989//! Return the value of element \b n
    9090template <class T>
    91 inline T const& TVector<T>::operator()(uint_4 n) const
     91inline T const& TVector<T>::operator()(sa_size_t n) const
    9292{
    9393#ifdef SO_BOUNDCHECKING
     
    100100//! Return the value of element \b n
    101101template <class T>
    102 inline T & TVector<T>::operator()(uint_4 n)
     102inline T & TVector<T>::operator()(sa_size_t n)
    103103{
    104104#ifdef SO_BOUNDCHECKING
  • trunk/SophyaLib/TArray/utilarr.cc

    r1103 r1156  
    4848}
    4949
    50 MuTyV & RandomSequence::Value(uint_8 k) const
     50MuTyV & RandomSequence::Value(sa_size_t k) const
    5151{
    5252  if (typ_ == Flat) retv_ = drandpm1()*sig_ + mean_;
     
    9696 */
    9797
    98 MuTyV & RegularSequence::Value (uint_8 k) const
     98MuTyV & RegularSequence::Value (sa_size_t k) const
    9999{
    100100  double x = start_+(double)k*step_;
     
    108108}
    109109
    110 MuTyV & EnumeratedSequence::Value (uint_8 k) const
     110MuTyV & EnumeratedSequence::Value (sa_size_t k) const
    111111{
    112112  if (k >= vecv_.size())  retv_ = 0;
     
    117117EnumeratedSequence & EnumeratedSequence::operator , (MuTyV const & v)
    118118{
     119  vecv_.push_back(v);
     120  return(*this);
     121}
     122
     123EnumeratedSequence & EnumeratedSequence::operator = (MuTyV const & v)
     124{
     125  vecv_.clear();
    119126  vecv_.push_back(v);
    120127  return(*this);
     
    139146  \warning If not \b size is fixed and \b end recomputed
    140147 */
    141 Range::Range(uint_4 start, uint_4 end, uint_4 size, uint_4 step)
     148Range::Range(sa_size_t start, sa_size_t end, sa_size_t size, sa_size_t step)
    142149{
    143150  start_ = start;
     
    155162
    156163/*
    157 Range & Range::operator = (uint_4 start)
     164Range & Range::operator = (sa_size_t start)
    158165{
    159166  start_ = start;
     
    173180
    174181//! Constructor of a (n,n) diagonal matrix with value diag on the diagonal
    175 IdentityMatrix::IdentityMatrix(double diag, uint_4 n)
     182IdentityMatrix::IdentityMatrix(double diag, sa_size_t n)
    176183{
    177184  size_ = n;
  • trunk/SophyaLib/TArray/utilarr.h

    r1103 r1156  
    3232public:
    3333  virtual ~Sequence();
    34   virtual MuTyV & Value(uint_8 k) const = 0;
    35   inline MuTyV & operator () (uint_8 k) 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)) ; }
    3636};
    3737
     
    4646  explicit RandomSequence(int typ = RandomSequence::Gaussian, double m=0., double s=1.);
    4747  virtual  ~RandomSequence();
    48   virtual MuTyV & Value(uint_8 k) const ;
     48  virtual MuTyV & Value(sa_size_t k) const ;
    4949  double   Rand();
    5050
     
    6868  inline double & Step() { return step_; }
    6969
    70   virtual MuTyV & Value(uint_8 k) const ;
     70  virtual MuTyV & Value(sa_size_t k) const ;
    7171
    7272protected:
     
    8080public:
    8181  virtual ~EnumeratedSequence();
    82   virtual MuTyV & Value(uint_8 k) const ;
     82  virtual MuTyV & Value(sa_size_t k) const ;
    8383  EnumeratedSequence & operator , (MuTyV const & v);
     84  EnumeratedSequence & operator = (MuTyV const & v);
    8485private:
    8586  vector<MuTyV> vecv_;
     
    8788};
    8889
    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) ; }
    9192
    9293//////////////////////////////////////////////////////////
     
    9495class Range {
    9596public:
    96   explicit Range(uint_4 start=0, uint_4 end=0, uint_4 size=1, uint_4 step=1);
     97  explicit Range(sa_size_t start=0, sa_size_t end=0, sa_size_t size=1, sa_size_t step=1);
    9798  //! Return the start index
    98   inline uint_4 & Start()  {  return start_; }
     99  inline sa_size_t & Start()  {  return start_; }
    99100  //! Return the last index
    100   inline uint_4 & End()    {  return end_; }
     101  inline sa_size_t & End()    {  return end_; }
    101102  //! Return the size
    102   inline uint_4 & Size()   {  return size_; }
     103  inline sa_size_t & Size()   {  return size_; }
    103104  //! Return the step
    104   inline uint_4 & Step()   {  return step_; }
     105  inline sa_size_t & Step()   {  return step_; }
    105106protected:
    106   uint_4 start_; //!< start index
    107   uint_4 end_;   //!< end index
    108   uint_4 size_;  //!< size
    109   uint_4 step_;  //!< step
     107  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
    110111};
    111112
     
    114115class IdentityMatrix {
    115116public:
    116   explicit IdentityMatrix(double diag=1., uint_4 n=0);
     117  explicit IdentityMatrix(double diag=1., sa_size_t n=0);
    117118  //! return the size of the identity matrix
    118   inline uint_4 Size() { return size_; }
     119  inline sa_size_t Size() { return size_; }
    119120  //! return the value of the diagonal elements
    120121  inline double Diag() { return diag_; }
    121122protected:
    122   uint_4 size_; //!< size of the matrix
     123  sa_size_t size_; //!< size of the matrix
    123124  double diag_; //!< value of the diagonal elements
    124125};
Note: See TracChangeset for help on using the changeset viewer.