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

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

Amelioation / debugging de la classe TArray<T> - TVector et TMatrix

heritent maintenant de TArray<T> - Classe RCMatrix rendu prive au fichier
sopemtx.cc - linfit.cc integre a sopemtx.cc

Reza 03/04/2000

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