Changeset 2752 in Sophya for trunk/SophyaLib/TArray/tmatrix.cc


Ignore:
Timestamp:
May 23, 2005, 6:18:17 PM (20 years ago)
Author:
ansari
Message:

1/ Suppression du constructeur de copie avec specification d'organisation memoire (MemoryMapping) pour TMatrix<T> et TVector<T>
2/ Amelioration de l'impression des TArray/TMatrix avec la specification setw(largeur)
3/ Correction petit bug dans la lecture fichiers ASCII argument non transmis ds utilarr.cc

Reza 23 Mai 2005

File:
1 edited

Legend:

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

    r2615 r2752  
    1 // $Id: tmatrix.cc,v 1.29 2004-09-10 09:55:07 cmv Exp $
     1// $Id: tmatrix.cc,v 1.30 2005-05-23 16:18:17 ansari Exp $
    22//                         C.Magneville          04/99
    33#include "sopnamsp.h"
    44#include "machdefs.h"
     5#include <iostream>
     6#include <iomanip>
    57#include <stdio.h>
    68#include <stdlib.h>
     
    102104
    103105//! 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 = Matrix
    116   UpdateMemoryMapping(a, SameMemoryMapping);
    117 }
    118 
    119 //! Constructor of a matrix from a TArray \b a
    120106/*!
    121107  \param a : TArray to be copied or shared
    122108  \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 */
     110template <class T>
     111TMatrix<T>::TMatrix(const TArray<T>& a, bool share)
    127112: TArray<T>(a, share)
    128113{
     
    135120  }
    136121  arrtype_ = 1;   // Type = Matrix
    137   UpdateMemoryMapping(a, mm);
     122  UpdateMemoryMapping(a, SameMemoryMapping);
    138123}
    139124
     
    264249TMatrix<T> TMatrix<T>::SubMatrix(Range rline, Range rcol) const
    265250{
     251  Range rx, ry;
    266252  short mm = GetMemoryMapping();
    267   Range rx, ry;
    268253  if (mm == CMemoryMapping)  { rx = rcol;  ry = rline; }
    269254  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);
    271256  sm.UpdateMemoryMapping(mm);
    272257  return(sm);
     
    389374  if (maxprt < 0)  maxprt = max_nprt_;
    390375  sa_size_t npr = 0;
     376
     377  // keep stream's io flags
     378  ios_base::fmtflags ioflg = os.flags();
     379  os << right ;
     380
    391381  Show(os, si);
    392382  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
    393394  sa_size_t kc,kr; 
    394395  for(kr=0; kr<size_[marowi_]; kr++) {
     
    396397    for(kc=0; kc<size_[macoli_]; kc++) {
    397398      if(kc > 0) os << " "; 
    398       os << (*this)(kr, kc);   npr++;
     399      os << setw(prtw) << (*this)(kr, kc);   npr++;
    399400      if (npr >= (sa_size_t) maxprt) {
    400401        if (npr < totsize_)  os << "\n     .... " << endl; return;
     
    404405  }
    405406  os << endl;
     407  os.flags(ioflg);  // reset stream io flags
    406408}
    407409
Note: See TracChangeset for help on using the changeset viewer.