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

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

documentation cmv 13/4/00

File size: 3.4 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
[894]24 //! Operator =
[804]25 inline TVector<T>& operator = (const TVector<T>& a)
26 { Set(a); return(*this); }
27
[762]28 // Gestion taille/Remplissage
[813]29 void ReSize(uint_4 n, short lcv=SameVectorType );
30 void Realloc(uint_4 n, short lcv=SameVectorType, bool force=false);
[762]31
[804]32 // Sub-Vector extraction $CHECK$ Reza 03/2000 Doit-on declarer cette methode const ?
[813]33 TVector<T> SubVector(Range relt) const ;
[894]34 //! Extract a vector define by Range \b relt
[813]35 inline TVector<T> operator () (Range relt) const
36 { return SubVector(relt); }
[804]37
[762]38 // Informations pointeur/data
[894]39 //! return the number of elements
[804]40 inline uint_4 NElts() const {return Size(); }
[762]41
[804]42 // Inline element acces methods
43 inline T const& operator()(uint_4 n) const;
44 inline T& operator()(uint_4 n);
[762]45
[813]46 // Operateur d'affectation
[898]47 //! Fill the vector with Sequence \b seq
[914]48 inline TVector<T>& operator = (Sequence seq) { SetSeq(seq); return(*this); }
[813]49
[804]50 // Operations diverses avec une constante
[894]51 //! Set vector elements to constant value \b x
[813]52 inline TVector<T>& operator = (T x) { SetT(x); return(*this); }
[894]53 //! Add constant value \b x to vector elements
[804]54 inline TVector<T>& operator += (T x) { Add(x); return(*this); }
[894]55 //! Substract constant value \b x to vector elements
[804]56 inline TVector<T>& operator -= (T x) { Sub(x); return(*this); }
[894]57 //! Multiply vector elements by constant value \b x
[804]58 inline TVector<T>& operator *= (T x) { Mul(x); return(*this); }
[894]59 //! Divide vector elements by constant value \b x
[804]60 inline TVector<T>& operator /= (T x) { Div(x); return(*this); }
[762]61
[804]62 // operations avec matrices
[894]63 //! += : add a vector in place
[804]64 inline TVector<T>& operator += (const TVector<T>& a) { AddElt(a); return(*this); }
[894]65 //! += : substract a vector in place
[804]66 inline TVector<T>& operator -= (const TVector<T>& a) { SubElt(a); return(*this); }
[762]67
[804]68 // Norme(^2)
69 T Norm2() const ;
[813]70
71 virtual string InfoString() const;
72
[762]73};
74
[804]75// ---- inline acces methods ------
[894]76
77//! Return the value of element \b n
[762]78template <class T>
[804]79inline T const& TVector<T>::operator()(uint_4 n) const
80{
81#ifdef SO_BOUNDCHECKING
82 if (veceli__ == 0) CheckBound(n, 0, 0, 0, 0, 4);
83 else CheckBound(0, n, 0, 0, 0, 4);
84#endif
85 return ( *( mNDBlock.Begin()+ offset_ + n*step_[veceli_] ) );
86}
[762]87
[894]88//! Return the value of element \b n
[762]89template <class T>
[804]90inline T & TVector<T>::operator()(uint_4 n)
91{
92#ifdef SO_BOUNDCHECKING
93 if (veceli__ == 0) CheckBound(n, 0, 0, 0, 0, 4);
94 else CheckBound(0, n, 0, 0, 0, 4);
95#endif
96 return ( *( mNDBlock.Begin()+ offset_ + n*step_[veceli_] ) );
97}
[762]98
99// Typedef pour simplifier et compatibilite Peida
[894]100//! Define Vector to be TVector<r_8>
[762]101typedef TVector<r_8> Vector;
102
103} // Fin du namespace
104
105#endif
Note: See TracBrowser for help on using the repository browser.