source: Sophya/trunk/SophyaLib/TArray/tvector.h@ 1010

Last change on this file since 1010 was 976, checked in by ansari, 25 years ago

modifs doc cmv 27/4/00

File size: 3.5 KB
RevLine 
[762]1// This may look like C code, but it is really -*- C++ -*-
2// C.Magneville 05/99
3#ifndef TVector_SEEN
4#define TVector_SEEN
5
6#include "tmatrix.h"
7
8namespace SOPHYA {
9
[894]10//! Class of vector (line or column)
[762]11template <class T>
12class TVector : public TMatrix<T> {
13public:
14 // Creation / destruction
[804]15 TVector();
[914]16 TVector(uint_4 n, short lcv=AutoVectorType, short mm=AutoMemoryMapping);
[762]17 TVector(const TVector<T>& v);
[804]18 TVector(const TVector<T>& v, bool share);
19 TVector(const TArray<T>& a);
[914]20 TVector(const TArray<T>& a, bool share, short lcv=AutoVectorType, short mm=AutoMemoryMapping);
[762]21
[804]22 virtual ~TVector();
23
[967]24 //! Operator =
[976]25 /*! \warning Datas are copied (cloned) from \b a.
26 \sa NDataBlock::operator=(const NDataBlock<T>&) */
[804]27 inline TVector<T>& operator = (const TVector<T>& a)
28 { Set(a); return(*this); }
29
[762]30 // Gestion taille/Remplissage
[813]31 void ReSize(uint_4 n, short lcv=SameVectorType );
32 void Realloc(uint_4 n, short lcv=SameVectorType, bool force=false);
[762]33
[804]34 // Sub-Vector extraction $CHECK$ Reza 03/2000 Doit-on declarer cette methode const ?
[813]35 TVector<T> SubVector(Range relt) const ;
[894]36 //! Extract a vector define by Range \b relt
[813]37 inline TVector<T> operator () (Range relt) const
38 { return SubVector(relt); }
[804]39
[762]40 // Informations pointeur/data
[894]41 //! return the number of elements
[804]42 inline uint_4 NElts() const {return Size(); }
[762]43
[804]44 // Inline element acces methods
45 inline T const& operator()(uint_4 n) const;
46 inline T& operator()(uint_4 n);
[762]47
[813]48 // Operateur d'affectation
[898]49 //! Fill the vector with Sequence \b seq
[914]50 inline TVector<T>& operator = (Sequence seq) { SetSeq(seq); return(*this); }
[813]51
[804]52 // Operations diverses avec une constante
[894]53 //! Set vector elements to constant value \b x
[813]54 inline TVector<T>& operator = (T x) { SetT(x); return(*this); }
[894]55 //! Add constant value \b x to vector elements
[804]56 inline TVector<T>& operator += (T x) { Add(x); return(*this); }
[894]57 //! Substract constant value \b x to vector elements
[804]58 inline TVector<T>& operator -= (T x) { Sub(x); return(*this); }
[894]59 //! Multiply vector elements by constant value \b x
[804]60 inline TVector<T>& operator *= (T x) { Mul(x); return(*this); }
[894]61 //! Divide vector elements by constant value \b x
[804]62 inline TVector<T>& operator /= (T x) { Div(x); return(*this); }
[762]63
[804]64 // operations avec matrices
[894]65 //! += : add a vector in place
[804]66 inline TVector<T>& operator += (const TVector<T>& a) { AddElt(a); return(*this); }
[894]67 //! += : substract a vector in place
[804]68 inline TVector<T>& operator -= (const TVector<T>& a) { SubElt(a); return(*this); }
[762]69
[804]70 // Norme(^2)
71 T Norm2() const ;
[813]72
73 virtual string InfoString() const;
74
[762]75};
76
[804]77// ---- inline acces methods ------
[894]78
79//! Return the value of element \b n
[762]80template <class T>
[804]81inline T const& TVector<T>::operator()(uint_4 n) const
82{
83#ifdef SO_BOUNDCHECKING
84 if (veceli__ == 0) CheckBound(n, 0, 0, 0, 0, 4);
85 else CheckBound(0, n, 0, 0, 0, 4);
86#endif
87 return ( *( mNDBlock.Begin()+ offset_ + n*step_[veceli_] ) );
88}
[762]89
[894]90//! Return the value of element \b n
[762]91template <class T>
[804]92inline T & TVector<T>::operator()(uint_4 n)
93{
94#ifdef SO_BOUNDCHECKING
95 if (veceli__ == 0) CheckBound(n, 0, 0, 0, 0, 4);
96 else CheckBound(0, n, 0, 0, 0, 4);
97#endif
98 return ( *( mNDBlock.Begin()+ offset_ + n*step_[veceli_] ) );
99}
[762]100
101// Typedef pour simplifier et compatibilite Peida
[956]102/*! \ingroup TArray
103 \typedef Vector
104 \brief To simplified TVector<r_8> writing
105*/
[762]106typedef TVector<r_8> Vector;
107
108} // Fin du namespace
109
110#endif
Note: See TracBrowser for help on using the repository browser.