Changeset 813 in Sophya for trunk/SophyaLib/TArray/tvector.cc


Ignore:
Timestamp:
Apr 5, 2000, 5:44:19 PM (25 years ago)
Author:
ansari
Message:

Correction bug/amelioarions TArray,TMatrix,TVector - Reza 5/4/2000

File:
1 edited

Legend:

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

    r804 r813  
    1 // $Id: tvector.cc,v 1.2 2000-04-03 17:35:59 ansari Exp $
     1// $Id: tvector.cc,v 1.3 2000-04-05 15:44:17 ansari Exp $
    22//                         C.Magneville          04/99
    33#include "machdefs.h"
     
    1818TVector<T>::TVector(uint_4 n, short lcv, short mm)
    1919// Constructeur
    20   : TMatrix<T>((lcv == ColumnVector) ? n : 1,(lcv == ColumnVector) ? 1 : 0, mm)
     20  : TMatrix<T>(1,1,mm)
    2121{
    22   if (lcv == ColumnVector) veceli_ = marowi_;
    23   else veceli_ = macoli_;
     22  lcv = SelectVectorType(lcv);
     23  ReSize(n,lcv);
    2424}
    2525
     
    4343: TMatrix<T>(a)
    4444{
     45  if ( (size_[0] != 1) && (size_[1] != 1) )
     46    throw SzMismatchError("TVector<T>::TVector(const TArray<T>& a) NRows()!=1 && NCols()!=1 ");
    4547}
    4648
    4749
    4850template <class T>
    49 TVector<T>::TVector(const TArray<T>& a, bool share, short lcv, short mm )
     51TVector<T>::TVector(const TArray<T>& a, bool share, short mm, short lcv )
    5052: TMatrix<T>(a, share, mm)
    5153{
    52   if (lcv == SameTypeVector) veceli_ = a.VectKA();
    53   else {
    54     if (lcv == ColumnVector) veceli_ = marowi_;
    55     else veceli_ = macoli_;
     54  if ( (size_[0] != 1) && (size_[1] != 1) )
     55    throw SzMismatchError("TVector<T>::TVector(const TArray<T>& a) NRows()!=1 && NCols()!=1 ");
     56  if ( (size_[0] == 1) && (size_[1] == 1) ) {
     57    if (lcv == SameVectorType) lcv = a.GetVectorType();
     58    if ( (lcv != ColumnVector) && (lcv != RowVector) ) lcv = GetDefaultVectorType();
     59    veceli_ = (lcv ==  ColumnVector ) ?  marowi_ : macoli_;
    5660  }
    5761}
     
    7074    throw(SzMismatchError("TVector::ReSize() n = 0 "));
    7175  uint_4 r,c;
    72   if (lcv == SameTypeVector)  lcv = GetVectorType();
     76  if (lcv == SameVectorType)  lcv = GetVectorType();
     77  else if ( (lcv != ColumnVector) && (lcv != RowVector) ) lcv = GetDefaultVectorType();
    7378  if (lcv == ColumnVector) { r = n;  c = 1; }
    7479  else { c = n; r = 1; }
    7580  TMatrix<T>::ReSize(r,c);
     81  veceli_ = (lcv ==  ColumnVector ) ?  marowi_ : macoli_;
    7682}
    7783
     
    8288    throw(SzMismatchError("TVector::Realloc() n = 0 "));
    8389  uint_4 r,c;
    84   if (lcv == SameTypeVector)  lcv = GetVectorType();
     90  if (lcv == SameVectorType)  lcv = GetVectorType();
     91  else if ( (lcv != ColumnVector) && (lcv != RowVector) ) lcv = GetDefaultVectorType();
    8592  if (lcv == ColumnVector) { r = n;  c = 1; }
    8693  else { c = n; r = 1; }
    8794  TMatrix<T>::Realloc(r,c,SameMemoryMapping,force);
     95  veceli_ = (lcv ==  ColumnVector ) ?  marowi_ : macoli_;
    8896}
    8997
    9098// $CHECK$ Reza 03/2000  Doit-on declarer cette methode const ?
    9199template <class T>
    92 TVector<T> TVector<T>::operator () (Range relt) const
     100TVector<T> TVector<T>::SubVector(Range relt) const
    93101{
    94102  Range rr, cr;
     
    109117}
    110118
     119template <class T>
     120string TVector<T>::InfoString() const
     121{
     122  string rs = "TVector<";
     123  rs += typeid(T).name();
     124  char buff[64];
     125  sprintf(buff, ">(%ld) (nr=%ld, nc=%ld)", (long)NElts(), (long)NRows(), (long)NCols());
     126  rs += buff;
     127  return(rs); 
     128
     129}
    111130
    112131///////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.