Changeset 4035 in Sophya for trunk/SophyaLib/TArray/tvector.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/tvector.cc

    r3869 r4035  
    1 // $Id: tvector.cc,v 1.28 2010-08-12 15:01:47 ansari Exp $
     1// $Id: tvector.cc,v 1.29 2011-11-14 16:28:25 ansari Exp $
    22//                         C.Magneville          04/99
    33#include "sopnamsp.h"
     
    5656/*!
    5757  \param n : number of elements
    58   \param lcv : line or column vector ?
     58  \param lcv : line or column vector (BaseArray::AutoVectorType / SameVectorType / ColumnVector / RowVector)
    5959  \param mm : memory mapping type
    6060  \param fzero : if \b true , set vector elements to zero
     
    108108: TMatrix<T>(a, share)
    109109{
     110  arrtype_ = 2;   // Type = Vector
     111  if (a.NbDimensions() == 0)  return;    // Reza-Nov 2011: we allow copy contrsuctor on non allocated arrays 
    110112  if ( (size_[0] != 1) && (size_[1] != 1) )
    111113    throw SzMismatchError("TVector<T>::TVector(const TArray<T>& a) NRows()!=1 && NCols()!=1 ");
    112   arrtype_ = 2;   // Type = Vector
    113114  if ( (size_[0] == 1) && (size_[1] == 1) ) {
    114115    if (lcv == SameVectorType) lcv = a.GetVectorType();
     
    119120
    120121//! 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*/
     127template <class T>
     128TVector<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 
    125133  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 ");
    128135}
    129136
Note: See TracChangeset for help on using the changeset viewer.