Wonton::Vector< D > Class Template Reference

Represents a vector in N-dimensional space. More...

#include <Vector.h>

Public Member Functions

WONTON_INLINE Vector ()
 Default constructor - zero Vector in D-space. More...
 
WONTON_INLINE Vector (const double &xm_comp)
 Initialize all components to same value (also constructor for 1d vectors) More...
 
WONTON_INLINE Vector (const double &xm_comp, const double &ym_comp)
 Specialized constructor for 2d Vectors. More...
 
WONTON_INLINE Vector (const double &xm_comp, const double &ym_comp, const double &zm_comp)
 Specialized constructor for 3d Vectors. More...
 
 Vector (std::vector< double > const &invec)
 Constructor from a std:vector. More...
 
WONTON_INLINE const double & operator[] (const int &i) const
 Return component i of the Vector. More...
 
WONTON_INLINE double & operator[] (const int &i)
 Return component i of the Vector. More...
 
WONTON_INLINE Vector operator- () const
 Negative of this vector. More...
 
WONTON_INLINE Vectoroperator+= (const Vector< D > &rhs)
 Add the Vector rhs to this Vector. More...
 
WONTON_INLINE Vectoroperator-= (const Vector< D > &rhs)
 Subtract the Vector rhs from this vector. More...
 
WONTON_INLINE Vectoroperator*= (const double &s)
 Scalar multiplication of this Vector by s. More...
 
WONTON_INLINE Vectoroperator/= (const double &s)
 Scalar division of this Vector by s. More...
 
WONTON_INLINE double norm (bool doSqrt=true) const
 Calculate the norm of a Vector. More...
 
WONTON_INLINE double one_norm () const
 Calculate the 1-norm of a Vector. More...
 
WONTON_INLINE double max_norm () const
 Calculate the max norm of a Vector. More...
 
WONTON_INLINE void normalize ()
 Convert this Vector into a unit Vector. More...
 
WONTON_INLINE void zero ()
 Convert this Vector into a zero Vector. More...
 
WONTON_INLINE bool is_zero (double dst_tol) const
 Check if this Vector is a zero Vector. More...
 
WONTON_INLINE void fill (double val)
 Convenience method for constructing a Vector with all components equal to a given value. More...
 
WONTON_INLINE void axis (int nonZero)
 Convenience method for constructing a unit Vector along a particular axis. More...
 
std::istream & readFromStream (std::istream &is)
 Read in a Vector from an input stream. More...
 
std::ostream & writeToStream (std::ostream &os) const
 Pretty printing of a Vector to an output stream. More...
 

Detailed Description

template<int D>
class Wonton::Vector< D >

Represents a vector in N-dimensional space.

Template Parameters
DIndicates the dimensionality of the Vector (this will generally be one of [1, 2, 3]).

Constructor & Destructor Documentation

◆ Vector() [1/5]

template<int D>
WONTON_INLINE Wonton::Vector< D >::Vector ( )
inline

Default constructor - zero Vector in D-space.

◆ Vector() [2/5]

template<int D>
WONTON_INLINE Wonton::Vector< D >::Vector ( const double &  xm_comp)
inline

Initialize all components to same value (also constructor for 1d vectors)

Parameters
[in]xm_compThe x coordinate.

◆ Vector() [3/5]

template<int D>
WONTON_INLINE Wonton::Vector< D >::Vector ( const double &  xm_comp,
const double &  ym_comp 
)
inline

Specialized constructor for 2d Vectors.

Parameters
[in]xm_comp,ym_compThe (x,y) coordinate pair.

◆ Vector() [4/5]

template<int D>
WONTON_INLINE Wonton::Vector< D >::Vector ( const double &  xm_comp,
const double &  ym_comp,
const double &  zm_comp 
)
inline

Specialized constructor for 3d Vectors.

Parameters
[in]xm_comp,ym_comp,zm_compThe (x,y,z) coordinate triple.

◆ Vector() [5/5]

template<int D>
Wonton::Vector< D >::Vector ( std::vector< double > const &  invec)
inline

Constructor from a std:vector.

Member Function Documentation

◆ axis()

template<int D>
WONTON_INLINE void Wonton::Vector< D >::axis ( int  nonZero)
inline

Convenience method for constructing a unit Vector along a particular axis.

Parameters
[in]nonZeroThe coordinate axis along which the Vector should point.

◆ fill()

template<int D>
WONTON_INLINE void Wonton::Vector< D >::fill ( double  val)
inline

Convenience method for constructing a Vector with all components equal to a given value.

Parameters
[in]valueValue to assign to all the components

◆ is_zero()

template<int D>
WONTON_INLINE bool Wonton::Vector< D >::is_zero ( double  dst_tol) const
inline

Check if this Vector is a zero Vector.

Parameters
[in]dst_tolDistance tolerance: Vector is zero if its length is below this tolerance.

◆ max_norm()

template<int D>
WONTON_INLINE double Wonton::Vector< D >::max_norm ( ) const
inline

Calculate the max norm of a Vector.

◆ norm()

template<int D>
WONTON_INLINE double Wonton::Vector< D >::norm ( bool  doSqrt = true) const
inline

Calculate the norm of a Vector.

Parameters
[in]doSqrtOPTIONAL: Return the square root of the norm, i.e. the magnitude of the Vector.

◆ normalize()

template<int D>
WONTON_INLINE void Wonton::Vector< D >::normalize ( )
inline

Convert this Vector into a unit Vector.

◆ one_norm()

template<int D>
WONTON_INLINE double Wonton::Vector< D >::one_norm ( ) const
inline

Calculate the 1-norm of a Vector.

◆ operator*=()

template<int D>
WONTON_INLINE Vector& Wonton::Vector< D >::operator*= ( const double &  s)
inline

Scalar multiplication of this Vector by s.

◆ operator+=()

template<int D>
WONTON_INLINE Vector& Wonton::Vector< D >::operator+= ( const Vector< D > &  rhs)
inline

Add the Vector rhs to this Vector.

◆ operator-()

template<int D>
WONTON_INLINE Vector Wonton::Vector< D >::operator- ( ) const
inline

Negative of this vector.

◆ operator-=()

template<int D>
WONTON_INLINE Vector& Wonton::Vector< D >::operator-= ( const Vector< D > &  rhs)
inline

Subtract the Vector rhs from this vector.

◆ operator/=()

template<int D>
WONTON_INLINE Vector& Wonton::Vector< D >::operator/= ( const double &  s)
inline

Scalar division of this Vector by s.

◆ operator[]() [1/2]

template<int D>
WONTON_INLINE const double& Wonton::Vector< D >::operator[] ( const int &  i) const
inline

Return component i of the Vector.

◆ operator[]() [2/2]

template<int D>
WONTON_INLINE double& Wonton::Vector< D >::operator[] ( const int &  i)
inline

Return component i of the Vector.

◆ readFromStream()

template<int D>
std::istream& Wonton::Vector< D >::readFromStream ( std::istream &  is)
inline

Read in a Vector from an input stream.

◆ writeToStream()

template<int D>
std::ostream& Wonton::Vector< D >::writeToStream ( std::ostream &  os) const
inline

Pretty printing of a Vector to an output stream.

◆ zero()

template<int D>
WONTON_INLINE void Wonton::Vector< D >::zero ( )
inline

Convert this Vector into a zero Vector.


The documentation for this class was generated from the following file:
  • /home/wonton/wonton/wonton/support/Vector.h