// This may look like C code, but it is really -*- C++ -*- // C.Magneville 05/99 #ifndef TVector_SEEN #define TVector_SEEN #include "tmatrix.h" namespace SOPHYA { template class TVector : public TMatrix { public: enum {SameTypeVector=0, ColumnVector=1, LineVector=2}; // Creation / destruction TVector(); TVector(uint_4 n, short lcv=ColumnVector, short mm=AutoMemoryMapping); TVector(const TVector& v); TVector(const TVector& v, bool share); TVector(const TArray& a); TVector(const TArray& a, bool share, short lcv=ColumnVector, short mm=CMemoryMapping); virtual ~TVector(); inline TVector& operator = (const TVector& a) { Set(a); return(*this); } // Vector type Line or Column vector inline short GetVectorType() const { return((marowi_ == veceli_) ? ColumnVector : LineVector); } // Gestion taille/Remplissage void ReSize(uint_4 n, short lcv=SameTypeVector ); void Realloc(uint_4 n, short lcv=SameTypeVector, bool force=false); // Sub-Vector extraction $CHECK$ Reza 03/2000 Doit-on declarer cette methode const ? TVector operator () (Range relt) const ; // Informations pointeur/data inline uint_4 NElts() const {return Size(); } // Inline element acces methods inline T const& operator()(uint_4 n) const; inline T& operator()(uint_4 n); // Operations diverses avec une constante inline TVector& operator = (T x) { Set(x); return(*this); } inline TVector& operator += (T x) { Add(x); return(*this); } inline TVector& operator -= (T x) { Sub(x); return(*this); } inline TVector& operator *= (T x) { Mul(x); return(*this); } inline TVector& operator /= (T x) { Div(x); return(*this); } // operations avec matrices inline TVector& operator += (const TVector& a) { AddElt(a); return(*this); } inline TVector& operator -= (const TVector& a) { SubElt(a); return(*this); } // Norme(^2) T Norm2() const ; }; // ---- inline acces methods ------ template inline T const& TVector::operator()(uint_4 n) const { #ifdef SO_BOUNDCHECKING if (veceli__ == 0) CheckBound(n, 0, 0, 0, 0, 4); else CheckBound(0, n, 0, 0, 0, 4); #endif return ( *( mNDBlock.Begin()+ offset_ + n*step_[veceli_] ) ); } template inline T & TVector::operator()(uint_4 n) { #ifdef SO_BOUNDCHECKING if (veceli__ == 0) CheckBound(n, 0, 0, 0, 0, 4); else CheckBound(0, n, 0, 0, 0, 4); #endif return ( *( mNDBlock.Begin()+ offset_ + n*step_[veceli_] ) ); } // Typedef pour simplifier et compatibilite Peida typedef TVector Vector; } // Fin du namespace #endif