|
GCpp general purpose C++ library
version 1.0
|
#include <GVectorT.hh>
Public Member Functions | |
| GVectorT (size_t n=1) | |
| GVectorT (size_t n, const T &x) | |
| GVectorT (size_t n, const T x[]) | |
| GVectorT (const GVectorT< T > &v) | |
| GVectorT & | operator= (const GVectorT< T > &v) |
| virtual | ~GVectorT () |
| virtual void | InitElement (size_t i) |
| virtual void | InitData () |
| virtual void | InitData (const T x) |
| virtual void | InitData (const T x[]) |
| virtual void | InitData (size_t n, const T x[]) |
| virtual bool | CheckIndex (size_t i) const |
| virtual bool | CheckDimension (const GVectorT< T > &v) const |
| virtual bool | CheckProduct (const GMatrixT< T > &m) const |
| size_t | SetDimension (size_t n) |
| size_t | GetDimension () const |
| const T * | Data () const |
| T * | Data () |
| virtual const T & | operator() (size_t i) const |
| virtual T & | operator() (size_t i) |
| virtual const T & | operator[] (size_t i) const |
| virtual T & | operator[] (size_t i) |
| virtual GVectorT< T > | operator+ (const GVectorT< T > &v) const |
| virtual GVectorT< T > | operator- (const GVectorT< T > &v) const |
| virtual GVectorT< T > | operator* (const T k) const |
| virtual GVectorT< T > | operator/ (const T k) const |
| virtual GVectorT< T > & | operator+= (const GVectorT< T > &v) |
| virtual GVectorT< T > & | operator-= (const GVectorT< T > &v) |
| virtual GVectorT< T > & | operator*= (const T k) |
| virtual GVectorT< T > & | operator/= (const T k) |
| virtual GVectorT< T > | operator- () const |
| virtual T | operator* (const GVectorT< T > &v) const |
| virtual GVectorT< T > | operator* (const GMatrixT< T > &m) const |
| virtual double | Norm2Squared () const |
| virtual double | Norm2 () const |
| virtual double | LengthSquared () const |
| virtual double | Length () const |
| virtual string | GetString () const |
| virtual string | GetString (const char *fmt) const |
| template<> | |
| void | InitData () |
| template<> | |
| double | Norm2 () const |
Protected Member Functions | |
| virtual T * | Allocate (size_t n) |
| virtual void | Reset () |
Protected Attributes | |
| bool | change_dim |
| Indicates if dimension can be changed. | |
| size_t | dimension |
| Vector dimension. | |
| T * | element |
| Vector elements array. | |
Static Private Attributes | |
| static string | vect_open = "< " |
| Pattern for string representation. | |
| static string | vect_close = " >" |
| Pattern for string representation. | |
| static string | vect_separ = " ; " |
| Pattern for string representation. | |
| static string | vect_format = "%8.3f" |
| Pattern for string representation. | |
Template class defining a vector for numerical types.
The basic vector operations are defined, with the assumption that the standard algebaric operation of the template class are defined.
For effective instantiation of a class, the following functions should be specialised (see file GVectorD.hh):
Default constructor.
| n | vector dimension |
Constructor with initialisation to a unique value (all elements).
| n | vector dimension |
| x | data value |
Constructor with array initialisation.
| n | vector dimension |
| x | data array (at least of size n) |
Copy constructor.
| v | vector to copy |
References GVectorT< T >::Data(), and GVectorT< T >::GetDimension().
|
protectedvirtual |
Allocate the memory for vector elements, and set dimension.
| n | vector dimension |
|
inlinevirtual |
Function warning when the argument vector has a different dimension.
| v | checked vector |
References GVectorT< T >::GetDimension(), and GLogWarning().
Referenced by GVector4::GVector4().
|
inlinevirtual |
Function warning when an index is out of bounds.
| i | checked index value |
References GGetString(), and GLogWarning().
|
inlinevirtual |
Function warning if the vector is not compatible with the argument for the product (*this)*m.
| m | matrix operand |
References GMatrixT< T >::GetRowsNumber(), and GLogWarning().
|
inline |
Return the data array pointer.
Referenced by GVector4::GVector4(), GVectorT< T >::GVectorT(), GVectorT< T >::operator*(), GMatrixT< T >::operator*(), GVectorT< T >::operator+(), GVectorT< T >::operator+=(), GVectorT< T >::operator-(), GVectorT< T >::operator-=(), GVectorT< T >::operator/(), GVectorT< T >::operator=(), GMatrixT< T >::SetColumn(), and GMatrixT< T >::SetRow().
|
inline |
Return the data array pointer.
|
inline |
Return the vector dimension.
Referenced by GVectorT< T >::CheckDimension(), GMatrixT< T >::CheckProduct(), GVector4::GVector4(), GVectorT< T >::GVectorT(), GVectorT< T >::operator=(), GMatrixT< T >::SetColumn(), and GMatrixT< T >::SetRow().
|
inlinevirtual |
Write the vector content in a string, using static numerical format.
|
virtual |
Write the vector content in a string.
| fmt | numerical format (C style) |
References GGetString().
|
inline |
Specialisation of the function to initialise the vector content.
|
inlinevirtual |
Function to initialise the vector content.
Referenced by GVector4::GVector4().
|
inlinevirtual |
Function to initialise all vector elements with the same value.
| x | element value |
|
inlinevirtual |
Function to initialise the vector content with an array of data. If the array dimension must be at least the vector dimension.
| x | values array |
|
inlinevirtual |
Function to initialise the vector content with an array of data, limited to maximum
b.
| x | values array |
| n | maximum number of elements to set |
|
inlinevirtual |
Function to initialise an element content.
|
inlinevirtual |
Return the vector length (euclidian).
|
inlinevirtual |
Return the vector length squared (euclidian).
|
inline |
Return the norm 2 (euclidian length).
|
inlinevirtual |
Return the norm 2 (euclidian length).
|
inlinevirtual |
Return the norm 2 squared (euclidian length).
|
inlinevirtual |
Return a component.
| i | component index |
|
inlinevirtual |
Return a component.
| i | component index |
|
virtual |
Product of the vector with a matrix.
| m | second operand |
References GVectorT< T >::Data(), GMatrixT< T >::Data(), GMatrixT< T >::GetColumnsNumber(), and GMatrixT< T >::GetIndex().
Multiplication scaling.
| k | scaling factor |
Unary minus.
References GVectorT< T >::Data().
Division scaling.
| k | scaling factor |
Affectation operator.
| v | vector to copy |
References GVectorT< T >::Data(), and GVectorT< T >::GetDimension().
|
inlinevirtual |
Return a component.
| i | component index |
|
inlinevirtual |
Return a component.
| i | component index |
|
inlineprotectedvirtual |
Reset the vector (dimension set to 0).
| size_t GVectorT< T >::SetDimension | ( | size_t | n | ) |
Sets a new dimension. The previous data are conserved. The function returns the dimension.
| n | new dimension |
References GLogWarning().