Changeset 1099 in Sophya for trunk/SophyaLib/TArray


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

Location:
trunk/SophyaLib/TArray
Files:
8 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_;
  • trunk/SophyaLib/TArray/basarr.h

    r1081 r1099  
    6262
    6363  // Returns true if ndim and sizes are equal
    64   virtual bool CompareSizes(const BaseArray& a);
     64  virtual bool CompareSizes(const BaseArray& a, bool& smo);
    6565
    6666  // Compacts \b size=1 array dimensions
     
    8383  inline uint_4 Size(int ka) const { return(size_[CheckDI(ka,1)]); }
    8484
    85   uint_4 MaxSizeKA() const ;
     85  int MaxSizeKA() const ;
    8686
    8787  //! Get memory organization
    88   inline short GetMemoryMapping() const
     88  inline short  GetMemoryMapping() const
    8989         { return ( (marowi_ == 1) ? CMemoryMapping : FortranMemoryMapping) ; }
    9090  //! line index dimension
    91   inline uint_4 RowsKA() const {return marowi_; }
     91  inline int    RowsKA() const {return marowi_; }
    9292  //! column index dimension
    93   inline uint_4 ColsKA() const {return macoli_; }
     93  inline int    ColsKA() const {return macoli_; }
    9494  //! Index dimension of the elements of a vector
    95   inline uint_4 VectKA() const {return veceli_; }
     95  inline int    VectKA() const {return veceli_; }
    9696  void          SetMemoryMapping(short mm=AutoMemoryMapping);
    9797
     
    126126  inline uint_4 Step(int ka) const { return(step_[CheckDI(ka,3)]); }
    127127
    128   uint_4 MinStepKA() const ;
     128  int MinStepKA() const ;
    129129
    130130  // Offset of element ip
     
    137137  virtual MuTyV & ValueAtPosition(uint_8 ip) const = 0;
    138138
    139  // Impression, I/O, ...
     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);
     142  // Impression, I/O, ...
    140143  void           Show(ostream& os, bool si=false) const;
    141144  //! Show information on \b cout
     
    166169  uint_4 size_[BASEARRAY_MAXNDIMS]; //!< array of the size in each dimension
    167170  uint_8 totsize_; //!< Total number of elements
     171  uint_8 offset_;  //!< global offset -\> position of elem[0] in DataBlock
    168172  //! two consecutive elements distance in a given dimension
    169173  uint_4 step_[BASEARRAY_MAXNDIMS];
    170174  uint_4 minstep_; //!< minimal step (in any axes)
    171175  uint_4 moystep_; //!< mean step, if == 0 --\> non regular steps
    172   uint_8 offset_;  //!< global offset -\> position of elem[0] in DataBlock
    173   uint_4 marowi_; //!< For matrices, Row index in dimensions
    174   uint_4 macoli_; //!< For matrices, Column index in dimensions
    175   uint_4 veceli_; //!< For vectors, dimension index = marowi_/macoli_ (Row/Col vectors)
    176   bool ck_memo_vt_; //!< if true, check MemoryOrg./VectorType for CompareSize
     176  int_2  marowi_; //!< For matrices, Row index in dimensions
     177  int_2  macoli_; //!< For matrices, Column index in dimensions
     178  int_2  veceli_; //!< For vectors, dimension index = marowi_/macoli_ (Row/Col vectors)
     179  int_2 arrtype_; //!< 0 a TArray, 1 TMatrix , 2 TVector
    177180  DVList* mInfo;    //!< Infos (variables) attached to the array
    178181
  • trunk/SophyaLib/TArray/matharr.cc

    r1013 r1099  
    148148  mean /= dsz;
    149149  sig = sig/dsz - mean*mean;
    150 //   #if !defined(OS_LINUX) && !defined (__KCC__) 
    151150#if !defined(__GNUG__) && !defined (__MWERKS__)
    152151  if (sig >= 0.) sig = sqrt(sig);
  • trunk/SophyaLib/TArray/tarray.cc

    r1085 r1099  
    223223void TArray<T>::ReSize(uint_4 ndim, uint_4 * siz, uint_4 step)
    224224{
     225  if (arrtype_ != 0) {
     226    if (ndim != 2)
     227       throw( ParmError("TArray<T>::ReSize(ndim!=2,...) for Matrix" ) );
     228    if ((arrtype_ == 2) && (siz[0] > 1) && (siz[1] > 1))
     229       throw( ParmError("TArray<T>::ReSize(,siz[0]>1 && size[1]>1) for Vector" ) );
     230  }
    225231  string exmsg = "TArray<T>::ReSize()";
    226232  if (!UpdateSizes(ndim, siz, step, 0, exmsg))  throw( ParmError(exmsg) );
     
    239245void TArray<T>::Realloc(uint_4 ndim, uint_4 * siz, uint_4 step, bool force)
    240246{
     247  if (arrtype_ != 0) {
     248    if (ndim != 2)
     249       throw( ParmError("TArray<T>::Realloc(ndim!=2,...) for Matrix" ) );
     250    if ((arrtype_ == 2) && (siz[0] > 1) && (siz[1] > 1))
     251       throw( ParmError("TArray<T>::Realloc(,siz[0]>1 && size[1]>1) for Vector" ) );
     252  }
    241253  string exmsg = "TArray<T>::Realloc()";
    242254  if (!UpdateSizes(ndim, siz, step, 0, exmsg))  throw( ParmError(exmsg) );
     
    545557  if (NbDimensions() < 1)
    546558    throw RangeCheckError("TArray<T>::AddElt(const TArray<T>& )  - Not Allocated Array ! ");
    547   if (!CompareSizes(a))
     559  bool smo;
     560  if (!CompareSizes(a, smo))
    548561    throw(SzMismatchError("TArray<T>::AddElt(const TArray<T>&) SizeMismatch")) ;
    549562
     
    551564  const T * pea;
    552565  uint_8 j,k,ka;
    553   if ((AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
     566  if (smo && (AvgStep() > 0) && (a.AvgStep() > 0))   {  // regularly spaced elements
    554567    uint_8 step = AvgStep();
    555568    uint_8 stepa = a.AvgStep();
     
    560573  }
    561574  else {    // Non regular data spacing ...
    562     uint_4 ax = MaxSizeKA();
    563     uint_8 step = Step(ax);
    564     uint_8 stepa = a.Step(ax);
    565     uint_8 gpas = Size(ax)*step;
    566     uint_8 naxa = Size()/Size(ax);
     575    int ax,axa;
     576    uint_8 step, stepa;
     577    uint_8 gpas, naxa;
     578    GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
    567579    for(j=0; j<naxa; j++)  {
    568580      pe = mNDBlock.Begin()+Offset(ax,j);
    569       pea = a.DataBlock().Begin()+a.Offset(ax,j);
     581      pea = a.DataBlock().Begin()+a.Offset(axa,j);
    570582      for(k=0, ka=0;  k<gpas;  k+=step, ka+=stepa)  pe[k] += pea[ka];
    571583    }
     
    584596  if (NbDimensions() < 1)
    585597    throw RangeCheckError("TArray<T>::SubElt(const TArray<T>& )  - Not Allocated Array ! ");
    586   if (!CompareSizes(a))
     598  bool smo;
     599  if (!CompareSizes(a, smo))
    587600    throw(SzMismatchError("TArray<T>::SubElt(const TArray<T>&) SizeMismatch")) ;
    588601
     
    590603  const T * pea;
    591604  uint_8 j,k,ka;
    592   if ((AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
     605  if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
    593606    uint_8 step = AvgStep();
    594607    uint_8 stepa = a.AvgStep();
     
    602615  }
    603616  else {    // Non regular data spacing ...
    604     uint_4 ax = MaxSizeKA();
    605     uint_8 step = Step(ax);
    606     uint_8 stepa = a.Step(ax);
    607     uint_8 gpas = Size(ax)*step;
    608     uint_8 naxa = Size()/Size(ax);
     617    int ax,axa;
     618    uint_8 step, stepa;
     619    uint_8 gpas, naxa;
     620    GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
    609621    for(j=0; j<naxa; j++)  {
    610622      pe = mNDBlock.Begin()+Offset(ax,j);
    611       pea = a.DataBlock().Begin()+a.Offset(ax,j);
     623      pea = a.DataBlock().Begin()+a.Offset(axa,j);
    612624      if (fginv)
    613625        for(k=0, ka=0;  k<gpas;  k+=step, ka+=stepa)  pe[k] = pea[ka]-pe[k] ;
     
    626638  if (NbDimensions() < 1)
    627639    throw RangeCheckError("TArray<T>::MulElt(const TArray<T>& )  - Not Allocated Array ! ");
    628   if (!CompareSizes(a))
     640  bool smo;
     641  if (!CompareSizes(a, smo))
    629642    throw(SzMismatchError("TArray<T>::MulElt(const TArray<T>&) SizeMismatch")) ;
    630643
     
    632645  const T * pea;
    633646  uint_8 j,k,ka;
    634   if ((AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
     647  if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
    635648    uint_8 step = AvgStep();
    636649    uint_8 stepa = a.AvgStep();
     
    641654  }
    642655  else {    // Non regular data spacing ...
    643     uint_4 ax = MaxSizeKA();
    644     uint_8 step = Step(ax);
    645     uint_8 stepa = a.Step(ax);
    646     uint_8 gpas = Size(ax)*step;
    647     uint_8 naxa = Size()/Size(ax);
    648     for(j=0; j<naxa; j++)  {
    649       pe = mNDBlock.Begin()+Offset(ax,j);
    650       pea = a.DataBlock().Begin()+a.Offset(ax,j);
     656    int ax,axa;
     657    uint_8 step, stepa;
     658    uint_8 gpas, naxa;
     659    GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
     660    for(j=0; j<naxa; j++)  {
     661      pe = mNDBlock.Begin()+Offset(axa,j);
     662      pea = a.DataBlock().Begin()+a.Offset(axa,j);
    651663      for(k=0, ka=0;  k<gpas;  k+=step, ka+=stepa)  pe[k] *= pea[ka];
    652664    }
     
    667679  if (NbDimensions() < 1)
    668680    throw RangeCheckError("TArray<T>::DivElt(const TArray<T>& )  - Not Allocated Array ! ");
    669   if (!CompareSizes(a))
     681  bool smo;
     682  if (!CompareSizes(a, smo))
    670683    throw(SzMismatchError("TArray<T>::DivElt(const TArray<T>&) SizeMismatch")) ;
    671684
     
    673686  const T * pea;
    674687  uint_8 j,k,ka;
    675   if ((AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
     688  if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
    676689    uint_8 step = AvgStep();
    677690    uint_8 stepa = a.AvgStep();
     
    694707  }
    695708  else {    // Non regular data spacing ...
    696     uint_4 ax = MaxSizeKA();
    697     uint_8 step = Step(ax);
    698     uint_8 stepa = a.Step(ax);
    699     uint_8 gpas = Size(ax)*step;
    700     uint_8 naxa = Size()/Size(ax);
     709    int ax,axa;
     710    uint_8 step, stepa;
     711    uint_8 gpas, naxa;
     712    GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
    701713    for(j=0; j<naxa; j++)  {
    702714      pe = mNDBlock.Begin()+Offset(ax,j);
    703       pea = a.DataBlock().Begin()+a.Offset(ax,j);
     715      pea = a.DataBlock().Begin()+a.Offset(axa,j);
    704716      if(divzero) {
    705717        if (fginv)
     
    726738  if (NbDimensions() < 1)
    727739    throw RangeCheckError("TArray<T>::CopyElt(const TArray<T>& )  - Not Allocated Array ! ");
    728   if (!CompareSizes(a))
     740  bool smo;
     741  if (!CompareSizes(a, smo))
    729742    throw(SzMismatchError("TArray<T>::CopyElt(const TArray<T>&) SizeMismatch")) ;
    730743
     
    732745  const T * pea;
    733746  uint_8 j,k,ka;
    734   if ((AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
     747  if (smo && (AvgStep() > 0) && (a.AvgStep() > 0) )   {  // regularly spaced elements
    735748    uint_8 step = AvgStep();
    736749    uint_8 stepa = a.AvgStep();
     
    741754  }
    742755  else {    // Non regular data spacing ...
    743     uint_4 ax = MaxSizeKA();
    744     uint_8 step = Step(ax);
    745     uint_8 stepa = a.Step(ax);
    746     uint_8 gpas = Size(ax)*step;
    747     uint_8 naxa = Size()/Size(ax);
     756    int ax,axa;
     757    uint_8 step, stepa;
     758    uint_8 gpas, naxa;
     759    GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
    748760    for(j=0; j<naxa; j++)  {
    749761      pe = mNDBlock.Begin()+Offset(ax,j);
    750       pea = a.DataBlock().Begin()+a.Offset(ax,j);
     762      pea = a.DataBlock().Begin()+a.Offset(axa,j);
    751763      for(k=0, ka=0;  k<gpas;  k+=step, ka+=stepa)  pe[k] = pea[ka];
    752764    }
     
    761773  if (NbDimensions() < 1)
    762774    throw RangeCheckError("TArray<T>::ConvertAndCopyElt(const TArray<T>& )  - Not Allocated Array ! ");
    763   if (!CompareSizes(a))
     775  bool smo;
     776  if (!CompareSizes(a, smo))
    764777    throw(SzMismatchError("TArray<T>::ConvertAndCopyElt(const TArray<T>&) SizeMismatch")) ;
    765778
     
    768781  uint_8 offa;
    769782  // Non regular data spacing ...
    770   uint_4 ax = MaxSizeKA();
    771   uint_8 step = Step(ax);
    772   uint_8 stepa = a.Step(ax);
    773   uint_8 gpas = Size(ax)*step;
    774   uint_8 naxa = Size()/Size(ax);
     783  int ax,axa;
     784  uint_8 step, stepa;
     785  uint_8 gpas, naxa;
     786  GetOpeParams(a, smo, ax, axa, step, stepa, gpas, naxa);
    775787  for(j=0; j<naxa; j++)  {
    776788    pe = mNDBlock.Begin()+Offset(ax,j);
    777     offa = a.Offset(ax,j);
     789    offa = a.Offset(axa,j);
    778790#if !defined(__GNUG__)
    779791    for(k=0, ka=0;  k<gpas;  k+=step, ka+=stepa)  pe[k] = (T)a.ValueAtPosition(offa+ka);
  • trunk/SophyaLib/TArray/tmatrix.cc

    r1081 r1099  
    1 // $Id: tmatrix.cc,v 1.13 2000-07-24 12:51:27 ansari Exp $
     1// $Id: tmatrix.cc,v 1.14 2000-07-26 16:29:45 ansari Exp $
    22//                         C.Magneville          04/99
    33#include "machdefs.h"
     
    2222  : TArray<T>()
    2323{
    24   ck_memo_vt_ = true;
     24  arrtype_ = 1;   // Type = Matrix
    2525}
    2626
     
    3939  if ( (r == 0) || (c == 0) )
    4040    throw ParmError("TMatrix<T>::TMatrix(uint_4 r,uint_4 c) NRows or NCols = 0");
     41  arrtype_ = 1;   // Type = Matrix
    4142  ReSize(r, c, mm);
    4243}
     
    5253  : TArray<T>(a)
    5354{
     55  arrtype_ = 1;   // Type = Matrix
    5456}
    5557
     
    6365: TArray<T>(a, share)
    6466{
     67  arrtype_ = 1;   // Type = Matrix
    6568}
    6669
     
    7780    ndim_ = 2;
    7881  }
     82  arrtype_ = 1;   // Type = Matrix
    7983  UpdateMemoryMapping(a, SameMemoryMapping);
    8084}
     
    97101    ndim_ = 2;
    98102  }
     103  arrtype_ = 1;   // Type = Matrix
    99104  UpdateMemoryMapping(a, mm);
    100105}
    101106
     107//! Constructor of a matrix from a TArray \b a , with a different data type
    102108template <class T>
    103109TMatrix<T>::TMatrix(const BaseArray& a)
    104110: TArray<T>()
    105111{
     112  arrtype_ = 1;   // Type = Matrix
    106113  SetBA(a);
    107114}
     
    125132  if (a.NbDimensions() > 2)
    126133    throw SzMismatchError("TMatrix<T>::Set(const TArray<T>& a) a.NbDimensions() > 2");
     134  if ((arrtype_ == 2) && (a.NbDimensions() > 1) && (a.Size(0) > 1) && (a.Size(1) > 1) )
     135    throw SzMismatchError("TMatrix<T>::Set(const TArray<T>& a) Size(0,1)>1 for Vector");
    127136  TArray<T>::Set(a);
    128137  if (NbDimensions() == 1) {
     
    140149  if (a.NbDimensions() > 2)
    141150    throw SzMismatchError("TMatrix<T>::SetBA(const BaseArray& a) a.NbDimensions() > 2");
     151  if ((arrtype_ == 2) && (a.NbDimensions() > 1) && (a.Size(0) > 1) && (a.Size(1) > 1) )
     152    throw SzMismatchError("TMatrix<T>::Set(const TArray<T>& a) Size(0,1)>1 for Vector");
    142153  TArray<T>::SetBA(a);
    143154  if (NbDimensions() == 1) {
     
    165176  if(r==0||c==0)
    166177    throw(SzMismatchError("TMatrix::ReSize r or c==0 "));
     178  if ((arrtype_ == 2) && (r > 1) && (c > 1))
     179    throw(SzMismatchError("TMatrix::ReSize r>1&&c>1 for Vector "));
    167180  uint_4 size[BASEARRAY_MAXNDIMS];
    168181  for(int kk=0; kk<BASEARRAY_MAXNDIMS; kk++)  size[kk] = 0;
     
    194207  if(r==0||c==0)
    195208    throw(SzMismatchError("TMatrix::Realloc r or c==0 "));
     209  if ((arrtype_ == 2) && (r > 1) && (c > 1))
     210    throw(SzMismatchError("TMatrix::Realloc r>1&&c>1 for Vector "));
    196211  uint_4 size[BASEARRAY_MAXNDIMS];
    197212  for(int kk=0; kk<BASEARRAY_MAXNDIMS; kk++)  size[kk] = 0;
  • trunk/SophyaLib/TArray/tmatrix.h

    r1081 r1099  
    3131  inline  TMatrix<T>& operator = (const TMatrix<T>& a)
    3232                     { Set(a);  return(*this); }
     33  //! Operator = between a matrix and an array
     34  inline  TMatrix<T>& operator = (const TArray<T>& a)
     35                     { Set(a);  return(*this); }
    3336
    3437  virtual TArray<T>& SetBA(const BaseArray& a);
     38  //! Operator = between matrices with different types
    3539  inline  TMatrix<T>& operator = (const BaseArray& a)
    3640                     { SetBA(a);  return(*this); }
  • trunk/SophyaLib/TArray/tvector.cc

    r976 r1099  
    1 // $Id: tvector.cc,v 1.8 2000-04-27 17:53:52 ansari Exp $
     1// $Id: tvector.cc,v 1.9 2000-07-26 16:29:46 ansari Exp $
    22//                         C.Magneville          04/99
    33#include "machdefs.h"
     
    3535  : TMatrix<T>(1,1,mm)
    3636{
     37  arrtype_ = 2;   // Type = Vector
    3738  lcv = SelectVectorType(lcv);
    3839  ReSize(n,lcv);
     
    4950  : TMatrix<T>(a)
    5051{
     52  arrtype_ = 2;   // Type = Vector
    5153}
    5254
     
    6062: TMatrix<T>(a, share)
    6163{
     64  arrtype_ = 2;   // Type = Vector
    6265}
    6366
     
    6972  if ( (size_[0] != 1) && (size_[1] != 1) )
    7073    throw SzMismatchError("TVector<T>::TVector(const TArray<T>& a) NRows()!=1 && NCols()!=1 ");
     74  arrtype_ = 2;   // Type = Vector
    7175}
    7276
     
    8690  if ( (size_[0] != 1) && (size_[1] != 1) )
    8791    throw SzMismatchError("TVector<T>::TVector(const TArray<T>& a) NRows()!=1 && NCols()!=1 ");
     92  arrtype_ = 2;   // Type = Vector
    8893  if ( (size_[0] == 1) && (size_[1] == 1) ) {
    8994    if (lcv == SameVectorType) lcv = a.GetVectorType();
     
    9196    veceli_ = (lcv ==  ColumnVector ) ?  marowi_ : macoli_;
    9297  }
     98}
     99
     100//! Constructor of a vector from a TArray \b a , with a different data type
     101template <class T>
     102TVector<T>::TVector(const BaseArray& a)
     103: TMatrix<T>()
     104{
     105  arrtype_ = 2;   // Type = Vector
     106  SetBA(a);
    93107}
    94108
  • trunk/SophyaLib/TArray/tvector.h

    r976 r1099  
    1919  TVector(const TArray<T>& a);
    2020  TVector(const TArray<T>& a,  bool share, short lcv=AutoVectorType, short mm=AutoMemoryMapping);
     21  TVector(const BaseArray& a);
    2122
    2223  virtual ~TVector();
     
    2728  inline  TVector<T>& operator = (const TVector<T>& a)
    2829                       { Set(a);  return(*this); }
    29 
     30  //! Operator = between a vector and a matrix
     31  inline  TVector<T>& operator = (const TMatrix<T>& a)
     32                       { Set(a);  return(*this); }
     33  //! Operator = between a vector and an array
     34  inline  TVector<T>& operator = (const TArray<T>& a)
     35                       { Set(a);  return(*this); }
     36  //! Operator = between Vectors with different types
     37  inline  TVector<T>& operator = (const BaseArray& a)
     38                       { SetBA(a);  return(*this); }
     39   
    3040  // Gestion taille/Remplissage
    3141  void ReSize(uint_4 n, short lcv=SameVectorType );
Note: See TracChangeset for help on using the changeset viewer.