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
|
---|
14 | TVector();
|
---|
15 | TVector(uint_4 n, short lcv=ColumnVector, short mm=AutoMemoryMapping);
|
---|
16 | TVector(const TVector<T>& v);
|
---|
17 | TVector(const TVector<T>& v, bool share);
|
---|
18 | TVector(const TArray<T>& a);
|
---|
19 | TVector(const TArray<T>& a, bool share, short mm=CMemoryMapping, short lcv=ColumnVector);
|
---|
20 |
|
---|
21 | virtual ~TVector();
|
---|
22 |
|
---|
23 | inline TVector<T>& operator = (const TVector<T>& a)
|
---|
24 | { Set(a); return(*this); }
|
---|
25 |
|
---|
26 |
|
---|
27 | // Gestion taille/Remplissage
|
---|
28 | void ReSize(uint_4 n, short lcv=SameVectorType );
|
---|
29 | void Realloc(uint_4 n, short lcv=SameVectorType, bool force=false);
|
---|
30 |
|
---|
31 | // Sub-Vector extraction $CHECK$ Reza 03/2000 Doit-on declarer cette methode const ?
|
---|
32 | TVector<T> SubVector(Range relt) const ;
|
---|
33 | inline TVector<T> operator () (Range relt) const
|
---|
34 | { return SubVector(relt); }
|
---|
35 |
|
---|
36 | // Informations pointeur/data
|
---|
37 | inline uint_4 NElts() const {return Size(); }
|
---|
38 |
|
---|
39 | // Inline element acces methods
|
---|
40 | inline T const& operator()(uint_4 n) const;
|
---|
41 | inline T& operator()(uint_4 n);
|
---|
42 |
|
---|
43 | // Operateur d'affectation
|
---|
44 | inline TMatrix<T>& operator = (Sequence seq) { SetSeq(seq); return(*this); }
|
---|
45 |
|
---|
46 | // Operations diverses avec une constante
|
---|
47 | inline TVector<T>& operator = (T x) { SetT(x); return(*this); }
|
---|
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); }
|
---|
52 |
|
---|
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); }
|
---|
56 |
|
---|
57 | // Norme(^2)
|
---|
58 | T Norm2() const ;
|
---|
59 |
|
---|
60 | virtual string InfoString() const;
|
---|
61 |
|
---|
62 | };
|
---|
63 |
|
---|
64 | // ---- inline acces methods ------
|
---|
65 | template <class T>
|
---|
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 | }
|
---|
74 |
|
---|
75 | template <class T>
|
---|
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 | }
|
---|
84 |
|
---|
85 | // Typedef pour simplifier et compatibilite Peida
|
---|
86 | typedef TVector<r_8> Vector;
|
---|
87 |
|
---|
88 | } // Fin du namespace
|
---|
89 |
|
---|
90 | #endif
|
---|