Chi-Tech
chi_math::VectorNX< N, NumberFormat > Struct Template Reference

#include <chi_math_vectorNX.h>

Public Member Functions

 VectorNX ()
 
 VectorNX (const NumberFormat value)
 
 VectorNX (const chi_mesh::Vector3 &that)
 
 VectorNX (const std::vector< NumberFormat > &values)
 
VectorNXoperator= (const VectorNX &rhs)
 
VectorNXoperator= (const chi_mesh::Vector3 &rhs)
 
VectorNX operator+ (const VectorNX &rhs) const
 
VectorNXoperator+= (const VectorNX &rhs)
 
VectorNX Shifted (const NumberFormat value) const
 
VectorNXShift (const NumberFormat value)
 
VectorNX operator- (const VectorNX &rhs) const
 
VectorNXoperator-= (const VectorNX &rhs)
 
VectorNX operator* (const NumberFormat value) const
 
VectorNXoperator*= (const NumberFormat value)
 
VectorNX operator* (const VectorNX &rhs) const
 
VectorNXoperator*= (const VectorNX &rhs)
 
VectorNX operator/ (const NumberFormat value) const
 
VectorNXoperator/= (const NumberFormat value)
 
VectorNX operator/ (const VectorNX &rhs) const
 
VectorNXoperator/= (const VectorNX &rhs)
 
NumberFormat operator[] (int i) const
 
NumberFormat & operator() (int i)
 
TensorRNX< 2, N, NumberFormat > OTimes (const VectorNX< N, NumberFormat > &that) const
 
VectorNX< N, NumberFormat > Dot (const TensorRNX< 2, N, NumberFormat > &that) const
 
VectorNX< 3, NumberFormat > Cross (const VectorNX< 2, NumberFormat > &rhs)
 
VectorNX< 3, NumberFormat > Cross (const VectorNX< 3, NumberFormat > &rhs)
 
NumberFormat Dot (const VectorNX &rhs) const
 
NumberFormat Dot (const chi_mesh::Vector3 &rhs) const
 
NumberFormat Norm () const
 
NumberFormat NormSquare () const
 
void Normalize ()
 
VectorNX Normalized () const
 
VectorNX InverseZeroIfSmaller (NumberFormat tol) const
 
VectorNX InverseOneIfSmaller (NumberFormat tol) const
 
VectorNX InverseZeroIfInf () const
 
VectorNX Inverse () const
 
void Print () const
 
std::string PrintS () const
 

Data Fields

std::array< NumberFormat, N > elements
 
const unsigned int dimension
 

Detailed Description

template<int N, class NumberFormat>
struct chi_math::VectorNX< N, NumberFormat >

Generalized vector notion.

Author
Jerry, Jan.

Definition at line 33 of file chi_math_vectorNX.h.

Constructor & Destructor Documentation

◆ VectorNX() [1/4]

template<int N, class NumberFormat >
chi_math::VectorNX< N, NumberFormat >::VectorNX ( )
inline

Default constructor.

Definition at line 39 of file chi_math_vectorNX.h.

◆ VectorNX() [2/4]

template<int N, class NumberFormat >
chi_math::VectorNX< N, NumberFormat >::VectorNX ( const NumberFormat  value)
inline

Constructor with value.

Definition at line 48 of file chi_math_vectorNX.h.

◆ VectorNX() [3/4]

template<int N, class NumberFormat >
chi_math::VectorNX< N, NumberFormat >::VectorNX ( const chi_mesh::Vector3 that)
inline

Constructor with chi_mesh::Vector3.

Definition at line 57 of file chi_math_vectorNX.h.

◆ VectorNX() [4/4]

template<int N, class NumberFormat >
chi_math::VectorNX< N, NumberFormat >::VectorNX ( const std::vector< NumberFormat > &  values)
inline

Constructor with array of values. This allows constructors of the form:

