Changeset 1393 in Sophya for trunk/SophyaLib/TArray


Ignore:
Timestamp:
Feb 12, 2001, 6:09:03 PM (25 years ago)
Author:
ansari
Message:

Ajout methodes ReSize(TArray &) - Reza 12/2/2001

Location:
trunk/SophyaLib/TArray
Files:
2 edited

Legend:

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

    r1389 r1393  
    230230
    231231
    232 //! Resize array
     232//! Sets or changes the array size
    233233/*!
    234234  \param ndim : number of dimensions
     
    245245       throw( ParmError("TArray<T>::ReSize(,siz[0]>1 && size[1]>1) for Vector" ) );
    246246  }
    247   string exmsg = "TArray<T>::ReSize()";
     247  string exmsg = "TArray<T>::ReSize(int_4 ...)";
    248248  if (!UpdateSizes(ndim, siz, step, 0, exmsg))  throw( ParmError(exmsg) );
    249249  mNDBlock.ReSize(totsize_);   
     250}
     251
     252//! Sets or changes the array size.
     253/*!
     254  The array size and memory layout are copied from the array \b a.
     255  \param a : Array used as template for setting the size and memory layout.
     256 */
     257template <class T>
     258void TArray<T>::ReSize(const TArray<T>& a)
     259{
     260  if (arrtype_ != 0) {
     261    if (a.NbDimensions() != 2)
     262       throw( ParmError("TArray<T>::ReSize(a.NbDimensions()!=2,...) for Matrix" ) );
     263    if ((arrtype_ == 2) && (a.Size(0) > 1) && (a.Size(1) > 1))
     264       throw( ParmError("TArray<T>::ReSize(a.Size(0)>1 && a.Size(1)>1) for Vector" ) );
     265  }
     266  string exmsg = "TArray<T>::ReSize(const TArray<T>&)";
     267  if (!UpdateSizes(a, exmsg))  throw( ParmError(exmsg) );
     268  mNDBlock.ReSize(totsize_);     
    250269}
    251270
  • trunk/SophyaLib/TArray/tarray.h

    r1156 r1393  
    5555  void CloneOrShare(const TArray<T>& a);
    5656  // Share: partage les donnees de "a"
    57 
    5857  void Share(const TArray<T>& a);
     58
    5959  void ReSize(int_4 ndim, sa_size_t * siz, sa_size_t step=1);
     60  void ReSize(const TArray<T>& a);
     61  //! a synonym (alias) for method ReSize(int_4, ...)
     62  inline void SetSize(int_4 ndim, sa_size_t * siz, sa_size_t step=1)
     63                { ReSize(ndim, siz, step); }
     64  //! a synonym (alias) for method ReSize(const TArray<T>&)
     65  inline void SetSize(const TArray<T>& a)
     66                { ReSize(a); }
    6067  void Realloc(int_4 ndim, sa_size_t * siz, sa_size_t step=1, bool force=false);
    6168
Note: See TracChangeset for help on using the changeset viewer.