iso::math::Vector< Type > Class Template Reference

vector class More...

#include <iso_math_vector.h>

Inherited by iso::math::Vector2< Type >, iso::math::Vector3< Type >, and iso::math::Vector4< Type >.

Inheritance diagram for iso::math::Vector< Type >:

Inheritance graph
[legend]
Collaboration diagram for iso::math::Vector< Type >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Vector ()
 create default zero vector
 Vector (unsigned int pDim)
 create zero vector
 Vector (unsigned int pDim, Type pValue)
 create vector containing identical values
 Vector (unsigned int pDim, const Type *pValues)
 create vector from array of values
template<typename Type2>
 Vector (unsigned int pDim, const Type2 *pValues)
 create vector from array of values
 Vector (unsigned int pDim, double pValue1, double pValue2,...) throw (MathException)
 create vector from parameter list of values
 Vector (const Vector< Type > &pVector)
 create vector from vector
template<class Type2>
 Vector (const Vector< Type2 > &pVector)
 create vector from vector
virtual ~Vector ()
 destructor
void reset ()
 set all vector elements to 0
virtual void setDim (unsigned int pDim)
 set dimension of vector
void set (Type pValue)
 set vector to identical values
void set (Type pValue, unsigned int pDim) throw (MathException)
 set vector to new dimension and set all it's components to pValue
void set (const Type *pValues)
 set vector to values from array
void set (unsigned int pDim, double pValue1, double pValue2,...) throw (MathException)
 set vector to parameter list of values
void set (const Vector< Type > &pVector) throw (MathException)
 set vector to values from vector
void set (const Vector< Type > &pVector, bool pResize) throw (MathException)
 set vector to values from vector
void setLength (Type pLength)
 scale vector to new length
const Vector< Type > & operator= (Type pValue)
 vector = value
const Vector< Type > & operator= (const Type *pValues)
 vector = values[]
const Vector< Type > & operator= (const Vector< Type > &pVector) throw (MathException)
 vector = vector
Type & operator[] (unsigned int pIndex) throw (MathException)
 vector[]
const Type & operator[] (unsigned int pIndex) const throw (MathException)
 operator[]
const unsigned int & dim () const
 return size of vector
Type * values ()
 return vector values
const Type * values () const
 return vector values
Type length () const
 return length of vector
Type lengthSquared () const
 return length^2 of vector
const Vector< Type > & operator+= (const Type pValue)
 vector += value
const Vector< Type > & operator-= (const Type pValue)
 vector -= value
const Vector< Type > & operator *= (const Type pValue)
 vector *= value
const Vector< Type > & operator/= (Type pValue)
 vector /= value
Vector< Type > operator+ (const Type pValue) const
 vector + value
Vector< Type > operator- (const Type pValue) const
 vector - value
Vector< Type > operator * (const Type pValue) const
 vector * value
Vector< Type > operator/ (Type pValue) const
 vector / value
const Vector< Type > & operator+= (const Vector< Type > &pVector) throw (MathException)
 vector += vector
const Vector< Type > & operator-= (const Vector< Type > &pVector) throw (MathException)
 vector -= vector
virtual const Vector< Type > & operator *= (const Vector< Type > &pVector) throw (MathException)
 vector *= vector
const Vector< Type > & operator/= (const Vector< Type > &pVector) throw (MathException)
 vector /= vector
Vector< Type > operator+ (const Vector< Type > &pVector) const throw (MathException)
 vector + vector
Vector< Type > operator- (const Vector< Type > &pVector) const throw (MathException)
 vector - vector
virtual Vector< Type > operator * (const Vector< Type > &pVector) const throw (MathException)
 vector * vector
Vector< Type > operator/ (const Vector< Type > &pVector) const throw (MathException)
 vector / vector
Type dot (const Vector< Type > &pVector) const throw (MathException)
 vector dot product
Type sum () const
 return sum of all vector components
Type product () const
 return product of all vector components
bool operator== (const Type &pValue) const
 vector == pValue
bool operator!= (const Type &pValue) const
 vector != pValue
bool operator> (const Type &pValue) const
 vector > vector
bool operator< (const Type &pValue) const
 vector > vector
bool operator>= (const Type &pValue) const
 vector > vector
bool operator<= (const Type &pValue) const
 vector > vector
bool operator== (const Vector< Type > &pVector) const
 vector == vector
bool operator!= (const Vector< Type > &pVector) const
 vector != vector
bool operator> (const math::Vector< Type > &pVector) const throw (MathException)
 vector > vector
bool operator< (const math::Vector< Type > &pVector) const throw (MathException)
 vector < vector
bool operator>= (const math::Vector< Type > &pVector) const throw (MathException)
 vector >= vector
bool operator<= (const math::Vector< Type > &pVector) const throw (MathException)
 vector <= vector
void normalise ()
 normalise vector length
void limit (Type pMaxLength)
 limit vector length to max length
void truncate (Type pThresh1, Type pThresh2)
 truncates a signal, crops everything above the upper threshold and below the lower threshold
void truncate (const Vector< Type > &pThresh1, const Vector< Type > &pThresh2) throw (MathException)
 truncates a signal, crops everything above the upper threshold and below the lower threshold
void invert ()
 invert vector
 operator base::String () const
base::String info () const
 print vector information

Static Public Member Functions

static Type dot (const Vector< Type > &pVector1, const Vector< Type > &pVector2) throw (MathException)
 vector dot product
static Vector< Type > project (const Vector< Type > &pVector1, const Vector< Type > &pVector2) throw (MathException)
 projects vector 1 on vector 2

Public Attributes

Type * c
 vector elements

Protected Attributes

unsigned int mDim
 dimension

Static Protected Attributes

static unsigned int sDim
 default dimension

Friends

std::ostream & operator<< (std::ostream &pOstream, const Vector< Type > &pVector)
 print vector information

Detailed Description

template<class Type>
class iso::math::Vector< Type >

vector class

Vectors are always treated as column vectors!

Created by Daniel Bisig on 7/16/06. Copyright 2006 Daniel Bisig All rights reserved.


Constructor & Destructor Documentation

template<class Type>
iso::math::Vector< Type >::Vector (  ) 

create default zero vector

template<class Type>
iso::math::Vector< Type >::Vector ( unsigned int  pDim  ) 

create zero vector

Parameters:
pDim size of vector

template<class Type>
iso::math::Vector< Type >::Vector ( unsigned int  pDim,
Type  pValue 
)

create vector containing identical values

Parameters:
pDim size of vector
pValue value

template<class Type>
iso::math::Vector< Type >::Vector ( unsigned int  pDim,
const Type *  pValues 
)

create vector from array of values

Parameters:
pDim size of vector
pValues array of values (must be of correct size)

template<class Type>
template<typename Type2>
iso::math::Vector< Type >::Vector ( unsigned int  pDim,
const Type2 *  pValues 
)

create vector from array of values

Parameters:
pDim size of vector
pValues array of values (must be of correct size)

template<class Type>
iso::math::Vector< Type >::Vector ( unsigned int  pDim,
double  pValue1,
double  pValue2,
  ... 
) throw (MathException)

create vector from parameter list of values

Parameters:
pDim size of vector
pValue1 value 1
pValue2 value 2
Exceptions:
MathException pDim smaller than 2

template<class Type>
iso::math::Vector< Type >::Vector ( const Vector< Type > &  pVector  ) 

create vector from vector

Parameters:
pVector vector to copy

template<class Type>
template<class Type2>
iso::math::Vector< Type >::Vector ( const Vector< Type2 > &  pVector  ) 

create vector from vector

Parameters:
pVector vector to copy

template<class Type>
iso::math::Vector< Type >::~Vector (  )  [virtual]

destructor


Member Function Documentation

template<class Type>
void iso::math::Vector< Type >::reset (  ) 

set all vector elements to 0

template<class Type>
void iso::math::Vector< Type >::setDim ( unsigned int  pDim  )  [virtual]

set dimension of vector

Parameters:
pDim new vector dimension
original values are preserved as far as possible. when vector dimension increases, new elements contain zero when vector dimension decreases, previous values at positions that are beyond new dimension

Reimplemented in iso::math::Vector2< Type >, iso::math::Vector3< Type >, iso::math::Vector4< Type >, and iso::math::Vector2< unsigned int >.

template<class Type>
void iso::math::Vector< Type >::set ( Type  pValue  )  [inline]

set vector to identical values

Parameters:
pValue value

template<typename Type>
void iso::math::Vector< Type >::set ( Type  pValue,
unsigned int  pDim 
) throw (MathException) [inline]

set vector to new dimension and set all it's components to pValue

Parameters:
pValue value
pDim new vector dimension
Exceptions:
MathException always since this is an illegal function

Reimplemented in iso::math::Vector2< unsigned int >.

template<class Type>
void iso::math::Vector< Type >::set ( const Type *  pValues  )  [inline]

set vector to values from array

Parameters:
pValues array of values
Remarks:
array of values must be of correct size

template<class Type>
void iso::math::Vector< Type >::set ( unsigned int  pDim,
double  pValue1,
double  pValue2,
  ... 
) throw (MathException) [inline]

set vector to parameter list of values

Parameters:
pDim size of vector
pValue1 value 1
pValue2 value 2
Exceptions:
MathException pDim smaller than 2 or dimension mismatch

template<class Type>
void iso::math::Vector< Type >::set ( const Vector< Type > &  pVector  )  throw (MathException) [inline]

set vector to values from vector

Parameters:
pVector vector to copy values from
Exceptions:
MathException dimension mismatch

template<typename Type>
void iso::math::Vector< Type >::set ( const Vector< Type > &  pVector,
bool  pResize 
) throw (MathException) [inline]

set vector to values from vector

Parameters:
pVector vector to copy values from
pResize change vector dim if necessary
Exceptions:
MathException always since this is an illegal vector function

template<class Type>
void iso::math::Vector< Type >::setLength ( Type  pLength  ) 

scale vector to new length

Parameters:
pLength new length

template<class Type>
const Vector< Type > & iso::math::Vector< Type >::operator= ( Type  pValue  )  [inline]

vector = value

Parameters:
pValue value
Returns:
vector

template<class Type>
const Vector< Type > & iso::math::Vector< Type >::operator= ( const Type *  pValues  )  [inline]

vector = values[]

Parameters:
pValues array of values (array must be of correct length)
Returns:
vector

template<class Type>
const Vector< Type > & iso::math::Vector< Type >::operator= ( const Vector< Type > &  pVector  )  throw (MathException) [inline]

vector = vector

Parameters:
pVector vector to copy values from
Returns:
vector
Exceptions:
MathException dimension mismatch

Reimplemented in iso::math::Vector2< Type >, iso::math::Vector3< Type >, iso::math::Vector4< Type >, and iso::math::Vector2< unsigned int >.

template<class Type>
Type & iso::math::Vector< Type >::operator[] ( unsigned int  pIndex  )  throw (MathException) [inline]

vector[]

Parameters:
pIndex index of vector component
Returns:
value
Exceptions:
MathException index out of bounds

template<class Type>
const Type & iso::math::Vector< Type >::operator[] ( unsigned int  pIndex  )  const throw (MathException) [inline]

operator[]

Parameters:
pIndex index of vector component
Returns:
constant value
Exceptions:
MathException index out of bounds

template<class Type>
const unsigned int & iso::math::Vector< Type >::dim (  )  const [inline]

return size of vector

Returns:
size of vector

template<class Type>
Type * iso::math::Vector< Type >::values (  ) 

return vector values

Returns:
vector values (as array)

template<class Type>
const Type * iso::math::Vector< Type >::values (  )  const

return vector values

Returns:
vector values (as const array)

template<class Type>
Type iso::math::Vector< Type >::length (  )  const [inline]

return length of vector

Returns:
length of vector

template<class Type>
Type iso::math::Vector< Type >::lengthSquared (  )  const [inline]

return length^2 of vector

Returns:
length^2 of vector

template<class Type>
const Vector< Type > & iso::math::Vector< Type >::operator+= ( const Type  pValue  )  [inline]

vector += value

Parameters:
pValue value
Returns:
vector

template<class Type>
const Vector< Type > & iso::math::Vector< Type >::operator-= ( const Type  pValue  )  [inline]

vector -= value

Parameters:
pValue value
Returns:
vector

template<class Type>
const Vector< Type > & iso::math::Vector< Type >::operator *= ( const Type  pValue  )  [inline]

vector *= value

Parameters:
pValue value
Returns:
vector

template<class Type>
const Vector< Type > & iso::math::Vector< Type >::operator/= ( Type  pValue  )  [inline]

vector /= value

Parameters:
pValue value
Returns:
vector

template<class Type>
Vector< Type > iso::math::Vector< Type >::operator+ ( const Type  pValue  )  const [inline]

