Changeset 813 in Sophya for trunk/SophyaLib/TArray/tvector.cc
- Timestamp:
- Apr 5, 2000, 5:44:19 PM (25 years ago)
- 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:59ansari Exp $1 // $Id: tvector.cc,v 1.3 2000-04-05 15:44:17 ansari Exp $ 2 2 // C.Magneville 04/99 3 3 #include "machdefs.h" … … 18 18 TVector<T>::TVector(uint_4 n, short lcv, short mm) 19 19 // Constructeur 20 : TMatrix<T>( (lcv == ColumnVector) ? n : 1,(lcv == ColumnVector) ? 1 : 0,mm)20 : TMatrix<T>(1,1,mm) 21 21 { 22 if (lcv == ColumnVector) veceli_ = marowi_;23 else veceli_ = macoli_;22 lcv = SelectVectorType(lcv); 23 ReSize(n,lcv); 24 24 } 25 25 … … 43 43 : TMatrix<T>(a) 44 44 { 45 if ( (size_[0] != 1) && (size_[1] != 1) ) 46 throw SzMismatchError("TVector<T>::TVector(const TArray<T>& a) NRows()!=1 && NCols()!=1 "); 45 47 } 46 48 47 49 48 50 template <class T> 49 TVector<T>::TVector(const TArray<T>& a, bool share, short lcv, short mm)51 TVector<T>::TVector(const TArray<T>& a, bool share, short mm, short lcv ) 50 52 : TMatrix<T>(a, share, mm) 51 53 { 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_; 56 60 } 57 61 } … … 70 74 throw(SzMismatchError("TVector::ReSize() n = 0 ")); 71 75 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(); 73 78 if (lcv == ColumnVector) { r = n; c = 1; } 74 79 else { c = n; r = 1; } 75 80 TMatrix<T>::ReSize(r,c); 81 veceli_ = (lcv == ColumnVector ) ? marowi_ : macoli_; 76 82 } 77 83 … … 82 88 throw(SzMismatchError("TVector::Realloc() n = 0 ")); 83 89 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(); 85 92 if (lcv == ColumnVector) { r = n; c = 1; } 86 93 else { c = n; r = 1; } 87 94 TMatrix<T>::Realloc(r,c,SameMemoryMapping,force); 95 veceli_ = (lcv == ColumnVector ) ? marowi_ : macoli_; 88 96 } 89 97 90 98 // $CHECK$ Reza 03/2000 Doit-on declarer cette methode const ? 91 99 template <class T> 92 TVector<T> TVector<T>:: operator ()(Range relt) const100 TVector<T> TVector<T>::SubVector(Range relt) const 93 101 { 94 102 Range rr, cr; … … 109 117 } 110 118 119 template <class T> 120 string 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 } 111 130 112 131 ///////////////////////////////////////////////////////////////
Note:
See TracChangeset
for help on using the changeset viewer.