chi_math::Vector3 ihat({1.0,0.0});
chi_math::Vector3 jhat({0.0,1.0,0.0,1.0});
chi_math::Vector3 khat({0.0,0.0,1.0});

Definition at line 75 of file chi_math_vectorNX.h.

Member Function Documentation

◆ Cross() [1/2]

template<int N, class NumberFormat >
VectorNX< 3, NumberFormat > chi_math::VectorNX< N, NumberFormat >::Cross ( const VectorNX< 2, NumberFormat > &  rhs)
inline

Vector cross-product. $ \vec{w} = \vec{x} \times \vec{y} $

Definition at line 290 of file chi_math_vectorNX.h.

◆ Cross() [2/2]

template<int N, class NumberFormat >
VectorNX< 3, NumberFormat > chi_math::VectorNX< N, NumberFormat >::Cross ( const VectorNX< 3, NumberFormat > &  rhs)
inline

Vector cross-product. $ \vec{w} = \vec{x} \times \vec{y} $

Definition at line 310 of file chi_math_vectorNX.h.

◆ Dot() [1/3]

template<int N, class NumberFormat >
NumberFormat chi_math::VectorNX< N, NumberFormat >::Dot ( const chi_mesh::Vector3 rhs) const
inline

Vector dot-product. $ \vec{w} = \vec{x} \bullet \vec{y} $

Definition at line 345 of file chi_math_vectorNX.h.

◆ Dot() [2/3]

template<int N, class NumberFormat >
VectorNX< N, NumberFormat > chi_math::VectorNX< N, NumberFormat >::Dot ( const TensorRNX< 2, N, NumberFormat > &  that) const
inline

Definition at line 278 of file chi_math_vectorNX.h.

◆ Dot() [3/3]

template<int N, class NumberFormat >
NumberFormat chi_math::VectorNX< N, NumberFormat >::Dot ( const VectorNX< N, NumberFormat > &  rhs) const
inline

Vector dot-product. $ \vec{w} = \vec{x} \bullet \vec{y} $

Definition at line 334 of file chi_math_vectorNX.h.

◆ Inverse()

template<int N, class NumberFormat >
VectorNX chi_math::VectorNX< N, NumberFormat >::Inverse ( ) const
inline

Returns a vector v^* where each element is inverted without any check for division by zero. $ w_i = \frac{1.0}{x_i} $

Definition at line 438 of file chi_math_vectorNX.h.

◆ InverseOneIfSmaller()

template<int N, class NumberFormat >
VectorNX chi_math::VectorNX< N, NumberFormat >::InverseOneIfSmaller ( NumberFormat  tol) const
inline

Returns a vector v^* where each element is inverted provided that it is greater than the given tolerance, otherwise the offending entry is set to 1.0.

Definition at line 412 of file chi_math_vectorNX.h.

◆ InverseZeroIfInf()

template<int N, class NumberFormat >
VectorNX chi_math::VectorNX< N, NumberFormat >::InverseZeroIfInf ( ) const
inline

Returns a vector v^* where each element is inverted provided that the inversion is not infinite, otherwise it is zeroed.

Definition at line 423 of file chi_math_vectorNX.h.

◆ InverseZeroIfSmaller()

template<int N, class NumberFormat >
VectorNX chi_math::VectorNX< N, NumberFormat >::InverseZeroIfSmaller ( NumberFormat  tol) const
inline

Returns a vector v^* where each element is inverted provided that it is greater than the given tolerance, otherwise the offending entry is set to 0.0.

Definition at line 400 of file chi_math_vectorNX.h.

◆ Norm()

template<int N, class NumberFormat >
NumberFormat chi_math::VectorNX< N, NumberFormat >::Norm ( ) const
inline

Computes the L2-norm of the vector. Otherwise known as the length of a 3D vector.

Definition at line 356 of file chi_math_vectorNX.h.

◆ Normalize()

template<int N, class NumberFormat >
void chi_math::VectorNX< N, NumberFormat >::Normalize ( )
inline

Normalizes the vector in-place.

