#include <Vector.hh>
Public Methods | |
Vector_ (size_t N=3, const T_ &X=T_(0)) | |
Construct an N-dimensional vector (default 3, 0 disallowed) and set its elements to X (default is "0"). | |
Vector_ (const vector< T_ > &V) | |
Construct the Vector_ from an STL vector V. More... | |
Vector_ (const T_ *Arr, size_t Len) | |
Construct the Vector_ from a traditional C-style array. More... | |
virtual | ~Vector_ () |
Destructor: empty virtual for eventual derived classes. | |
const T_& | operator[] (size_t Idx) const |
[]: unchecked C-style access. More... | |
T_& | operator[] (size_t Idx) |
const T_& | operator() (size_t Idx) const |
T_& | operator() (size_t Idx) |
bool | ftn_idx () const |
ftn_idx(): returns "true" if the calling vector object was switched to use FORTRAN-style [1..N] indexing instead of the usual [0..N-1] C-style access. More... | |
bool | ftn_idx (bool F) |
bool | range_check () const |
range_check(): returns true if range checking is enabled. More... | |
bool | range_check (bool C) |
Vector_<T_>& | set_values (const T_ &X=T_(0)) |
set_values(): sets all coordinates to X (0 by default). | |
size_t | dim () const |
dim(): returns the dimension (size) of the vector. More... | |
size_t | dim (size_t D) |
vector<T_>::const_iterator | begin () const |
begin(), end(): for STL-style manipulations. | |
vector<T_>::iterator | begin () |
vector<T_>::const_iterator | end () const |
vector<T_>::iterator | end () |
Vector_<T_>& | operator+= (const T_ &X) |
Scalar arithmetics: add, subtract, multiply or divide each coordinate the T_ type object X "in place". More... | |
Vector_<T_>& | operator-= (const T_ &X) |
Vector_<T_>& | operator *= (const T_ &X) |
Vector_<T_> | operator * (const T_ &X) const |
Vector_<T_>& | operator/= (const T_ &X) |
Vector_<T_> | operator/ (const T_ &X) const |
Vector_<T_>& | operator+= (const Vector_< T_ > &V) |
Vector arithmetics: addition, subtraction, scalar product. More... | |
Vector_<T_> | operator+ (const Vector_< T_ > &V) const |
Vector_<T_>& | operator-= (const Vector_< T_ > &V) |
Vector_<T_> | operator- (const Vector_< T_ > &V) const |
T_ | operator * (const Vector_< T_ > &V) const |
T_ | vec_len2 () const |
vec_len2(): calculates the square of the Euclidean norm. More... | |
T_ | vec_len () const |
T_ | vec_norm () |
vec_norm(): normalises the calling object to a unit vector "in place". More... | |
void | transform (unary_function< T_, T_ > Unaryfunc) |
transform(): this method allows the modification of each coordinate of the calling object "in place" using the STL function object Unaryfunc. More... | |
void | read (istream &In) |
reads from In into the calling object. | |
Private Attributes | |
vector<T_> | Vec |
size_t | Dim |
bool | Ftnidx |
bool | Check |
The objects are N>0 -dimensional vectors with all the usual arithmetic operations. The base type T_ must support meaningful arithmetics and output <<.
Definition at line 59 of file Vector.hh.
|
Construct an N-dimensional vector (default 3, 0 disallowed) and set its elements to X (default is "0").
|
|
Construct the Vector_ from an STL vector V. If V is empty, then a 3-dimensional Vector_ will be created. |
|
Construct the Vector_ from a traditional C-style array. There are no checks: you have been warned. |
|
Destructor: empty virtual for eventual derived classes.
|
|
[]: unchecked C-style access. Ignores FORTRAN access status. (): allows range-checked and FORTRAN-style indexing. Throws Indexrangexc_ on range errors. |
|
|
|
|
|
|
|
ftn_idx(): returns "true" if the calling vector object was switched to use FORTRAN-style [1..N] indexing instead of the usual [0..N-1] C-style access. Useful for porting Numerical Recipes C code which uses the FORTRAN indexing convention. ftn_idx(F): switches the FORTRAN boolean variable to F. Returns old state. |
|
|
|
range_check(): returns true if range checking is enabled. range_check(C): sets Check to C, returns old range checking status. |
|
|
|
set_values(): sets all coordinates to X (0 by default).
|
|
dim(): returns the dimension (size) of the vector. dim(D): adjusts the dimension to D or to 3 if D==0. Returns previous dimension. Definition at line 143 of file Vector.hh. Referenced by Vector_(). |
|
|
|
begin(), end(): for STL-style manipulations.
|
|
|
|
|
|
|
|
Scalar arithmetics: add, subtract, multiply or divide each coordinate the T_ type object X "in place". The modified calling object is returned. |
|
|
|
|
|
|
|
|
|
|
|
Vector arithmetics: addition, subtraction, scalar product. The operands must have equal dimensions otherwise a Dimexc_ is thrown. |
|
|
|
|
|
|
|
|
|
vec_len2(): calculates the square of the Euclidean norm. Can be invoked either as "Vector.vec_len2()" or "vec_len2(Vector)". vec_len(): returns the Euclidean norm for types T_ which support a sqrt(T_) operation. Definition at line 182 of file Vector.hh. Referenced by vec_len(). |
|
|
|
vec_norm(): normalises the calling object to a unit vector "in place". Returns the original length. The type T_ must support a sqrt(T_) operation. "Null"-vectors should ideally throw a "division by zero" exception later. |
|
transform(): this method allows the modification of each coordinate of the calling object "in place" using the STL function object Unaryfunc. Could be used for things like taking the square root of each coordinate etc. See also the arithmetics methods for multiplications by a scalar etc. |
|
reads from In into the calling object.
|
|
|
|
|
|
|
|
|