Shiokaze Framework
A research-oriented fluid solver for computer graphics
vec< T, D > Struct Template Reference

Fixed sized vector structure. More...

#include <vec.h>

Public Member Functions

 vec ()
 Default constructor.
 
template<class Y >
 vec (const Y *v)
 Copy constructor. More...
 
template<class Y >
 vec (const vec< Y, D > &v)
 Copy constructor. More...
 
 vec (T v)
 Constructor. More...
 
 vec (T x, T y)
 Constructor for two dimensional vector. More...
 
 vec (T x, T y, T z)
 Constructor for three dimensional vector. More...
 
const T & operator[] (unsigned idx) const
 Get the value at a specified dimension. More...
 
T & operator[] (unsigned idx)
 Get the reference to the value at a specified dimension. More...
 
bool empty () const
 Get if all the elements in the vector is empty. More...
 
bool operator== (const vec &v) const
 Get if the vector is equal to the input vector. More...
 
bool operator!= (const vec &v) const
 Get if the vector is not equal to the input vector. More...
 
template<class Y >
vec< T, D > operator+ (const vec< Y, D > &v) const
 Add a vector. More...
 
template<class Y >
vec< T, D > operator- (const vec< Y, D > &v) const
 Subtract a vector. More...
 
template<class Y >
void operator+= (const vec< Y, D > &v)
 Add a vector. More...
 
template<class Y >
void operator-= (const vec< Y, D > &v)
 Subtract a vector. More...
 
template<class Y >
vec operator* (Y s) const
 Multiply a value. More...
 
template<class Y >
vec operator/ (Y s) const
 Divide by a value. More...
 
template<class Y >
void operator*= (Y s)
 Multiply a value. More...
 
template<class Y >
void operator/= (Y s)
 Divide by a value. More...
 
template<class Y >
operator* (vec< Y, D > v) const
 Compute the dot product. More...
 
double norm2 () const
 Compute L2 norm. More...
 
double norm_inf () const
 Compute L-inf norm. More...
 
double len () const
 Compute L1 norm. More...
 
vec normal () const
 Compute normalized vector. More...
 
bool normalize ()
 Normaliz vector.
 
vec rotate90 () const
 Rotate vector 90 degrees counterclockwise. More...
 
template<class Y = double>
cross2 (const vec< Y, 2 > &r) const
 Compute the cross product for two dimensions. More...
 
template<class Y = double>
vec< T, 3 > cross (const vec< Y, 3 > &r) const
 Compute the cross product for three dimensions. More...
 
template<class Y = double>
vec< Y, D > cell () const
 Compute the position of the center of a cell from the index space. More...
 
template<class Y = double>
vec< Y, D > nodal () const
 Compute the position of the nodal position from the index space. More...
 
template<class Y = double>
vec< Y, D > face (int dim) const
 Compute the position of the center of face position from the index space. More...
 
template<class Y = double>
vec< Y, D > edge (int dim) const
 Compute the position of the center of edge position from the index space. More...
 

Public Attributes

v [D]
 Vector value array.
 

Detailed Description

template<class T, unsigned D>
struct vec< T, D >

Fixed sized vector structure.

Constructor & Destructor Documentation

◆ vec() [1/5]

template<class T , unsigned D>
template<class Y >
vec< T, D >::vec ( const Y *  v)
inline

Copy constructor.

Parameters
[in]vC array to the vector values from which to copy.

◆ vec() [2/5]

template<class T , unsigned D>
template<class Y >
vec< T, D >::vec ( const vec< Y, D > &  v)
inline

Copy constructor.

Parameters
[in]vA vector from which to copy.

◆ vec() [3/5]

template<class T , unsigned D>
vec< T, D >::vec ( v)
inline

Constructor.

Parameters
[in]vValue with which to initialize.

◆ vec() [4/5]

template<class T , unsigned D>
vec< T, D >::vec ( x,
y 
)
inline

Constructor for two dimensional vector.

Parameters
[in]xValue for the first dimension.
[in]yValue for the second dimension.

◆ vec() [5/5]

template<class T , unsigned D>
vec< T, D >::vec ( x,
y,
z 
)
inline

Constructor for three dimensional vector.

Parameters
[in]xValue for the first dimension.
[in]yValue for the second dimension.
[in]zValue for the third dimension.

Member Function Documentation

◆ cell()

template<class T , unsigned D>
template<class Y = double>
vec<Y,D> vec< T, D >::cell ( ) const
inline

Compute the position of the center of a cell from the index space.

Returns
Cell center position.

◆ cross()

template<class T , unsigned D>
template<class Y = double>
vec<T,3> vec< T, D >::cross ( const vec< Y, 3 > &  r) const
inline

Compute the cross product for three dimensions.

Parameters
[in]rThree dimensoinal vector.
Returns
Result.

◆ cross2()

template<class T , unsigned D>
template<class Y = double>
T vec< T, D >::cross2 ( const vec< Y, 2 > &  r) const
inline

