Changeset 1099 in Sophya for trunk/SophyaLib/TArray/basarr.cc


Ignore:
Timestamp:
Jul 26, 2000, 6:29:46 PM (25 years ago)
Author:
ansari
Message:

Protection integrite TMatrix,TVector - operateur = (BaseArray & pour TVector et operations entre matrices avec <> MemMapping (Pas termine) Reza 27/6/2000

File:
1 edited

Legend:

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

    r958 r1099  
    164164  }
    165165  else veceli_ = (vt ==  ColumnVector ) ?  marowi_ : macoli_;
    166   ck_memo_vt_ = true;   // Check MemMapping and VectorType for CompareSize 
    167166}
    168167
     
    196195  }
    197196  else veceli_ = (vt ==  ColumnVector ) ?  marowi_ : macoli_;
    198   ck_memo_vt_ = true;   // Check MemMapping and VectorType for CompareSize 
    199197}
    200198
     
    224222  }
    225223  else   veceli_ = (vt ==  ColumnVector ) ?  marowi_ : macoli_;
    226   ck_memo_vt_ = true;   // Check MemMapping and VectorType for CompareSize 
    227224}
    228225
     
    243240  }
    244241  else  veceli_ = (vt ==  ColumnVector ) ?  marowi_ : macoli_;
    245   ck_memo_vt_ = true;   // Check MemMapping and VectorType for CompareSize 
    246242}
    247243
     
    268264  }
    269265  veceli_ = (default_vector_type ==  ColumnVector ) ?  marowi_ : macoli_;
    270   ck_memo_vt_ = false;   // Default : Don't Check MemMapping and VectorType for CompareSize 
     266  arrtype_ = 0;    // Default Array type, not a Matrix or Vector
     267 
    271268}
    272269
     
    277274
    278275
    279 //! Returns true if dimension and sizes are equal
     276//! Returns true if the two arrays have compatible dimensions.
    280277/*!
    281278  \param a : array to be compared
    282   \return true if ndim and sizes[ndim] are equal, false if not
     279  \param smo : Return flag = true if the two arrays have the same memory organisation
     280  \return true if \c NbDimensions() and \c Size() are equal, false if not
     281
     282  If the array (on which the operation is being performed, \c this)
     283  is a \b Matrix or a \b Vector, the matrix dimensions \c NRows() \c NCols()
     284  are checked. The flag \c smo is returned true if the two arrays, viewed
     285  as a matrix have the same memory organisation.
     286  Otherwise, (if the array is of not a Matrix or a Vector)
     287  the size compatibility viewed as a TArray is checked <tt>
     288  (Size(k) == a.Size(k), k=0,...NbDimensions()), </tt> disregard of the memory
     289  organisation and the row and column index. The flag \c smo is returned true
     290  in this case.
    283291*/
    284 bool BaseArray::CompareSizes(const BaseArray& a)
     292bool BaseArray::CompareSizes(const BaseArray& a, bool& smo)
    285293{
    286294  if (ndim_ != a.ndim_)  return(false);
    287   for(uint_4 k=0; k<ndim_; k++)
    288     if (size_[k] != a.size_[k])  return(false);
    289   //  $CHECK$   Reza doit-on verifier ca
    290   if (ck_memo_vt_ && a.ck_memo_vt_)
    291     if ( (macoli_ != a.macoli_) || (marowi_ != a.marowi_) ||
    292          (veceli_ != a.veceli_) )  return(false);
    293   return(true);
     295  if (arrtype_ == 0) {  // Simple TArray, not a matrix
     296    smo = true;
     297    for(uint_4 k=0; k<ndim_; k++)
     298      if (size_[k] != a.size_[k])  return(false);
     299    return(true);
     300  }
     301  else {
     302    smo = false;
     303    if ( (size_[marowi_] != a.size_[marowi_]) ||
     304         (size_[macoli_] != a.size_[macoli_])  ) return(false);
     305    if ( (macoli_ == a.macoli_) && (marowi_ == a.marowi_) ||
     306         (veceli_ == a.veceli_) )  smo = true;
     307    return(true);
     308  }
    294309}
    295310
     
    336351
    337352//! return minimum value for step[ndim]
    338 uint_4 BaseArray::MinStepKA() const
    339 {
    340   for(uint_4 ka=0; ka<ndim_; ka++)
     353int BaseArray::MinStepKA() const
     354{
     355  for(int ka=0; ka<ndim_; ka++)
    341356    if (step_[ka] == minstep_) return(ka);
    342357  return(0);
     
    344359
    345360//! return maximum value for step[ndim]
    346 uint_4 BaseArray::MaxSizeKA() const
    347 {
    348   uint_4 ka = 0;
     361int BaseArray::MaxSizeKA() const
     362{
     363  int ka = 0;
    349364  uint_4 mx = size_[0];
    350   for(uint_4 k=0; k<ndim_; k++) 
    351     if (size_[k] > mx) {  ka = k;  mx = size_[k];  }
     365  for(int k=0; k<ndim_; k++) 
     366    if (size_[k] > mx) {  ka = k;  mx = size_[k]; }
    352367  return(ka);
    353368}
     
    410425}
    411426
     427//! return various parameters for double loop operations on two arrays.
     428void BaseArray::GetOpeParams(const BaseArray& a, bool smo, int& ax, int& axa, uint_8& step,
     429                             uint_8& stepa, uint_8& gpas, uint_8& naxa)
     430{
     431  if (smo) { // Same memory organisation
     432    ax = axa = MaxSizeKA();
     433  }
     434  else {
     435    if (Size(RowsKA()) >= Size(ColsKA()) ) {
     436      ax = RowsKA();
     437      axa = a.RowsKA();
     438    }
     439    else {
     440      ax = ColsKA();
     441      axa = a.ColsKA();
     442    }
     443  }
     444  step = Step(ax);
     445  stepa = a.Step(axa);
     446  gpas = Size(ax)*step;
     447  naxa = Size()/Size(ax);
     448  return;
     449}
    412450
    413451// ----------------------------------------------------
     
    505543  }
    506544  veceli_ = (default_vector_type ==  ColumnVector ) ?  marowi_ : macoli_;
    507   ck_memo_vt_ = false;   // Default : Don't Check MemMapping and VectorType for CompareSize 
    508545  // Update OK
    509546  ndim_ = ndim;
     
    562599  }
    563600  veceli_ = (default_vector_type ==  ColumnVector ) ?  marowi_ : macoli_;
    564   ck_memo_vt_ = false;   // Default : Don't Check MemMapping and VectorType for CompareSize 
    565601  // Update OK
    566602  ndim_ = ndim;
     
    609645  marowi_ = a.marowi_;
    610646  veceli_ = a.veceli_;
    611   ck_memo_vt_ = a.ck_memo_vt_;
    612647  // Update OK
    613648  ndim_ = a.ndim_;
Note: See TracChangeset for help on using the changeset viewer.