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

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

doc pour preparation inverse logique de NDataBlock cmv 21/4/00

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