Definition at line 379 of file chi_math_vectorNX.h.

◆ Normalized()

template<int N, class NumberFormat >
VectorNX chi_math::VectorNX< N, NumberFormat >::Normalized ( ) const
inline

Returns a normalized version of the vector.

Definition at line 387 of file chi_math_vectorNX.h.

◆ NormSquare()

template<int N, class NumberFormat >
NumberFormat chi_math::VectorNX< N, NumberFormat >::NormSquare ( ) const
inline

Computes the square of the L2-norm of the vector. This eliminates the usage of the square root and is therefore less expensive that a proper L2-norm. Useful if only comparing distances.

Definition at line 369 of file chi_math_vectorNX.h.

◆ operator()()

template<int N, class NumberFormat >
NumberFormat & chi_math::VectorNX< N, NumberFormat >::operator() ( int  i)
inline

Returns a reference of the value at the given index.

Definition at line 261 of file chi_math_vectorNX.h.

◆ operator*() [1/2]

template<int N, class NumberFormat >
VectorNX chi_math::VectorNX< N, NumberFormat >::operator* ( const NumberFormat  value) const
inline

Vector component-wise multiplication by scalar. $ \vec{w} = \vec{x} \alpha $

Definition at line 170 of file chi_math_vectorNX.h.

◆ operator*() [2/2]

template<int N, class NumberFormat >
VectorNX chi_math::VectorNX< N, NumberFormat >::operator* ( const VectorNX< N, NumberFormat > &  rhs) const
inline

Vector component-wise multiplication. $ w_i = x_i y_i $

Definition at line 191 of file chi_math_vectorNX.h.

◆ operator*=() [1/2]

template<int N, class NumberFormat >
VectorNX & chi_math::VectorNX< N, NumberFormat >::operator*= ( const NumberFormat  value)
inline

Vector in-place component-wise multiplication by scalar. $ \vec{x} = \vec{x} \alpha $

Definition at line 181 of file chi_math_vectorNX.h.

◆ operator*=() [2/2]

template<int N, class NumberFormat >
VectorNX & chi_math::VectorNX< N, NumberFormat >::operator*= ( const VectorNX< N, NumberFormat > &  rhs)
inline

Vector in-place component-wise multiplication. $ x_i = x_i y_i $

Definition at line 202 of file chi_math_vectorNX.h.

◆ operator+()

template<int N, class NumberFormat >
VectorNX chi_math::VectorNX< N, NumberFormat >::operator+ ( const VectorNX< N, NumberFormat > &  rhs) const
inline

Component-wise addition of two vectors. $ \vec{w} = \vec{x} + \vec{y} $

Definition at line 105 of file chi_math_vectorNX.h.

◆ operator+=()

template<int N, class NumberFormat >
VectorNX & chi_math::VectorNX< N, NumberFormat >::operator+= ( const VectorNX< N, NumberFormat > &  rhs)
inline

In-place component-wise addition of two vectors. $ \vec{x} = \vec{x} + \vec{y} $

Definition at line 116 of file chi_math_vectorNX.h.

◆ operator-()

template<int N, class NumberFormat >
VectorNX chi_math::VectorNX< N, NumberFormat >::operator- ( const VectorNX< N, NumberFormat > &  rhs) const
inline

Component-wise subtraction. $ \vec{w} = \vec{x} - \vec{y} $

Definition at line 148 of file chi_math_vectorNX.h.

◆ operator-=()

template<int N, class NumberFormat >
VectorNX & chi_math::VectorNX< N, NumberFormat >::operator-= ( const VectorNX< N, NumberFormat > &  rhs)
inline

In-place component-wise subtraction. $ \vec{x} = \vec{x} - \vec{y} $

Definition at line 159 of file chi_math_vectorNX.h.

◆ operator/() [1/2]

template<int N, class NumberFormat >
VectorNX chi_math::VectorNX< N, NumberFormat >::operator/ ( const NumberFormat  value) const
inline