vector + value

Parameters:
pValue value
Returns:
vector

template<class Type>
Vector< Type > iso::math::Vector< Type >::operator- ( const Type  pValue  )  const [inline]

vector - value

Parameters:
pValue value
Returns:
vector

template<class Type>
Vector< Type > iso::math::Vector< Type >::operator * ( const Type  pValue  )  const [inline]

vector * value

Parameters:
pValue value
Returns:
vector

template<class Type>
Vector< Type > iso::math::Vector< Type >::operator/ ( Type  pValue  )  const [inline]

vector / value

Parameters:
pValue value
Returns:
vector

template<class Type>
const Vector< Type > & iso::math::Vector< Type >::operator+= ( const Vector< Type > &  pVector  )  throw (MathException) [inline]

vector += vector

Parameters:
pVector vector
Returns:
vector
Exceptions:
MathException dimension mismatch

template<class Type>
const Vector< Type > & iso::math::Vector< Type >::operator-= ( const Vector< Type > &  pVector  )  throw (MathException) [inline]

vector -= vector

Parameters:
pVector vector
Returns:
vector
Exceptions:
MathException dimension mismatch

template<class Type>
const Vector< Type > & iso::math::Vector< Type >::operator *= ( const Vector< Type > &  pVector  )  throw (MathException) [virtual]

vector *= vector

Parameters:
pVector vector
Returns:
vector
Exceptions:
MathException dimension mismatch

template<class Type>
const Vector< Type > & iso::math::Vector< Type >::operator/= ( const Vector< Type > &  pVector  )  throw (MathException) [inline]

vector /= vector

Parameters:
pVector vector
Returns:
vector
Exceptions:
MathException dimension mismatch

template<class Type>
Vector< Type > iso::math::Vector< Type >::operator+ ( const Vector< Type > &  pVector  )  const throw (MathException) [inline]

vector + vector

Parameters:
pVector vector
Returns:
vector
Exceptions:
MathException dimension mismatch

template<class Type>
Vector< Type > iso::math::Vector< Type >::operator- ( const Vector< Type > &  pVector  )  const throw (MathException) [inline]

vector - vector

Parameters:
pVector vector
Returns:
vector
Exceptions:
MathException dimension mismatch

template<class Type>
Vector< Type > iso::math::Vector< Type >::operator * ( const Vector< Type > &  pVector  )  const throw (MathException) [virtual]

vector * vector

Parameters:
pVector vector
Returns:
vector
Exceptions:
MathException dimension mismatch

template<class Type>
Vector< Type > iso::math::Vector< Type >::operator/ ( const Vector< Type > &  pVector  )  const throw (MathException) [inline]

vector / vector

Parameters:
pVector vector
Returns:
vector
Exceptions:
MathException dimension mismatch

template<class Type>
Type iso::math::Vector< Type >::dot ( const Vector< Type > &  pVector  )  const throw (MathException) [inline]

vector dot product

Parameters:
pVector vector
Returns:
dot product
Exceptions:
MathException dimension mismatch

template<class Type>
Type iso::math::Vector< Type >::dot ( const Vector< Type > &  pVector1,
const Vector< Type > &  pVector2 
) throw (MathException) [static]

vector dot product

Parameters:
pVector1 vector 1
pVector2 vector 2
Returns:
dot product
Exceptions:
MathException dimension mismatch

template<class Type>
Type iso::math::Vector< Type >::sum (  )  const [inline]

return sum of all vector components

Returns:
return sum of all vector components

template<class Type>
Type iso::math::Vector< Type >::product (  )  const [inline]

return product of all vector components

Returns:
return product of all vector components

template<class Type>
Vector< Type > iso::math::Vector< Type >::project ( const Vector< Type > &  pVector1,
const Vector< Type > &  pVector2 
) throw (MathException) [static]

projects vector 1 on vector 2

Parameters:
pVector1 vector 1
pVector2 vector 2
Returns:
returns projected vector
Exceptions:
MathException dimension mismatch \

template<class Type>
bool iso::math::Vector< Type >::operator== ( const Type &  pValue  )  const [inline]

vector == pValue

Parameters:
pValue scalar value
Returns:
true if all elements are equal to scalar value, false otherwise

template<class Type>
bool iso::math::Vector< Type >::operator!= ( const Type &  pValue  )  const [inline]

