Changeset 4035 in Sophya for trunk/SophyaLib/TArray/tmatrix.cc
- Timestamp:
- Nov 14, 2011, 5:28:25 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.