Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

RazorBack::Vector_ Class Template Reference

Vector_: this class implements a template for a linear algebra vector class. More...

#include <Vector.hh>

List of all members.

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


Detailed Description

template<class T_> class RazorBack::Vector_

Vector_: this class implements a template for a linear algebra vector class.

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.


Constructor & Destructor Documentation

template<class T_>
RazorBack::Vector_<T_>::Vector_<T_> ( size_t N = 3,
const T_ & X = T_(0) ) [inline, explicit]
 

Construct an N-dimensional vector (default 3, 0 disallowed) and set its elements to X (default is "0").

Definition at line 78 of file Vector.hh.

template<class T_>
RazorBack::Vector_<T_>::Vector_<T_> ( const vector< T_ > & V ) [inline, explicit]
 

Construct the Vector_ from an STL vector V.

If V is empty, then a 3-dimensional Vector_ will be created.

Definition at line 86 of file Vector.hh.

template<class T_>
RazorBack::Vector_<T_>::Vector_<T_> ( const T_ * Arr,
size_t Len ) [inline]
 

Construct the Vector_ from a traditional C-style array.

There are no checks: you have been warned.

Definition at line 96 of file Vector.hh.

template<class T_>
RazorBack::Vector_<T_>::~Vector_<T_> ( ) [inline, virtual]
 

Destructor: empty virtual for eventual derived classes.

Definition at line 104 of file Vector.hh.


Member Function Documentation

template<class T_>
const T_ & RazorBack::Vector_<T_>::operator[] ( size_t Idx ) const [inline]
 

[]: unchecked C-style access.

Ignores FORTRAN access status. (): allows range-checked and FORTRAN-style indexing. Throws Indexrangexc_ on range errors.

Definition at line 111 of file Vector.hh.

template<class T_>
T_ & RazorBack::Vector_<T_>::operator[] ( size_t Idx ) [inline]
 

Definition at line 112 of file Vector.hh.

template<class T_>
const T_& RazorBack::Vector_<T_>::operator() ( size_t Idx ) const
 

template<class T_>
T_& RazorBack::Vector_<T_>::operator() ( size_t Idx )
 

template<class T_>
bool RazorBack::Vector_<T_>::ftn_idx ( ) const [inline]
 

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.

Definition at line 125 of file Vector.hh.

template<class T_>
bool RazorBack::Vector_<T_>::ftn_idx ( bool F ) [inline]
 

Definition at line 126 of file Vector.hh.

template<class T_>
bool RazorBack::Vector_<T_>::range_check ( ) const [inline]
 

range_check(): returns true if range checking is enabled.

range_check(C): sets Check to C, returns old range checking status.

Definition at line 132 of file Vector.hh.

template<class T_>
bool RazorBack::Vector_<T_>::range_check ( bool C ) [inline]
 

Definition at line 133 of file Vector.hh.

template<class T_>
Vector_< T_ > & RazorBack::Vector_<T_>::set_values ( const T_ & X = T_(0) )
 

set_values(): sets all coordinates to X (0 by default).

template<class T_>
size_t RazorBack::Vector_<T_>::dim ( ) const [inline]
 

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_().

template<class T_>
size_t RazorBack::Vector_<T_>::dim ( size_t D )
 

template<class T_>
vector< T_ >::const_iterator RazorBack::Vector_<T_>::begin ( ) const [inline]
 

begin(), end(): for STL-style manipulations.

Definition at line 147 of file Vector.hh.

template<class T_>
vector< T_ >::iterator RazorBack::Vector_<T_>::begin<T_> ( ) [inline]
 

Definition at line 148 of file Vector.hh.

template<class T_>
vector< T_ >::const_iterator RazorBack::Vector_<T_>::end<T_> ( ) const [inline]
 

Definition at line 149 of file Vector.hh.

template<class T_>
vector< T_ >::iterator RazorBack::Vector_<T_>::end<T_> ( ) [inline]
 

Definition at line 150 of file Vector.hh.

template<class T_>
Vector_< T_ > & RazorBack::Vector_<T_>::operator+= ( const T_ & X )
 

Scalar arithmetics: add, subtract, multiply or divide each coordinate the T_ type object X "in place".

The modified calling object is returned.

template<class T_>
Vector_<T_>& RazorBack::Vector_<T_>::operator-= ( const T_ & X )
 

template<class T_>
Vector_<T_>& RazorBack::Vector_<T_>::operator *= ( const T_ & X )
 

template<class T_>
Vector_<T_> RazorBack::Vector_<T_>::operator * ( const T_ & X ) const
 

template<class T_>
Vector_<T_>& RazorBack::Vector_<T_>::operator/= ( const T_ & X )
 

template<class T_>
Vector_<T_> RazorBack::Vector_<T_>::operator/ ( const T_ & X ) const
 

template<class T_>
Vector_< T_ > & RazorBack::Vector_<T_>::operator+= ( const Vector_< T_ > & V )
 

Vector arithmetics: addition, subtraction, scalar product.

The operands must have equal dimensions otherwise a Dimexc_ is thrown.

template<class T_>
Vector_<T_> RazorBack::Vector_<T_>::operator+ ( const Vector_< T_ > & V ) const
 

template<class T_>
Vector_<T_>& RazorBack::Vector_<T_>::operator-= ( const Vector_< T_ > & V )
 

template<class T_>
Vector_<T_> RazorBack::Vector_<T_>::operator- ( const Vector_< T_ > & V ) const
 

template<class T_>
T_ RazorBack::Vector_<T_>::operator * ( const Vector_< T_ > & V ) const
 

template<class T_>
T_ RazorBack::Vector_<T_>::vec_len2 ( ) const [inline]
 

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().

template<class T_>
T_ RazorBack::Vector_<T_>::vec_len ( ) const [inline]
 

Definition at line 183 of file Vector.hh.

template<class T_>
T_ RazorBack::Vector_<T_>::vec_norm ( )
 

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.

template<class T_>
void RazorBack::Vector_<T_>::transform ( unary_function< T_, T_ > Unaryfunc ) [inline]
 

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.

Definition at line 202 of file Vector.hh.

template<class T_>
void RazorBack::Vector_<T_>::read ( istream & In )
 

reads from In into the calling object.


Member Data Documentation

template<class T_>
vector<T_> RazorBack::Vector_<T_>::Vec [private]
 

Definition at line 64 of file Vector.hh.

template<class T_>
size_t RazorBack::Vector_<T_>::Dim [private]
 

Definition at line 65 of file Vector.hh.

template<class T_>
bool RazorBack::Vector_<T_>::Ftnidx [private]
 

Definition at line 66 of file Vector.hh.

template<class T_>
bool RazorBack::Vector_<T_>::Check [private]
 

Definition at line 67 of file Vector.hh.


The documentation for this class was generated from the following file:
Generated at Wed Aug 21 09:33:28 2002 for The Razorback C++ Library: Linear Algebra by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001