Protium
Math and Design Features
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
Protium::LinearAlgebra::Vector< T, n > Class Template Reference

Implementation of vector to be used in Linear Algebra. More...

#include <Vector.h>

Inheritance diagram for Protium::LinearAlgebra::Vector< T, n >:

Public Member Functions

 Vector (const T &amplitude=1)
 
 Vector (const std::vector< T > &vec)
 
 Vector (const Vector< T, n > &other)
 
 Vector (const T *input)
 
virtual ~Vector ()
 
const T & At (const int &index) const
 
Vector< T, n-1 > GetSubVector (const int &i)
 
void Init ()
 Initialization of vector components to. More...
 
virtual T Norm () const
 
virtual T Normalize (const T &norm)
 
bool operator!= (const Vector< T, n > &rhs) const
 
const T operator* (const Vector< T, n > &rhs) const
 
const Vector< T, n > operator* (const T &rhs) const
 
Vector< T, n > & operator*= (const T &rhs)
 
const Vector< T, n > operator+ (const Vector< T, n > &rhs) const
 
Vector< T, n > & operator+= (const Vector< T, n > &rhs)
 
const Vector< T, n > operator- (const Vector< T, n > &rhs) const
 
Vector< T, n > & operator-= (const Vector< T, n > &rhs)
 
Vector< T, n > & operator= (const Vector< T, n > &rhs)
 
bool operator== (const Vector< T, n > &rhs) const
 
T & operator[] (const int &index)
 
- Public Member Functions inherited from Protium::Allocation::SmallObject< ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >
virtual ~SmallObject ()
 

Static Public Member Functions

static int NDimensions ()
 
static Vector< T, n > UnitVector (int dim=0)
 Constructs a unit vector in the given dimension. More...
 
- Static Public Member Functions inherited from Protium::Allocation::SmallObjectBase< ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >
static void operator delete (void *p, std::size_t size) throw ()
 
static void operator delete (void *p, const std::nothrow_t &) throw ()
 
static void operator delete (void *p, void *place)
 
static void operator delete[] (void *p, std::size_t size) throw ()
 
static void operator delete[] (void *p, const std::nothrow_t &) throw ()
 
static void operator delete[] (void *p, void *place)
 
static void * operator new (std::size_t size) throw ( std::bad_alloc )
 
static void * operator new (std::size_t size, const std::nothrow_t &) throw ()
 
static void * operator new (std::size_t size, void *place)
 
static void * operator new[] (std::size_t size) throw ( std::bad_alloc )
 
static void * operator new[] (std::size_t size, const std::nothrow_t &) throw ()
 
static void * operator new[] (std::size_t size, void *place)
 

Private Attributes

std::vector< T > fComponents
 Holds the components of the vector. More...
 

Additional Inherited Members

- Public Types inherited from Protium::Allocation::SmallObjectBase< ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >
typedef
Protium::Allocation::SmallObjectAllocator
< ThreadingModel, chunkSize,
maxSmallObjectSize,
objectAlignSize,
LifetimePolicy > 
ObjAllocator
 Type of allocator to host the allocator singleton. More...
 
- Protected Member Functions inherited from Protium::Allocation::SmallObject< ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >
 SmallObject (void)
 
- Protected Member Functions inherited from Protium::Allocation::SmallObjectBase< ThreadingModel, chunkSize, maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >
 SmallObjectBase (void)
 
 SmallObjectBase (const SmallObjectBase &)
 
 ~SmallObjectBase ()
 
SmallObjectBaseoperator= (const SmallObjectBase &)
 

Detailed Description

template<typename T, int n>
class Protium::LinearAlgebra::Vector< T, n >

Implementation of vector to be used in Linear Algebra.

Definition at line 16 of file Vector.h.

Constructor & Destructor Documentation

template<typename T, int n>
Protium::LinearAlgebra::Vector< T, n >::Vector ( const T &  amplitude = 1)
inline

Default Constructor.

Parameters
amplitudethe amplitude of the vector

Definition at line 71 of file Vector.h.

template<typename T, int n>
Protium::LinearAlgebra::Vector< T, n >::Vector ( const T *  input)
inline

Construct from an array. Copies contents.

Parameters
inputAn array of size n and type T

Definition at line 81 of file Vector.h.

template<typename T, int n>
Protium::LinearAlgebra::Vector< T, n >::Vector ( const std::vector< T > &  vec)
inline

Construct from STL Vector

Definition at line 89 of file Vector.h.

template<typename T, int n>
Protium::LinearAlgebra::Vector< T, n >::Vector ( const Vector< T, n > &  other)
inline

Copy constructor.

Definition at line 97 of file Vector.h.

