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


Ignore:
Timestamp:
Nov 14, 2011, 5:28:25 PM (14 years ago)
Author:
ansari
Message:

1/ modif mineure ds TArray<T>::::ReadASCII() au print level global de BaseArray
2/ Correction bug gestion memoire au niveau des constructeurs de copie TArray/TMatrix/TVector
avec un BaseArray en argument. Ajout argument optionnel bool pack a ces constructeurs
3/ On autorise desormais la creation des objets TArray/TMatrix/TVector par constructeur de
copie sur des objets non alloues

Reza, 14/11/2011

File:
1 edited

Legend:

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

    r3831 r4035  
    1 // $Id: tmatrix.cc,v 1.40 2010-08-05 12:16:19 ansari Exp $
     1// $Id: tmatrix.cc,v 1.41 2011-11-14 16:28:25 ansari Exp $
    22//                         C.Magneville          04/99
    33#include "sopnamsp.h"
     
    127127: TArray<T>(a, share)
    128128{
     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  }
    129134  if (a.NbDimensions() > 2)
    130135    throw SzMismatchError("TMatrix<T>::TMatrix(const TArray<T>& a, ...) a.NbDimensions()>2");
     
    134139    ndim_ = 2;
    135140  }
     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*/
     150template <class T>
     151TMatrix<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 !
    136155  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);
    137164  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);
    148166}
    149167
Note: See TracChangeset for help on using the changeset viewer.