Changeset 2752 in Sophya for trunk/SophyaLib/TArray
- Timestamp:
- May 23, 2005, 6:18:17 PM (20 years ago)
- Location:
- trunk/SophyaLib/TArray
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/TArray/tarray.cc
r2615 r2752 7 7 #include <stdlib.h> 8 8 #include <math.h> 9 #include <iomanip> 10 9 11 #include "pexceptions.h" 10 12 #include "tarray.h" … … 1303 1305 if (maxprt < 0) maxprt = max_nprt_; 1304 1306 sa_size_t npr = 0; 1307 // keep stream's io flags 1308 ios_base::fmtflags ioflg = os.flags(); 1309 os << right ; 1310 1305 1311 Show(os, si); 1306 1312 if (ndim_ < 1) return; 1313 1314 // Calcul de la largeur d'impression pour chaque element 1315 int fprtw = os.precision()+7; 1316 int prtw = 5; 1317 1318 if ( (typeid(T) == typeid( int_4 )) || (typeid(T) == typeid( uint_4 )) ) prtw = 8; 1319 else if ( (typeid(T) == typeid( int_8 )) || (typeid(T) == typeid( uint_8 )) ) prtw = 11; 1320 else if ( typeid(T) == typeid( r_4 ) ) prtw = fprtw; 1321 else if ( typeid(T) == typeid( r_8 ) ) prtw = fprtw; 1322 else if ( typeid(T) == typeid(complex<r_4>) ) prtw = fprtw; 1323 else if ( typeid(T) == typeid(complex<r_8>) ) prtw = fprtw; 1324 1325 1307 1326 sa_size_t k0,k1,k2,k3,k4; 1308 1327 for(k4=0; k4<size_[4]; k4++) { … … 1320 1339 for(k0=0; k0<size_[0]; k0++) { 1321 1340 if(k0 > 0) os << " "; 1322 os << Elem(k0, k1, k2, k3, k4); npr++;1341 os << setw(prtw) << Elem(k0, k1, k2, k3, k4); npr++; 1323 1342 if (npr >= (sa_size_t) maxprt) { 1324 1343 if (npr < totsize_) os << "\n .... " << endl; return; … … 1331 1350 } 1332 1351 os << endl; 1352 os.flags(ioflg); // reset stream io flags 1333 1353 } 1334 1354 -
trunk/SophyaLib/TArray/tmatrix.cc
r2615 r2752 1 // $Id: tmatrix.cc,v 1. 29 2004-09-10 09:55:07 cmvExp $1 // $Id: tmatrix.cc,v 1.30 2005-05-23 16:18:17 ansari Exp $ 2 2 // C.Magneville 04/99 3 3 #include "sopnamsp.h" 4 4 #include "machdefs.h" 5 #include <iostream> 6 #include <iomanip> 5 7 #include <stdio.h> 6 8 #include <stdlib.h> … … 102 104 103 105 //! Constructor of a matrix from a TArray \b a 104 template <class T>105 TMatrix<T>::TMatrix(const TArray<T>& a)106 : TArray<T>(a)107 {108 if (a.NbDimensions() > 2)109 throw SzMismatchError("TMatrix<T>::TMatrix(const TArray<T>& a) a.NbDimensions()>2 ");110 if (a.NbDimensions() == 1) {111 size_[1] = 1;112 step_[1] = size_[0]*step_[0];113 ndim_ = 2;114 }115 arrtype_ = 1; // Type = Matrix116 UpdateMemoryMapping(a, SameMemoryMapping);117 }118 119 //! Constructor of a matrix from a TArray \b a120 106 /*! 121 107 \param a : TArray to be copied or shared 122 108 \param share : if true, share data. If false copy data 123 \param mm : define the memory mapping type 124 */ 125 template <class T> 126 TMatrix<T>::TMatrix(const TArray<T>& a, bool share, short mm ) 109 */ 110 template <class T> 111 TMatrix<T>::TMatrix(const TArray<T>& a, bool share) 127 112 : TArray<T>(a, share) 128 113 { … … 135 120 } 136 121 arrtype_ = 1; // Type = Matrix 137 UpdateMemoryMapping(a, mm);122 UpdateMemoryMapping(a, SameMemoryMapping); 138 123 } 139 124 … … 264 249 TMatrix<T> TMatrix<T>::SubMatrix(Range rline, Range rcol) const 265 250 { 251 Range rx, ry; 266 252 short mm = GetMemoryMapping(); 267 Range rx, ry;268 253 if (mm == CMemoryMapping) { rx = rcol; ry = rline; } 269 254 else { ry = rcol; rx = rline; } 270 TMatrix sm(SubArray(rx, ry, Range(0), Range(0), Range(0)),true , mm);255 TMatrix sm(SubArray(rx, ry, Range(0), Range(0), Range(0)),true); 271 256 sm.UpdateMemoryMapping(mm); 272 257 return(sm); … … 389 374 if (maxprt < 0) maxprt = max_nprt_; 390 375 sa_size_t npr = 0; 376 377 // keep stream's io flags 378 ios_base::fmtflags ioflg = os.flags(); 379 os << right ; 380 391 381 Show(os, si); 392 382 if (ndim_ < 1) return; 383 // Calcul de la largeur d'impression pour chaque element 384 int fprtw = os.precision()+7; 385 int prtw = 5; 386 387 if ( (typeid(T) == typeid( int_4 )) || (typeid(T) == typeid( uint_4 )) ) prtw = 8; 388 else if ( (typeid(T) == typeid( int_8 )) || (typeid(T) == typeid( uint_8 )) ) prtw = 11; 389 else if ( typeid(T) == typeid( r_4 ) ) prtw = fprtw; 390 else if ( typeid(T) == typeid( r_8 ) ) prtw = fprtw; 391 else if ( typeid(T) == typeid(complex<r_4>) ) prtw = fprtw; 392 else if ( typeid(T) == typeid(complex<r_8>) ) prtw = fprtw; 393 393 394 sa_size_t kc,kr; 394 395 for(kr=0; kr<size_[marowi_]; kr++) { … … 396 397 for(kc=0; kc<size_[macoli_]; kc++) { 397 398 if(kc > 0) os << " "; 398 os << (*this)(kr, kc); npr++;399 os << setw(prtw) << (*this)(kr, kc); npr++; 399 400 if (npr >= (sa_size_t) maxprt) { 400 401 if (npr < totsize_) os << "\n .... " << endl; return; … … 404 405 } 405 406 os << endl; 407 os.flags(ioflg); // reset stream io flags 406 408 } 407 409 -
trunk/SophyaLib/TArray/tmatrix.h
r2575 r2752 18 18 TMatrix(const TMatrix<T>& a); 19 19 TMatrix(const TMatrix<T>& a, bool share); 20 TMatrix(const TArray<T>& a); 21 TMatrix(const TArray<T>& a, bool share, short mm=BaseArray::AutoMemoryMapping); 20 TMatrix(const TArray<T>& a, bool share=true); 22 21 TMatrix(const BaseArray& a); 23 22 -
trunk/SophyaLib/TArray/tvector.cc
r2719 r2752 1 // $Id: tvector.cc,v 1.1 8 2005-05-13 16:44:30 cmvExp $1 // $Id: tvector.cc,v 1.19 2005-05-23 16:18:17 ansari Exp $ 2 2 // C.Magneville 04/99 3 3 #include "sopnamsp.h" … … 91 91 } 92 92 93 //! Constructor from a TArray94 template <class T>95 TVector<T>::TVector(const TArray<T>& a)96 : TMatrix<T>(a)97 {98 if ( (size_[0] != 1) && (size_[1] != 1) )99 throw SzMismatchError("TVector<T>::TVector(const TArray<T>& a) NRows()!=1 && NCols()!=1 ");100 arrtype_ = 2; // Type = Vector101 }102 93 103 94 //! Constructor of a vector from a TArray \b a … … 105 96 \param a : TArray to be copied or shared 106 97 \param share : if true, share data. If false copy data 107 \param mm : define the memory mapping type108 98 \param lcv : line or column vector ? 109 99 \sa SelectVectorType 110 100 */ 111 101 template <class T> 112 TVector<T>::TVector(const TArray<T>& a, bool share, short lcv , short mm)113 : TMatrix<T>(a, share , mm)102 TVector<T>::TVector(const TArray<T>& a, bool share, short lcv) 103 : TMatrix<T>(a, share) 114 104 { 115 105 if ( (size_[0] != 1) && (size_[1] != 1) ) … … 202 192 else cr = relt; 203 193 TMatrix<T> const & mtx = (*this); 204 TVector sv( mtx(rr, cr) , true, GetVectorType() , GetMemoryMapping());194 TVector sv( mtx(rr, cr) , true, GetVectorType() ); 205 195 return(sv); 206 196 } -
trunk/SophyaLib/TArray/tvector.h
r2719 r2752 17 17 TVector(const TVector<T>& v); 18 18 TVector(const TVector<T>& v, bool share); 19 TVector(const TArray<T>& a); 20 TVector(const TArray<T>& a, bool share, short lcv=AutoVectorType, short mm=AutoMemoryMapping); 19 TVector(const TArray<T>& a, bool share=true, short lcv=AutoVectorType); 21 20 TVector(const BaseArray& a); 22 21 TVector(const vector<T>& v, short lcv=AutoVectorType); -
trunk/SophyaLib/TArray/utilarr.cc
r2615 r2752 287 287 if (is.good()) { 288 288 if ((line.length() > 0) && (line[0]!=clm)) { 289 nel = Append(line, nbad );289 nel = Append(line, nbad, sep); 290 290 if (nel > 0) { 291 291 nr++; n += nel; … … 298 298 } 299 299 if ((line.length() > 0) && (line[0]!=clm)) { 300 nel = Append(line, nbad );300 nel = Append(line, nbad, sep); 301 301 // cout << " Decoding Eline = " << line << " Nel= " << nel << endl; 302 302 if (nel > 0) {
Note:
See TracChangeset
for help on using the changeset viewer.