// 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 { //! Class of vector (line or column) template class TVector : public TMatrix { public: #include "tvector_tsnl.h" /* For two level name look-up gcc >= 3.4 */ // Creation / destruction TVector(); TVector(sa_size_t n, short lcv=BaseArray::AutoVectorType, short mm=BaseArray::AutoMemoryMapping, bool fzero=true); TVector(const TVector& v); TVector(const TVector& v, bool share); TVector(const TArray& a, bool share=true, short lcv=BaseArray::AutoVectorType); TVector(const BaseArray& a, bool pack=true); TVector(const vector& v, short lcv=BaseArray::AutoVectorType); virtual ~TVector(); //! Operator = /*! \warning Datas are copied (cloned) from \b a. \sa NDataBlock::operator=(const NDataBlock&) */ inline TVector& operator = (const TVector& a) { Set(a); return(*this); } //! Operator = between a vector and a matrix inline TVector& operator = (const TMatrix& a) { Set(a); return(*this); } //! Operator = between a vector and an array inline TVector& operator = (const TArray& a) { Set(a); return(*this); } //! Operator = between Vectors with different types inline TVector& operator = (const BaseArray& a) { SetBA(a); return(*this); } // Gestion taille/Remplissage void ReSize(sa_size_t n, short lcv=BaseArray::SameVectorType, bool fzero=true); //! a synonym (alias) for method ReSize(sa_size_t, short) inline void SetSize(sa_size_t n, short lcv=BaseArray::SameVectorType, bool fzero=true) { ReSize(n, lcv, fzero); } void Realloc(sa_size_t n, short lcv=BaseArray::SameVectorType, bool force=false); // Remplissage from/to a STL vector sa_size_t FillFr(const vector& v,bool noresize=false); sa_size_t FillTo(vector& v,bool addtoend=false); vector ConvertTostdvec(); // Sub-Vector extraction $CHECK$ Reza 03/2000 Doit-on declarer cette methode const ? TVector SubVector(Range relt) const ; //! Extract a vector define by Range \b relt inline TVector operator () (Range relt) const { return SubVector(relt); } // Informations pointeur/data //! return the number of elements inline sa_size_t NElts() const {return Size(); } // Inline element acces methods inline T const& operator()(sa_size_t n) const; inline T& operator()(sa_size_t n); // Operateur d'affectation //! Fill the vector with Sequence \b seq inline TVector& operator = (Sequence const & seq) { SetSeq(seq); return(*this); } // Operations diverses avec une constante //! Set vector elements to constant value \b x inline TVector& operator = (T x) { SetT(x); return(*this); } //! Add constant value \b x to vector elements inline TVector& operator += (T x) { AddCst(x,*this); return(*this); } //! Substract constant value \b x to vector elements inline TVector& operator -= (T x) { SubCst(x,*this); return(*this); } //! Multiply vector elements by constant value \b x inline TVector& operator *= (T x) { MulCst(x,*this); return(*this); } //! Divide vector elements by constant value \b x inline TVector& operator /= (T x) { DivCst(x,*this); return(*this); } // operations avec matrices //! += : add a vector in place inline TVector& operator += (const TVector& a) { AddElt(a,*this); return(*this); } //! += : substract a vector in place inline TVector& operator -= (const TVector& a) { SubElt(a,*this); return(*this); } virtual string InfoString() const; }; // ---- inline acces methods ------ //! Return the value of element \b n template inline T const& TVector::operator()(sa_size_t 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_] ) ); } //! Return the value of element \b n template inline T & TVector::operator()(sa_size_t 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 /*! \ingroup TArray \typedef Vector \brief To simplified TVector writing */ typedef TVector Vector; //--------- extern template declarations (if needed) ----------- #if defined ( NEED_EXT_DECL_TEMP ) && !defined( TVECTOR_CC_BFILE ) extern template class TVector; extern template class TVector; extern template class TVector; extern template class TVector; extern template class TVector; extern template class TVector; extern template class TVector; extern template class TVector; extern template class TVector; extern template class TVector; extern template class TVector< complex >; extern template class TVector< complex >; #ifdef SO_LDBLE128 extern template class TVector; extern template class TVector< complex >; #endif #endif // Fin de if defined ( NEED_EXT_DECL_TEMP ) } // Fin du namespace #endif