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

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