Vector component-wise division by scalar. $ w_i = \frac{x_i}{\alpha} $

Definition at line 213 of file chi_math_vectorNX.h.

◆ operator/() [2/2]

template<int N, class NumberFormat >
VectorNX chi_math::VectorNX< N, NumberFormat >::operator/ ( const VectorNX< N, NumberFormat > &  rhs) const
inline

Vector component-wise division. $ w_i = \frac{x_i}{y_i} $

Definition at line 234 of file chi_math_vectorNX.h.

◆ operator/=() [1/2]

template<int N, class NumberFormat >
VectorNX & chi_math::VectorNX< N, NumberFormat >::operator/= ( const NumberFormat  value)
inline

Vector in-place component-wise division by scalar. $ x_i = \frac{x_i}{\alpha} $

Definition at line 224 of file chi_math_vectorNX.h.

◆ operator/=() [2/2]

template<int N, class NumberFormat >
VectorNX & chi_math::VectorNX< N, NumberFormat >::operator/= ( const VectorNX< N, NumberFormat > &  rhs)
inline

Vector in-place component-wise division. $ x_i = \frac{x_i}{y_i} $

Definition at line 245 of file chi_math_vectorNX.h.

◆ operator=() [1/2]

template<int N, class NumberFormat >
VectorNX & chi_math::VectorNX< N, NumberFormat >::operator= ( const chi_mesh::Vector3 rhs)
inline

Component-wise from chi_mesh::Vector3.

Definition at line 94 of file chi_math_vectorNX.h.

◆ operator=() [2/2]

template<int N, class NumberFormat >
VectorNX & chi_math::VectorNX< N, NumberFormat >::operator= ( const VectorNX< N, NumberFormat > &  rhs)
inline

Component-wise copy.

Definition at line 86 of file chi_math_vectorNX.h.

◆ operator[]()

template<int N, class NumberFormat >
NumberFormat chi_math::VectorNX< N, NumberFormat >::operator[] ( int  i) const
inline

Returns a copy of the value at the given index.

Definition at line 255 of file chi_math_vectorNX.h.

◆ OTimes()

template<int N, class NumberFormat >
TensorRNX< 2, N, NumberFormat > chi_math::VectorNX< N, NumberFormat >::OTimes ( const VectorNX< N, NumberFormat > &  that) const
inline

Definition at line 267 of file chi_math_vectorNX.h.

◆ Print()

template<int N, class NumberFormat >
void chi_math::VectorNX< N, NumberFormat >::Print ( ) const
inline

prints the vector to standard cout

Definition at line 448 of file chi_math_vectorNX.h.

◆ PrintS()

template<int N, class NumberFormat >
std::string chi_math::VectorNX< N, NumberFormat >::PrintS ( ) const
inline

Prints the vector to a string and then returns the string.

Definition at line 459 of file chi_math_vectorNX.h.

◆ Shift()

template<int N, class NumberFormat >
VectorNX & chi_math::VectorNX< N, NumberFormat >::Shift ( const NumberFormat  value)
inline

In-place component-wise shift by scalar-value. $ \vec{x} = \vec{x} + \alpha $

Definition at line 137 of file chi_math_vectorNX.h.

◆ Shifted()

template<int N, class NumberFormat >
VectorNX chi_math::VectorNX< N, NumberFormat >::Shifted ( const NumberFormat  value) const
inline

Component-wise shift by scalar-value. $ \vec{w} = \vec{x} + \alpha $

Definition at line 126 of file chi_math_vectorNX.h.

Field Documentation

◆ dimension

template<int N, class NumberFormat >
const unsigned int chi_math::VectorNX< N, NumberFormat >::dimension

Definition at line 36 of file chi_math_vectorNX.h.

◆ elements

template<int N, class NumberFormat >
std::array<NumberFormat,N> chi_math::VectorNX< N, NumberFormat >::elements

Definition at line 35 of file chi_math_vectorNX.h.


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