vector != pValue

Parameters:
pValue scalar value
Returns:
true if one of the elements is not equal to scalar value, false otherwise

template<class Type>
bool iso::math::Vector< Type >::operator> ( const Type &  pValue  )  const [inline]

vector > vector

Parameters:
pValue scalar value
Returns:
true if all elements are larger than scalar value, false otherwise

template<class Type>
bool iso::math::Vector< Type >::operator< ( const Type &  pValue  )  const [inline]

vector > vector

Parameters:
pValue scalar value
Returns:
true if all elements are smaller than scalar value, false otherwise

template<class Type>
bool iso::math::Vector< Type >::operator>= ( const Type &  pValue  )  const [inline]

vector > vector

Parameters:
pValue scalar value
Returns:
true if all elements are larger or equal than scalar value, false otherwise

template<class Type>
bool iso::math::Vector< Type >::operator<= ( const Type &  pValue  )  const [inline]

vector > vector

Parameters:
pValue scalar value
Returns:
true if all elements are smaller or equal than scalar value, false otherwise

template<class Type>
bool iso::math::Vector< Type >::operator== ( const Vector< Type > &  pVector  )  const [inline]

vector == vector

Returns:
true if both vector length and all elements are equal, false otherwise

template<class Type>
bool iso::math::Vector< Type >::operator!= ( const Vector< Type > &  pVector  )  const [inline]

vector != vector

Returns:
true if either vector length or one of the elements is not equal, false otherwise

template<class Type>
bool iso::math::Vector< Type >::operator> ( const math::Vector< Type > &  pVector  )  const throw (MathException) [inline]

vector > vector

Parameters:
pVector vector
Returns:
vector
Exceptions:
MathException dimension mismatch

template<class Type>
bool iso::math::Vector< Type >::operator< ( const math::Vector< Type > &  pVector  )  const throw (MathException) [inline]

vector < vector

Parameters:
pVector vector
Returns:
vector
Exceptions:
MathException dimension mismatch

template<class Type>
bool iso::math::Vector< Type >::operator>= ( const math::Vector< Type > &  pVector  )  const throw (MathException) [inline]

vector >= vector

Parameters:
pVector vector
Returns:
vector
Exceptions:
MathException dimension mismatch

template<class Type>
bool iso::math::Vector< Type >::operator<= ( const math::Vector< Type > &  pVector  )  const throw (MathException) [inline]

vector <= vector

Parameters:
pVector vector
Returns:
vector
Exceptions:
MathException dimension mismatch

template<class Type>
void iso::math::Vector< Type >::normalise (  )  [inline]

normalise vector length

template<class Type>
void iso::math::Vector< Type >::limit ( Type  pMaxLength  )  [inline]

limit vector length to max length

template<class Type>
void iso::math::Vector< Type >::truncate ( Type  pThresh1,
Type  pThresh2 
) [inline]

truncates a signal, crops everything above the upper threshold and below the lower threshold

Parameters:
pThresh1 lower threshold
pThresh2 upper threshold

template<class Type>
void iso::math::Vector< Type >::truncate ( const Vector< Type > &  pThresh1,
const Vector< Type > &  pThresh2 
) throw (MathException) [inline]

truncates a signal, crops everything above the upper threshold and below the lower threshold

Parameters:
pThresh1 lower threshold
pThresh2 upper threshold
Exceptions:
MathException dimension mismatch

template<class Type>
void iso::math::Vector< Type >::invert (  )  [inline]

invert vector

template<class Type>
iso::math::Vector< Type >::operator base::String (  )  const [inline]

template<class Type>
base::String iso::math::Vector< Type >::info (  )  const

print vector information


Friends And Related Function Documentation

template<class Type>
std::ostream& operator<< ( std::ostream &  pOstream,
const Vector< Type > &  pVector 
) [friend]

print vector information

Parameters:
pOstream output stream
pVector vector
Returns:
output stream


Member Data Documentation

template<class Type>
Type* iso::math::Vector< Type >::c

vector elements

template<class Type>
unsigned int iso::math::Vector< Type >::mDim [protected]

dimension

template<class Type>
unsigned int iso::math::Vector< Type >::sDim [static, protected]

default dimension


The documentation for this class was generated from the following file:
Generated on Fri Feb 25 14:04:07 2011 for iso_math by  doxygen 1.5.1