Compute the cross product for two dimensions.

Parameters
[in]rTwo dimensoinal vector.
Returns
Result.

◆ edge()

template<class T , unsigned D>
template<class Y = double>
vec<Y,D> vec< T, D >::edge ( int  dim) const
inline

Compute the position of the center of edge position from the index space.

Parameters
[in]dimDimension of the edge.
Returns
Edge center position.

◆ empty()

template<class T , unsigned D>
bool vec< T, D >::empty ( ) const
inline

Get if all the elements in the vector is empty.

Returns
true if all the elements in the vector is zero. false otherwise.

◆ face()

template<class T , unsigned D>
template<class Y = double>
vec<Y,D> vec< T, D >::face ( int  dim) const
inline

Compute the position of the center of face position from the index space.

Parameters
[in]dimDimension of the face.
Returns
Face center position.

◆ len()

template<class T , unsigned D>
double vec< T, D >::len ( ) const
inline

Compute L1 norm.

Returns
L1 norm.

◆ nodal()

template<class T , unsigned D>
template<class Y = double>
vec<Y,D> vec< T, D >::nodal ( ) const
inline

Compute the position of the nodal position from the index space.

Returns
Nodal position.

◆ norm2()

template<class T , unsigned D>
double vec< T, D >::norm2 ( ) const
inline

Compute L2 norm.

Returns
L2 norm.

◆ norm_inf()

template<class T , unsigned D>
double vec< T, D >::norm_inf ( ) const
inline

Compute L-inf norm.

Returns
L-inf norm.

◆ normal()

template<class T , unsigned D>
vec vec< T, D >::normal ( ) const
inline

Compute normalized vector.

Returns
Normalized vector.

◆ operator!=()

template<class T , unsigned D>
bool vec< T, D >::operator!= ( const vec< T, D > &  v) const
inline

Get if the vector is not equal to the input vector.

Returns
true if the vector is not equal to the input vector. false otherwise.

◆ operator*() [1/2]

template<class T , unsigned D>
template<class Y >
T vec< T, D >::operator* ( vec< Y, D >  v) const
inline

Compute the dot product.

Parameters
[in]vInput vector.
Returns
Dot product result.

◆ operator*() [2/2]

template<class T , unsigned D>
template<class Y >
vec vec< T, D >::operator* ( s) const
inline

Multiply a value.

Parameters
[in]sValue to multiply.
Returns
Result.

◆ operator*=()

template<class T , unsigned D>
template<class Y >
void vec< T, D >::operator*= ( s)
inline

Multiply a value.

Parameters
[in]sValue to multiply.

◆ operator+()

template<class T , unsigned D>
template<class Y >
vec<T,D> vec< T, D >::operator+ ( const vec< Y, D > &  v) const
inline

Add a vector.

Parameters
[in]vVector to add.
Returns
Added vector.

◆ operator+=()

template<class T , unsigned D>
template<class Y >
void vec< T, D >::operator+= ( const vec< Y, D > &  v)
inline

Add a vector.

Parameters
[in]vVector to add.

◆ operator-()

template<class T , unsigned D>
template<class Y >
vec<T,D> vec< T, D >::operator- ( const vec< Y, D > &  v) const
inline

Subtract a vector.

Parameters
[in]vVector to subtract.
Returns
Subtracted vector.

◆ operator-=()

template<class T , unsigned D>
template<class Y >
void vec< T, D >::operator-= ( const vec< Y, D > &  v)
inline

Subtract a vector.

Parameters
[in]vVector to subtract.

◆ operator/()

template<class T , unsigned D>
template<class Y >
vec vec< T, D >::operator/ ( s) const
inline

Divide by a value.

Parameters
[in]sValue to divide.
Returns
Result.

◆ operator/=()

template<class T , unsigned D>
template<class Y >
void vec< T, D >::operator/= ( s)
inline

Divide by a value.

Parameters
[in]sValue to divide.

◆ operator==()

template<class T , unsigned D>
bool vec< T, D >::operator== ( const vec< T, D > &  v) const
inline

Get if the vector is equal to the input vector.

Returns
true if the vector is equal to the input vector. false otherwise.

◆ operator[]() [1/2]

template<class T , unsigned D>
T& vec< T, D >::operator[] ( unsigned  idx)
inline

Get the reference to the value at a specified dimension.

Parameters
[in]idxIndex position.
Returns
Reference of the value at the position.

◆ operator[]() [2/2]

template<class T , unsigned D>
const T& vec< T, D >::operator[] ( unsigned  idx) const
inline

Get the value at a specified dimension.

Parameters
[in]idxIndex position.
Returns
Value at the position.

◆ rotate90()

template<class T , unsigned D>
vec vec< T, D >::rotate90 ( ) const
inline

Rotate vector 90 degrees counterclockwise.

Returns
Rotated vector.

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