1#ifndef chi_math_VectorNX_h
2#define chi_math_VectorNX_h
6 struct TensorRank2Dim3;
12 template<
int R,
int N,
class NumberFormat>
32 template <
int N,
class NumberFormat>
41 static_assert(std::is_floating_point<NumberFormat>::value,
42 "Only floating point number formats are supported for VectorNX." );
50 static_assert(std::is_floating_point<NumberFormat>::value,
51 "Only floating point number formats are supported for VectorNX." );
59 static_assert(std::is_floating_point<NumberFormat>::value,
60 "Only floating point number formats are supported for VectorNX." );
64 for (
int i = 0; (i<N) and (i<3);++i)
77 static_assert(std::is_floating_point<NumberFormat>::value,
78 "Only floating point number formats are supported for VectorNX." );
81 for (
int i = 0; i<values.size() and i<
dimension; ++i)
96 for (
int i = 0; (i<N) and (i<3);++i)
108 for (
int i = 0; i<N;++i)
118 for (
int i = 0; i<N;++i)
129 for (
int i = 0; i<N;++i)
139 for (
int i = 0; i<N;++i)
151 for (
int i = 0; i<N;++i)
161 for (
int i = 0; i<N;++i)
173 for (
int i = 0;i<N;++i)
183 for (
int i = 0;i<N;++i)
194 for (
int i = 0; i<N ; ++i)
204 for (
int i = 0; i<N ; ++i)
216 for (
int i = 0;i<N;++i)
226 for (
int i = 0;i<N;++i)
237 for (
int i = 0; i<N ; ++i)
247 for (
int i = 0; i<N ; ++i)
270 for (
int i=0; i<N; ++i)
271 for (
int j=0; j<N; ++j)
281 for (
int i=0; i<N; ++i)
292 static_assert(N == 2 or N ==3,
293 "chi_math::VectorNX::Cross only defined for dimension 2 or 3 vectors.");
312 static_assert(N == 2 or N ==3,
313 "chi_math::VectorNX::Cross only defined for dimension 2 or 3 vectors.");
336 NumberFormat value = 0.0;
337 for (
int i = 0; i<N; ++i)
347 NumberFormat value = 0.0;
348 for (
int i = 0; (i<N) and (i<3); ++i)
358 NumberFormat value = 0.0;
359 for (
int i = 0; i<N;++i)
371 NumberFormat value = 0.0;
372 for (
int i = 0; i<N;++i)
381 NumberFormat norm = this->
Norm();
382 for (
int i = 0;i<N;++i)
389 NumberFormat norm = this->
Norm();
391 for (
int i = 0;i<N;++i)
403 for (
int i = 0; i<N;++i)
415 for (
int i = 0; i<N;++i)
426 for (
int i = 0; i<N; ++i)
428 NumberFormat dn_inv = 1.0/
elements[i];
429 newVector.
elements[i] = (std::isinf(dn_inv))? dn_inv : 0.0;
441 for (
int i = 0; i<N; ++i)
450 for (
int i = 0; i<N-1; i++)
461 std::stringstream out;
463 for (
int i = 0; i<N-1 ; ++i)
479template<
int N,
class NumberFormat>
484 for (
int i = 0; i<N;++i)
chi_math::VectorNX< N, NumberFormat > operator*(const double value, const chi_math::VectorNX< N, NumberFormat > &that)
VectorNX< 3, NumberFormat > Cross(const VectorNX< 3, NumberFormat > &rhs)
VectorNX & operator/=(const NumberFormat value)
VectorNX< N, NumberFormat > Dot(const TensorRNX< 2, N, NumberFormat > &that) const
VectorNX & operator=(const VectorNX &rhs)
VectorNX & operator=(const chi_mesh::Vector3 &rhs)
NumberFormat operator[](int i) const
std::string PrintS() const
NumberFormat & operator()(int i)
VectorNX< 3, NumberFormat > Cross(const VectorNX< 2, NumberFormat > &rhs)
VectorNX Shifted(const NumberFormat value) const
VectorNX operator*(const NumberFormat value) const
VectorNX & operator/=(const VectorNX &rhs)
VectorNX Normalized() const
VectorNX & operator*=(const VectorNX &rhs)
VectorNX(const chi_mesh::Vector3 &that)
VectorNX & Shift(const NumberFormat value)
VectorNX InverseZeroIfSmaller(NumberFormat tol) const
VectorNX & operator*=(const NumberFormat value)
NumberFormat Dot(const VectorNX &rhs) const
TensorRNX< 2, N, NumberFormat > OTimes(const VectorNX< N, NumberFormat > &that) const
std::array< NumberFormat, N > elements
VectorNX operator+(const VectorNX &rhs) const
VectorNX InverseZeroIfInf() const
VectorNX operator/(const NumberFormat value) const
VectorNX operator-(const VectorNX &rhs) const
VectorNX InverseOneIfSmaller(NumberFormat tol) const
VectorNX operator*(const VectorNX &rhs) const
VectorNX operator/(const VectorNX &rhs) const
const unsigned int dimension
NumberFormat Norm() const
VectorNX(const NumberFormat value)
NumberFormat Dot(const chi_mesh::Vector3 &rhs) const
NumberFormat NormSquare() const
VectorNX & operator+=(const VectorNX &rhs)
VectorNX & operator-=(const VectorNX &rhs)
VectorNX(const std::vector< NumberFormat > &values)