ParM  parm
A molecular dynamics library
Public Member Functions | Friends | List of all members
NumVector< T, N > Class Template Reference

An N-dimensional physics vector, extending NVector. More...

#include <vec.hpp>

Inheritance diagram for NumVector< T, N >:
NVector< T, N >

Public Member Functions

 NumVector ()
 
 NumVector (const NVector< T, N > &rhs)
 
 NumVector (const T rhs[N])
 
dot (const NumVector &other) const
 Inner product. More...
 
sq () const
 
mag () const
 The square of the vector, \(\vec r^2 \). More...
 
distance (const NumVector &rhs) const
 The magnitude of the vector, \( \left| \vec r \right| \). More...
 
NumVector perpto (const NumVector &other) const
 
void normalize ()
 Normalize in place. More...
 
NumVector norm () const
 Return the normalized version. More...
 
 ~NumVector ()
 
template<>
double distance (const NumVector< double, 2 > &rhs) const
 
template<>
long double distance (const NumVector< long double, 2 > &rhs) const
 
template<>
double distance (const NumVector< double, 3 > &rhs) const
 
template<>
long double distance (const NumVector< long double, 3 > &rhs) const
 
template<>
double mag () const
 
template<>
long double mag () const
 
template<>
double mag () const
 
template<>
long double mag () const
 
- Public Member Functions inherited from NVector< T, N >
 NVector ()
 
 NVector (const NVector &rhs)
 
template<class U >
 NVector (const NVector< U, N > &rhs)
 
 NVector (const T locs[N])
 
const T & get (const unsigned int n) const
 
void set (const unsigned int n, const T a)
 
unsigned int len () const
 
NVectoroperator+= (const NVector &rhs)
 
NVectoroperator-= (const NVector &rhs)
 
template<class U >
NVectoroperator*= (const U rhs)
 
template<class U >
NVectoroperator/= (const U rhs)
 
NVector operator- () const
 
NVector operator+ (const NVector &rhs) const
 
NVector operator- (const NVector &rhs) const
 
T & operator[] (const unsigned int i)
 
const T & operator[] (const unsigned int i) const
 
template<class U >
NVector operator* (const U rhs) const
 Multiplication by a scalar. More...
 
template<class U >
NVector operator/ (const U rhs) const
 Division by a scalar. More...
 
T * begin ()
 
T * end ()
 
 ~NVector ()
 
template<class U >
NVector< T, N > & operator*= (const U rhs)
 
template<class U >
NVector< T, N > & operator/= (const U rhs)
 

Friends

template<class U , unsigned int M>
ostream & operator<< (ostream &out, const NumVector< U, M > v)
 

Additional Inherited Members

- Public Types inherited from NVector< T, N >
typedef T * iterator
 
- Protected Attributes inherited from NVector< T, N >
vals [N]
 

Detailed Description

template<class T, unsigned int N>
class NumVector< T, N >

An N-dimensional physics vector, extending NVector.

This extends addition, subtraction, and multiplication from the type T to the NVector class.

Template Parameters
Ta numerical type, as as float or double.
Nthe number of dimensions.

Constructor & Destructor Documentation

template<class T, unsigned int N>
NumVector< T, N >::NumVector ( )
inline
template<class T, unsigned int N>
NumVector< T, N >::NumVector ( const NVector< T, N > &  rhs)
inline
template<class T, unsigned int N>
NumVector< T, N >::NumVector ( const T  rhs[N])
inline
template<class T, unsigned int N>
NumVector< T, N >::~NumVector ( )
inline

Member Function Documentation

template<class T , unsigned int N>
T NumVector< T, N >::distance ( const NumVector< T, N > &  rhs) const
inline

The magnitude of the vector, \( \left| \vec r \right| \).

The magnitude of the vector distance, \( \left| \vec r - \vec s \right| \).

Parameters
rhsThe other vector, \(\vec s \)
template<>
double NumVector< double, 2 >::distance ( const NumVector< double, 2 > &  rhs) const
inline
template<>
long double NumVector< long double, 2 >::distance ( const NumVector< long double, 2 > &  rhs) const
inline
template<>
double NumVector< double, 3 >::distance ( const NumVector< double, 3 > &  rhs) const
inline
template<>
long double NumVector< long double, 3 >::distance ( const NumVector< long double, 3 > &  rhs) const
inline
template<class T , unsigned int N>
T NumVector< T, N >::dot ( const NumVector< T, N > &  other) const

Inner product.

template<class T, unsigned int N>
T NumVector< T, N >::mag ( ) const
inline

The square of the vector, \(\vec r^2 \).

template<>
double NumVector< double, 2 >::mag ( ) const
inline
template<>
long double NumVector< long double, 2 >::mag ( ) const
inline
template<>
double NumVector< double, 3 >::mag ( ) const
inline
template<>
long double NumVector< long double, 3 >::mag ( ) const
inline
template<class T , unsigned int N>
NumVector< T, N > NumVector< T, N >::norm ( ) const

Return the normalized version.

template<class T , unsigned int N>
void NumVector< T, N >::normalize ( )

Normalize in place.

template<class T , unsigned int N>
NumVector< T, N > NumVector< T, N >::perpto ( const NumVector< T, N > &  other) const

returns the component of this perpendicular to other.

\( \vec r - \frac{\vec r \cdot \vec s}{\vec s^2} \vec s \)

where \( \vec r \) is this vector, and \(\vec s \) is rhs.

Parameters
otherThe other vector, \(\vec s\)
template<class T, unsigned int N>
T NumVector< T, N >::sq ( ) const
inline

Friends And Related Function Documentation

template<class T, unsigned int N>
template<class U , unsigned int M>
ostream& operator<< ( ostream &  out,
const NumVector< U, M >  v 
)
friend

The documentation for this class was generated from the following file: