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

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

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