[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 |
|
---|
| 8 | namespace SOPHYA {
|
---|
| 9 |
|
---|
| 10 | template <class T>
|
---|
| 11 | class TVector : public TMatrix<T> {
|
---|
| 12 | public:
|
---|
| 13 | // Creation / destruction
|
---|
[804] | 14 | TVector();
|
---|
| 15 | TVector(uint_4 n, short lcv=ColumnVector, short mm=AutoMemoryMapping);
|
---|
[762] | 16 | TVector(const TVector<T>& v);
|
---|
[804] | 17 | TVector(const TVector<T>& v, bool share);
|
---|
| 18 | TVector(const TArray<T>& a);
|
---|
[813] | 19 | TVector(const TArray<T>& a, bool share, short mm=CMemoryMapping, short lcv=ColumnVector);
|
---|
[762] | 20 |
|
---|
[804] | 21 | virtual ~TVector();
|
---|
| 22 |
|
---|
| 23 | inline TVector<T>& operator = (const TVector<T>& a)
|
---|
| 24 | { Set(a); return(*this); }
|
---|
| 25 |
|
---|
| 26 |
|
---|
[762] | 27 | // Gestion taille/Remplissage
|
---|
[813] | 28 | void ReSize(uint_4 n, short lcv=SameVectorType );
|
---|
| 29 | void Realloc(uint_4 n, short lcv=SameVectorType, bool force=false);
|
---|
[762] | 30 |
|
---|
[804] | 31 | // Sub-Vector extraction $CHECK$ Reza 03/2000 Doit-on declarer cette methode const ?
|
---|
[813] | 32 | TVector<T> SubVector(Range relt) const ;
|
---|
| 33 | inline TVector<T> operator () (Range relt) const
|
---|
| 34 | { return SubVector(relt); }
|
---|
[804] | 35 |
|
---|
[762] | 36 | // Informations pointeur/data
|
---|
[804] | 37 | inline uint_4 NElts() const {return Size(); }
|
---|
[762] | 38 |
|
---|
[804] | 39 | // Inline element acces methods
|
---|
| 40 | inline T const& operator()(uint_4 n) const;
|
---|
| 41 | inline T& operator()(uint_4 n);
|
---|
[762] | 42 |
|
---|
[813] | 43 | // Operateur d'affectation
|
---|
| 44 | inline TMatrix<T>& operator = (Sequence seq) { SetSeq(seq); return(*this); }
|
---|
| 45 |
|
---|
[804] | 46 | // Operations diverses avec une constante
|
---|
[813] | 47 | inline TVector<T>& operator = (T x) { SetT(x); return(*this); }
|
---|
[804] | 48 | inline TVector<T>& operator += (T x) { Add(x); return(*this); }
|
---|
| 49 | inline TVector<T>& operator -= (T x) { Sub(x); return(*this); }
|
---|
| 50 | inline TVector<T>& operator *= (T x) { Mul(x); return(*this); }
|
---|
| 51 | inline TVector<T>& operator /= (T x) { Div(x); return(*this); }
|
---|
[762] | 52 |
|
---|
[804] | 53 | // operations avec matrices
|
---|
| 54 | inline TVector<T>& operator += (const TVector<T>& a) { AddElt(a); return(*this); }
|
---|
| 55 | inline TVector<T>& operator -= (const TVector<T>& a) { SubElt(a); return(*this); }
|
---|
[762] | 56 |
|
---|
[804] | 57 | // Norme(^2)
|
---|
| 58 | T Norm2() const ;
|
---|
[813] | 59 |
|
---|
| 60 | virtual string InfoString() const;
|
---|
| 61 |
|
---|
[762] | 62 | };
|
---|
| 63 |
|
---|
[804] | 64 | // ---- inline acces methods ------
|
---|
[762] | 65 | template <class T>
|
---|
[804] | 66 | inline T const& TVector<T>::operator()(uint_4 n) const
|
---|
| 67 | {
|
---|
| 68 | #ifdef SO_BOUNDCHECKING
|
---|
| 69 | if (veceli__ == 0) CheckBound(n, 0, 0, 0, 0, 4);
|
---|
| 70 | else CheckBound(0, n, 0, 0, 0, 4);
|
---|
| 71 | #endif
|
---|
| 72 | return ( *( mNDBlock.Begin()+ offset_ + n*step_[veceli_] ) );
|
---|
| 73 | }
|
---|
[762] | 74 |
|
---|
| 75 | template <class T>
|
---|
[804] | 76 | inline T & TVector<T>::operator()(uint_4 n)
|
---|
| 77 | {
|
---|
| 78 | #ifdef SO_BOUNDCHECKING
|
---|
| 79 | if (veceli__ == 0) CheckBound(n, 0, 0, 0, 0, 4);
|
---|
| 80 | else CheckBound(0, n, 0, 0, 0, 4);
|
---|
| 81 | #endif
|
---|
| 82 | return ( *( mNDBlock.Begin()+ offset_ + n*step_[veceli_] ) );
|
---|
| 83 | }
|
---|
[762] | 84 |
|
---|
| 85 | // Typedef pour simplifier et compatibilite Peida
|
---|
| 86 | typedef TVector<r_8> Vector;
|
---|
| 87 |
|
---|
| 88 | } // Fin du namespace
|
---|
| 89 |
|
---|
| 90 | #endif
|
---|