template<typename T, int n>
virtual Protium::LinearAlgebra::Vector< T, n >::~Vector ( )
inlinevirtual

Default Destructor

Definition at line 106 of file Vector.h.

Member Function Documentation

template<typename T, int n>
const T& Protium::LinearAlgebra::Vector< T, n >::At ( const int &  index) const
inline

Const access operator

Definition at line 155 of file Vector.h.

template<typename T, int n>
Vector<T,n-1> Protium::LinearAlgebra::Vector< T, n >::GetSubVector ( const int &  i)
inline

Calculates and returns a vector of one less dimension

Parameters
iThe index of the element to be left out
Returns
A vector of one less dimension

Definition at line 142 of file Vector.h.

template<typename T, int n>
void Protium::LinearAlgebra::Vector< T, n >::Init ( )
inline

Initialization of vector components to.

Definition at line 62 of file Vector.h.

template<typename T, int n>
static int Protium::LinearAlgebra::Vector< T, n >::NDimensions ( )
inlinestatic

Returns back the template integer parameter

Definition at line 113 of file Vector.h.

template<typename T, int n>
virtual T Protium::LinearAlgebra::Vector< T, n >::Norm ( ) const
inlinevirtual

Calculates the norm of the vector

Returns
The square root of the square of this vector

Definition at line 120 of file Vector.h.

template<typename T, int n>
virtual T Protium::LinearAlgebra::Vector< T, n >::Normalize ( const T &  norm)
inlinevirtual

Normalizes this vector to a constant

Parameters
normThe normalization constant
Returns
The norm of the vector

Definition at line 128 of file Vector.h.

template<typename T, int n>
bool Protium::LinearAlgebra::Vector< T, n >::operator!= ( const Vector< T, n > &  rhs) const
inline

Negative comparison operator

Definition at line 240 of file Vector.h.

template<typename T, int n>
const T Protium::LinearAlgebra::Vector< T, n >::operator* ( const Vector< T, n > &  rhs) const
inline

Multiplication Operator

Parameters
rhsA vector of same type and size
Returns
constant of vector type

Definition at line 203 of file Vector.h.

template<typename T, int n>
const Vector<T,n> Protium::LinearAlgebra::Vector< T, n >::operator* ( const T &  rhs) const
inline

Multiplication Operator

Parameters
rhsOf vector type
Returns
Vector of same size and type as current one

Definition at line 217 of file Vector.h.

template<typename T, int n>
Vector<T,n>& Protium::LinearAlgebra::Vector< T, n >::operator*= ( const T &  rhs)
inline

Operator only defined for multiplying by another type

Definition at line 171 of file Vector.h.

template<typename T, int n>
const Vector<T,n> Protium::LinearAlgebra::Vector< T, n >::operator+ ( const Vector< T, n > &  rhs) const
inline

Addition operator

Definition at line 189 of file Vector.h.

template<typename T, int n>
Vector<T,n>& Protium::LinearAlgebra::Vector< T, n >::operator+= ( const Vector< T, n > &  rhs)
inline

Increment operator

Parameters
rhsVector to increment by (increments each element by it's corresponding one)

Definition at line 162 of file Vector.h.

template<typename T, int n>
const Vector<T,n> Protium::LinearAlgebra::Vector< T, n >::operator- ( const Vector< T, n > &  rhs) const
inline

Subtraction operator

Definition at line 195 of file Vector.h.

template<typename T, int n>
Vector<T,n>& Protium::LinearAlgebra::Vector< T, n >::operator-= ( const Vector< T, n > &  rhs)
inline

Decrement operator

Definition at line 180 of file Vector.h.

template<typename T, int n>
Vector<T,n>& Protium::LinearAlgebra::Vector< T, n >::operator= ( const Vector< T, n > &  rhs)
inline

Assignment Operator

Definition at line 223 of file Vector.h.

template<typename T, int n>
bool Protium::LinearAlgebra::Vector< T, n >::operator== ( const Vector< T, n > &  rhs) const
inline

Comparison operator

Definition at line 230 of file Vector.h.

template<typename T, int n>
T& Protium::LinearAlgebra::Vector< T, n >::operator[] ( const int &  index)
inline

Access operator.

Definition at line 149 of file Vector.h.

template<typename T, int n>
static Vector<T,n> Protium::LinearAlgebra::Vector< T, n >::UnitVector ( int  dim = 0)
inlinestatic

Constructs a unit vector in the given dimension.

Definition at line 245 of file Vector.h.

Member Data Documentation

template<typename T, int n>
std::vector<T> Protium::LinearAlgebra::Vector< T, n >::fComponents
private

Holds the components of the vector.

Definition at line 57 of file Vector.h.