Public Member Functions

mth::Vector< T, N > Class Template Reference

compile-time (static) vector of size N More...

Inheritance diagram for mth::Vector< T, N >:
can::Array< T, N >

List of all members.

Public Member Functions

 Vector ()
 default constructor
 Vector (unsigned n)
 construct with n elems
 Vector (T const *v)
 construct from an array
T & operator() (unsigned i)
 mutable index operator
T const & operator() (unsigned i) const
 immutable index operator
Vector< T, N > & operator+= (Vector< T, N > const &b)
 add a vector to this vector
Vector< T, N > operator+ (Vector< T, N > const &b) const
 add two vectors
Vector< T, N > & operator-= (Vector< T, N > const &b)
 subtract a vector from this vector
Vector< T, N > operator- (Vector< T, N > const &b) const
 subtract two vectors
Vector< T, N > operator* (T const &s) const
 multiply a vector times a scalar
Vector< T, N > operator/ (T const &s) const
 divide a vector by a scalar
operator* (Vector< T, N > const &b) const
 vector dot product
getLength () const
 get the vector magnitude
Vector< T, N > normalize () const
 divide the vector by its magnitude
void zero ()
 zero the vector

Detailed Description

template<class T, unsigned N = 0>
class mth::Vector< T, N >

compile-time (static) vector of size N

This class endows Array<T,N> with the standard mathematical properties of a linear algebra vector. The vector is templated on scalar type so that math can be performed for a variety of (meaningful) scalar types.


Constructor & Destructor Documentation

template<class T, unsigned N = 0>
mth::Vector< T, N >::Vector ( unsigned  n  )  [inline]

construct with n elems

A dummy constructor Vector(n) is provided so that dynamic and static vectors can be used interchangebly


Member Function Documentation

template<class T, unsigned N = 0>
T& mth::Vector< T, N >::operator() ( unsigned  i  )  [inline]

mutable index operator

An index operator (i) is provided so that mth::Vector and mth::Matrix share a common index operator

template<class T, unsigned N = 0>
T mth::Vector< T, N >::operator* ( Vector< T, N > const &  b  )  const [inline]

vector dot product

we chose the default vector-vector multiplication operator to be the dot product. so far this seems to have been a good choice

template<class T, unsigned N = 0>
Vector<T,N> mth::Vector< T, N >::operator* ( T const &  s  )  const [inline]

multiply a vector times a scalar

currently there is no scalar times vector operator, so do be sure to put scalar on the right hand side

template<class T, unsigned N = 0>
Vector<T,N> mth::Vector< T, N >::operator/ ( T const &  s  )  const [inline]

divide a vector by a scalar

equivalent to scaling by 1/s


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines