Chi-Tech
chi_mesh::Vector3 Struct Reference

#include <chi_meshvector.h>

Public Member Functions

 Vector3 ()
 
 Vector3 (double a)
 
 Vector3 (double a, double b)
 
 Vector3 (double a, double b, double c)
 
 Vector3 (std::initializer_list< double > list)
 
 Vector3 (const std::vector< double > &list)
 
 Vector3 (const Vector3 &that)
 
Vector3operator= (const Vector3 &that)
 
Vector3operator= (std::initializer_list< double > list)
 
Vector3operator= (const std::vector< double > &list)
 
Vector3 operator+ (const Vector3 &that) const
 
Vector3operator+= (const Vector3 &that)
 
Vector3 Shifted (const double value) const
 
Vector3Shift (const double value)
 
Vector3 operator- (const Vector3 &that) const
 
Vector3operator-= (const Vector3 &that)
 
Vector3 operator* (const double value) const
 
Vector3operator*= (const double value)
 
Vector3 operator* (const Vector3 &that) const
 
Vector3operator*= (const Vector3 &that)
 
Vector3 operator/ (const double value) const
 
Vector3operator/= (const double value)
 
Vector3 operator/ (const Vector3 &that) const
 
Vector3operator/= (const Vector3 &that)
 
double operator[] (const size_t i) const
 
double & operator() (const size_t i)
 
chi_mesh::TensorRank2Dim3 OTimes (const Vector3 &that) const
 
Vector3 Dot (const chi_mesh::TensorRank2Dim3 &that) const
 
Vector3 Cross (const Vector3 &that) const
 
double Dot (const Vector3 &that) const
 
double Norm () const
 
double NormSquare () const
 
void Normalize ()
 
Vector3 Normalized () const
 
Vector3 InverseZeroIfSmaller (const double tol) const
 
Vector3 InverseOneIfSmaller (const double tol) const
 
Vector3 Inverse () const
 
void Print () const
 
std::string PrintS () const
 
std::string PrintStr () const
 

Static Public Member Functions

static size_t Size ()
 

Data Fields

double x
 Element-0. More...
 
double y
 Element-1. More...
 
double z
 Element-2. More...
 

Friends

std::ostream & operator<< (std::ostream &out, Vector3 &v)
 

Detailed Description

General 3 element vector structure.

Author
Jan

Definition at line 18 of file chi_meshvector.h.

Constructor & Destructor Documentation

◆ Vector3() [1/7]

chi_mesh::Vector3::Vector3 ( )
inline

Default constructor. Initialized as all zeros.

Definition at line 25 of file chi_meshvector.h.

◆ Vector3() [2/7]

chi_mesh::Vector3::Vector3 ( double  a)
inlineexplicit

Constructor where single element is initialized $ x[z]=a $.

Definition at line 30 of file chi_meshvector.h.

◆ Vector3() [3/7]

chi_mesh::Vector3::Vector3 ( double  a,
double  b 
)
inlineexplicit

Constructor where $ x=a$ and $ y=b $.

Definition at line 35 of file chi_meshvector.h.

◆ Vector3() [4/7]

chi_mesh::Vector3::Vector3 ( double  a,
double  b,
double  c 
)
inlineexplicit

Constructor where $ \vec{x}=[a,b,c] $.

Definition at line 40 of file chi_meshvector.h.

◆ Vector3() [5/7]

chi_mesh::Vector3::Vector3 ( std::initializer_list< double >  list)
inline

Constructor where $ \vec{x}=\{a,b,c\} $.

Definition at line 45 of file chi_meshvector.h.

◆ Vector3() [6/7]

chi_mesh::Vector3::Vector3 ( const std::vector< double > &  list)
inlineexplicit

Constructor where $ \vec{x}=\{a,b,c\} $.

Definition at line 60 of file chi_meshvector.h.

◆ Vector3() [7/7]

chi_mesh::Vector3::Vector3 ( const Vector3 that)
inline

Copy constructor.

Definition at line 75 of file chi_meshvector.h.

Member Function Documentation

◆ Cross()

Vector3 chi_mesh::Vector3::Cross ( const Vector3 that) const
inline

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

Definition at line 317 of file chi_meshvector.h.

◆ Dot() [1/2]

chi_mesh::Vector3 chi_mesh::Vector3::Dot ( const chi_mesh::TensorRank2Dim3 that) const

Dot product of vector and a rank-2 tensor. $ \vec{w} = \vec{x} \bullet \vec{\vec{T}} $

Definition at line 19 of file chi_mesh_utilities.cc.

◆ Dot() [2/2]

double chi_mesh::Vector3::Dot ( const Vector3 that) const
inline

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

Definition at line 329 of file chi_meshvector.h.

◆ Inverse()

Vector3 chi_mesh::Vector3::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 422 of file chi_meshvector.h.

◆ InverseOneIfSmaller()

Vector3 chi_mesh::Vector3::InverseOneIfSmaller ( const double  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. $ w_i = \frac{1.0}{x_i} $

Definition at line 409 of file chi_meshvector.h.

◆ InverseZeroIfSmaller()

Vector3 chi_mesh::Vector3::InverseZeroIfSmaller ( const double  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. $ w_i = \frac{1.0}{x_i} $

Definition at line 395 of file chi_meshvector.h.

◆ Norm()

double chi_mesh::Vector3::Norm ( ) const
inline

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

Definition at line 341 of file chi_meshvector.h.

◆ Normalize()

void chi_mesh::Vector3::Normalize ( )
inline

Normalizes the vector in-place. $ \vec{x} = \frac{\vec{x}}{||x||_2} $

Definition at line 368 of file chi_meshvector.h.

◆ Normalized()

Vector3 chi_mesh::Vector3::Normalized ( ) const
inline

Returns a normalized version of the vector. $ \vec{w} = \frac{\vec{x}}{||x||_2} $

Definition at line 379 of file chi_meshvector.h.

◆ NormSquare()

double chi_mesh::Vector3::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 356 of file chi_meshvector.h.

◆ operator()()

double & chi_mesh::Vector3::operator() ( const size_t  i)
inline

Returns a reference of the value at the given index.

Definition at line 297 of file chi_meshvector.h.

◆ operator*() [1/2]

Vector3 chi_mesh::Vector3::operator* ( const double  value) const
inline

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

Definition at line 194 of file chi_meshvector.h.

◆ operator*() [2/2]

Vector3 chi_mesh::Vector3::operator* ( const Vector3 that) const
inline

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

Definition at line 217 of file chi_meshvector.h.

◆ operator*=() [1/2]

Vector3 & chi_mesh::Vector3::operator*= ( const double  value)
inline

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

Definition at line 206 of file chi_meshvector.h.

◆ operator*=() [2/2]

Vector3 & chi_mesh::Vector3::operator*= ( const Vector3 that)
inline

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

Definition at line 229 of file chi_meshvector.h.

◆ operator+()

Vector3 chi_mesh::Vector3::operator+ ( const Vector3 that) const
inline

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

Definition at line 123 of file chi_meshvector.h.

◆ operator+=()

Vector3 & chi_mesh::Vector3::operator+= ( const Vector3 that)
inline

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

Definition at line 135 of file chi_meshvector.h.

◆ operator-()

Vector3 chi_mesh::Vector3::operator- ( const Vector3 that) const
inline

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

Definition at line 170 of file chi_meshvector.h.

◆ operator-=()

Vector3 & chi_mesh::Vector3::operator-= ( const Vector3 that)
inline

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

Definition at line 182 of file chi_meshvector.h.

◆ operator/() [1/2]

Vector3 chi_mesh::Vector3::operator/ ( const double  value) const
inline

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

Definition at line 241 of file chi_meshvector.h.

◆ operator/() [2/2]

Vector3 chi_mesh::Vector3::operator/ ( const Vector3 that) const
inline

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

Definition at line 264 of file chi_meshvector.h.

◆ operator/=() [1/2]

Vector3 & chi_mesh::Vector3::operator/= ( const double  value)
inline

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

Definition at line 253 of file chi_meshvector.h.

◆ operator/=() [2/2]

Vector3 & chi_mesh::Vector3::operator/= ( const Vector3 that)
inline

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

Definition at line 276 of file chi_meshvector.h.

◆ operator=() [1/3]

Vector3 & chi_mesh::Vector3::operator= ( const std::vector< double > &  list)
inline

Definition at line 106 of file chi_meshvector.h.

◆ operator=() [2/3]

Vector3 & chi_mesh::Vector3::operator= ( const Vector3 that)
inline

Assignment operator.

Definition at line 83 of file chi_meshvector.h.

◆ operator=() [3/3]

Vector3 & chi_mesh::Vector3::operator= ( std::initializer_list< double >  list)
inline

Definition at line 92 of file chi_meshvector.h.

◆ operator[]()

double chi_mesh::Vector3::operator[] ( const size_t  i) const
inline

Returns a copy of the value at the given index.

Definition at line 287 of file chi_meshvector.h.

◆ OTimes()

chi_mesh::TensorRank2Dim3 chi_mesh::Vector3::OTimes ( const Vector3 that) const

Tensor product of two vectors. $ \vec{\vec{T}} = \vec{x} \otimes \vec{y} $

Definition at line 6 of file chi_mesh_utilities.cc.

◆ Print()

void chi_mesh::Vector3::Print ( ) const
inline

Prints the vector to std::cout.

Definition at line 433 of file chi_meshvector.h.

◆ PrintS()

std::string chi_mesh::Vector3::PrintS ( ) const
inline

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

Definition at line 448 of file chi_meshvector.h.

◆ PrintStr()

std::string chi_mesh::Vector3::PrintStr ( ) const
inline

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

Definition at line 457 of file chi_meshvector.h.

◆ Shift()

Vector3 & chi_mesh::Vector3::Shift ( const double  value)
inline

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

Definition at line 158 of file chi_meshvector.h.

◆ Shifted()

Vector3 chi_mesh::Vector3::Shifted ( const double  value) const
inline

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

Definition at line 146 of file chi_meshvector.h.

◆ Size()

static size_t chi_mesh::Vector3::Size ( )
inlinestatic

Definition at line 465 of file chi_meshvector.h.

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
Vector3 v 
)
friend

Definition at line 440 of file chi_meshvector.h.

Field Documentation

◆ x

double chi_mesh::Vector3::x

Element-0.

Definition at line 20 of file chi_meshvector.h.

◆ y

double chi_mesh::Vector3::y

Element-1.

Definition at line 21 of file chi_meshvector.h.

◆ z

double chi_mesh::Vector3::z

Element-2.

Definition at line 22 of file chi_meshvector.h.


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