Changeset 4035 in Sophya
- Timestamp:
- Nov 14, 2011, 5:28:25 PM (13 years ago)
- Location:
- trunk/SophyaLib/TArray
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/TArray/basarr.cc
r3669 r4035 118 118 mm == FortranMemoryMapping : Fortran like memory mapping 119 119 \endverbatim 120 \return default memory mapping value 120 121 \verbatim 121 122 # ===== For Matrices … … 138 139 ex: Mc[2][0] = Mmath(3,1) = 31 139 140 Mc[0][2] = Mmath(1,3) = 13 140 *** RESUME diffIdl/Fortan/C/Math:141 *** SUMMARY difference Idl/Fortan/C/Math: 141 142 Midl(col-1,row-1) = Mfor(col,row) = Mc[row-1][col-1] = Mmath(row,col) 142 143 TRANSPOSE(column-major array) --> row-major array 143 144 \endverbatim 144 \return default memory mapping value145 145 */ 146 146 short BaseArray::SetDefaultMemoryMapping(short mm) … … 565 565 } 566 566 567 //! Return attached DVList567 //! Return the attached DVList info object 568 568 DVList& BaseArray::Info() 569 569 { … … 571 571 return(*mInfo); 572 572 } 573 574 573 575 574 576 //! Update sizes and information for array -
trunk/SophyaLib/TArray/basarr.h
r3572 r4035 160 160 virtual void WriteASCII(ostream& os) const = 0; 161 161 162 // DVList info Object162 // Access to the DVList info Object 163 163 DVList& Info(); 164 //! return true if the DVList info Object has been created (not empty) 165 inline bool HasInfoObject() const { return ((mInfo!=NULL)?true:false); } 166 167 //! Return the attached DVList object pointer (for special uses only TArray ... ) 168 inline DVList* getInfoPointer() const { return mInfo; } 164 169 165 170 protected: -
trunk/SophyaLib/TArray/tarray.cc
r3850 r4035 197 197 : BaseArray() , mNDBlock(a.mNDBlock) 198 198 { 199 if (a.NbDimensions() == 0) return; // Reza-Nov 2011: we allow copy contrsuctor on non allocated arrays 199 200 string exmsg = "TArray<T>::TArray(const TArray<T>&)"; 200 201 if (!UpdateSizes(a, exmsg)) throw( ParmError(exmsg) ); … … 210 211 : BaseArray() , mNDBlock(a.mNDBlock, share) 211 212 { 212 if (a.NbDimensions() == 0) return; 213 if (a.NbDimensions() == 0) return; // Reza-Nov 2011: we allow copy contrsuctor on non allocated arrays 213 214 string exmsg = "TArray<T>::TArray(const TArray<T>&, bool)"; 214 215 if (!UpdateSizes(a, exmsg)) throw( ParmError(exmsg) ); … … 216 217 } 217 218 218 //! Constructor with size and contents copied (after conversion) from a different type TArray 219 template <class T> 220 TArray<T>::TArray(const BaseArray& a) 219 //! Constructor with size and contents copied (after conversion) from an array with different data type. 220 /*! 221 The array size and memory layout are copied from the array \b a, or a packed array is created if \b pack==true. 222 \param a : original array, to copy sizes and data from 223 \param pack : if \b true , create a packed array, else same memory layout as \b a. 224 */ 225 template <class T> 226 TArray<T>::TArray(const BaseArray& a, bool pack) 221 227 : BaseArray() , mNDBlock() 222 228 { 223 229 if (a.NbDimensions() == 0) return; 224 string exmsg = "TArray<T>::TArray(const BaseArray&)"; 225 if (!UpdateSizes(a, exmsg)) throw( ParmError(exmsg) ); 226 mNDBlock.ReSize(totsize_); 227 // if (a.mInfo) mInfo = new DVList(*(a.mInfo)); - pb protected ! 230 string exmsg = "TArray<T>::TArray(const BaseArray&,bool)"; 231 ReSize(a,pack,false); 228 232 ConvertAndCopyElt(a); 233 if (a.HasInfoObject()) mInfo = new DVList(*(a.getInfoPointer())); 229 234 } 230 235 … … 1626 1631 } 1627 1632 SetSeq(es); 1628 cout << "TArray<T>::ReadASCII()/Info: " << n << " elements read from stream " 1629 << " (Row,Col= " << nr << "," << nc << ")" << endl; 1633 if (BaseArray::GetPrintLevel()>0) 1634 cout << "TArray<T>::ReadASCII()/Info: " << n << " elements read from stream " 1635 << " (Row,Col= " << nr << "," << nc << ")" << endl; 1630 1636 return(n); 1631 1637 } -
trunk/SophyaLib/TArray/tarray.h
r3831 r4035 35 35 TArray(const TArray<T>& a); 36 36 TArray(const TArray<T>& a, bool share); 37 TArray(const BaseArray& a );37 TArray(const BaseArray& a, bool pack=true); 38 38 39 39 virtual ~TArray(); -
trunk/SophyaLib/TArray/tmatrix.cc
r3831 r4035 1 // $Id: tmatrix.cc,v 1.4 0 2010-08-05 12:16:19ansari Exp $1 // $Id: tmatrix.cc,v 1.41 2011-11-14 16:28:25 ansari Exp $ 2 2 // C.Magneville 04/99 3 3 #include "sopnamsp.h" … … 127 127 : TArray<T>(a, share) 128 128 { 129 arrtype_ = 1; // Type = Matrix 130 if (a.NbDimensions() == 0) { // Reza-Nov 2011: we allow copy contrsuctor on non allocated arrays 131 UpdateMemoryMapping(a, SameMemoryMapping); 132 return; 133 } 129 134 if (a.NbDimensions() > 2) 130 135 throw SzMismatchError("TMatrix<T>::TMatrix(const TArray<T>& a, ...) a.NbDimensions()>2"); … … 134 139 ndim_ = 2; 135 140 } 141 UpdateMemoryMapping(a, SameMemoryMapping); 142 } 143 144 //! Constructor of a matrix from a TArray \b a , with different data type 145 /*! 146 Matrix size and memory layout are copied from the array \b a, or a packed matrix is created if \b pack==true. 147 \param a : original array, to copy sizes and data from 148 \param pack : if \b true , create a packed matrix, else same memory layout as \b a. 149 */ 150 template <class T> 151 TMatrix<T>::TMatrix(const BaseArray& a, bool pack) 152 : TArray<T>() 153 { 154 // On ne peut pas passer par TArray<T>(const BaseArray&), car il faut initialiser arrtype_ d'abord ! 136 155 arrtype_ = 1; // Type = Matrix 156 if (a.NbDimensions() == 0) { // Reza-Nov 2011: we allow copy contrsuctor on non allocated arrays 157 UpdateMemoryMapping(a, SameMemoryMapping); 158 return; 159 } 160 if (a.NbDimensions() > 2) 161 throw SzMismatchError("TMatrix<T>::TMatrix((const BaseArray& a, bool) a.NbDimensions()>2"); 162 string exmsg = "TMatrix<T>::TMatrix(const BaseArray&,bool)"; 163 TArray<T>::ReSize(a,pack,false); 137 164 UpdateMemoryMapping(a, SameMemoryMapping); 138 } 139 140 //! Constructor of a matrix from a TArray \b a , with a different data type 141 template <class T> 142 TMatrix<T>::TMatrix(const BaseArray& a) 143 : TArray<T>() 144 { 145 arrtype_ = 1; // Type = Matrix 146 UpdateMemoryMapping(a, SameMemoryMapping); 147 SetBA(a); 165 TArray<T>::ConvertAndCopyElt(a); 148 166 } 149 167 -
trunk/SophyaLib/TArray/tmatrix.h
r3831 r4035 21 21 TMatrix(const TMatrix<T>& a); 22 22 TMatrix(const TMatrix<T>& a, bool share); 23 TMatrix(const TArray<T>& a, 24 TMatrix(const BaseArray& a );23 TMatrix(const TArray<T>& a, bool share=true); 24 TMatrix(const BaseArray& a, bool pack=true); 25 25 26 26 virtual ~TMatrix(); -
trunk/SophyaLib/TArray/tvector.cc
r3869 r4035 1 // $Id: tvector.cc,v 1.2 8 2010-08-12 15:01:47ansari Exp $1 // $Id: tvector.cc,v 1.29 2011-11-14 16:28:25 ansari Exp $ 2 2 // C.Magneville 04/99 3 3 #include "sopnamsp.h" … … 56 56 /*! 57 57 \param n : number of elements 58 \param lcv : line or column vector ?58 \param lcv : line or column vector (BaseArray::AutoVectorType / SameVectorType / ColumnVector / RowVector) 59 59 \param mm : memory mapping type 60 60 \param fzero : if \b true , set vector elements to zero … … 108 108 : TMatrix<T>(a, share) 109 109 { 110 arrtype_ = 2; // Type = Vector 111 if (a.NbDimensions() == 0) return; // Reza-Nov 2011: we allow copy contrsuctor on non allocated arrays 110 112 if ( (size_[0] != 1) && (size_[1] != 1) ) 111 113 throw SzMismatchError("TVector<T>::TVector(const TArray<T>& a) NRows()!=1 && NCols()!=1 "); 112 arrtype_ = 2; // Type = Vector113 114 if ( (size_[0] == 1) && (size_[1] == 1) ) { 114 115 if (lcv == SameVectorType) lcv = a.GetVectorType(); … … 119 120 120 121 //! Constructor of a vector from a TArray \b a , with a different data type 121 template <class T> 122 TVector<T>::TVector(const BaseArray& a) 123 : TMatrix<T>(a) 124 { 122 /*! 123 vector size and memory layout are copied from the array \b a, or a packed vector is created if \b pack==true. 124 \param a : original array, to copy sizes and data from 125 \param pack : if \b true , create a packed vector, else same memory layout as \b a. 126 */ 127 template <class T> 128 TVector<T>::TVector(const BaseArray& a, bool pack) 129 : TMatrix<T>(a,pack) 130 { 131 arrtype_ = 2; // Type = Vector 132 if (a.NbDimensions() == 0) return; // Reza-Nov 2011: we allow copy contrsuctor on non allocated arrays 125 133 if ( (size_[0] != 1) && (size_[1] != 1) ) 126 throw SzMismatchError("TVector<T>::TVector(const BaseArray& a) NRows()!=1 && NCols()!=1 "); 127 arrtype_ = 2; // Type = Vector 134 throw SzMismatchError("TVector<T>::TVector(const BaseArray& a,bool) NRows()!=1 && NCols()!=1 "); 128 135 } 129 136 -
trunk/SophyaLib/TArray/tvector.h
r3857 r4035 20 20 TVector(const TVector<T>& v); 21 21 TVector(const TVector<T>& v, bool share); 22 TVector(const TArray<T>& a, 23 TVector(const BaseArray& a );22 TVector(const TArray<T>& a, bool share=true, short lcv=BaseArray::AutoVectorType); 23 TVector(const BaseArray& a, bool pack=true); 24 24 TVector(const vector<T>& v, short lcv=BaseArray::AutoVectorType); 25 25
Note: See TracChangeset
for help on using the changeset viewer.