36 #ifndef _VECTORSMALL_H_ 37 #define _VECTORSMALL_H_ 1
39 #include <lifev/core/LifeV.hpp> 40 #include <lifev/core/array/RNM.hpp> 82 for (
UInt i = 0; i < Dim; i++ )
91 for (
UInt i = 0; i < Dim; i++ )
100 for (
UInt i = 0; i < Dim; i++ )
102 M_coords[ i ] = vector.M_coords[ i ];
122 for (
UInt i = 0; i < Dim; i++ )
143 for (
UInt i = 0; i < Dim; i++ )
145 M_coords[ i ] += vector.M_coords[ i ];
154 return tmp += vector;
160 for (
UInt i = 0; i < Dim; i++ )
162 M_coords[ i ] -= vector.M_coords[ i ];
171 return tmp -= vector;
177 for (
UInt i = 0; i < Dim; i++ )
187 ASSERT ( factor != 0. ,
"Division by zero!" );
188 *
this *= 1. / factor;
196 return tmp /= factor;
202 ASSERT ( i < Dim,
"trying to access an index that exceeds the dimension of the array" );
209 ASSERT ( i < Dim,
"trying to set an index that exceeds the dimension of the array" );
216 ASSERT ( i < Dim,
"trying to access an index that exceeds the dimension of the array" );
223 ASSERT ( i < Dim,
"trying to set an index that exceeds the dimension of the array" );
239 Real scalarProduct = 0.;
240 for (
UInt i = 0; i < Dim; i++ )
242 scalarProduct +=
M_coords[ i ] * vector.M_coords[ i ];
244 return scalarProduct;
249 MatrixSmall<Dim, Dim> result;
251 for (
UInt i = 0; i < Dim; i++ )
252 for (
UInt j = 0; j < Dim; j++ )
254 result[i][j] =
M_coords[ i ] * vector.M_coords[ j ];
265 return std::sqrt (
this->dot ( *
this ) );
318 return tmp *= factor;
326 return tmp *= factor;
331 inline std::ostream& operator<< ( std::ostream& out ,
VectorSmall<Dim>
const& point )
334 for (
UInt i = 0; i < Dim; i++ )
336 out << point[ i ] <<
" ";
352 template <
UInt Dim,
typename Vector>
355 ASSERT ( coords.size() == Dim ,
"the input vector has the wrong dimension" );
357 for (
UInt i = 0; i < Dim; i++ )
359 tmp[ i ] = coords[ i ];
442 return tmp
+= vector;
458 return tmp
-= vector;
474 return tmp
*= factor;
480 ASSERT ( factor != 0. ,
"Division by zero!" );
481 *
this *= 1. / factor;
489 return tmp
/= factor;
495 ASSERT ( i < 3 ,
"trying to access an index different from 0,1,2" );
502 ASSERT ( i < 3 ,
"trying to set an index different from 0,1,2" );
509 ASSERT ( i < 3 ,
"trying to access an index different from 0,1,2" );
516 ASSERT ( i < 3 ,
"trying to set an index different from 0,1,2" );
575 return std::sqrt (
this->dot ( *
this ) );
641 template <
typename Vector>
644 ASSERT ( coords.size() == 3 ,
"the input vector has the wrong dimension" );
645 return VectorSmall<3> ( coords[ 0 ], coords[ 1 ], coords[ 2 ] );
VectorSmall< 3 > cross(VectorSmall< 3 > const &vector) const
Cross product.
static VectorSmall< Dim > Zero()
Zero initialization.
VectorSmall(const Real value)
Non Empty constructor.
VectorSmall< 3 > operator-(VectorSmall< 3 > const &vector) const
Operator -.
VectorSmall< 3 > castToVector3D(Vector const &coords)
Conversion of an array (std::vector, KNM, ecc.) to a VectorSmall.
Real const & operator[](UInt const &i) const
Operator [].
VectorSmall< Dim > operator+(VectorSmall< Dim > const &vector) const
Operator +.
Real & operator()(UInt const &i)
Operator ()
VectorSmall< Dim > operator-(VectorSmall< Dim > const &vector) const
Operator -.
Real dot(VectorSmall< 3 > const &vector) const
Scalar product.
VectorSmall< Dim > normalized()
Create the versor associated to this VectorSmall.
void normalize()
Normalize vector.
Real const & operator[](UInt const &i) const
Operator [].
VectorSmall< Dim > operator/(Real const &factor) const
Operator / (division by scalar)
VectorSmall< 3 > operator+(VectorSmall< 3 > const &vector) const
Operator +.
MatrixSmall< 3, 3 > outerProduct(VectorSmall< 3 > const &vector) const
Outer product.
VectorSmall(VectorSmall< Dim > const &vector)
Copy constructor.
VectorSmall()
Empty constructor (all components are set to zero)
VectorSmall< 3 > & operator=(VectorSmall< 3 > const &vector)
Assignment operator.
void updateInverseJacobian(const UInt &iQuadPt)
UInt size() const
function to get the size of the VectorSmall ( for compatibility with Eigen)
void normalize()
Normalize vector.
VectorSmall< Dim > & operator*=(Real const &factor)
Operator *= (multiplication by scalar)
VectorSmall< Dim > operator*(VectorSmall< Dim > const &vector, Real const &factor)
Operator * (multiplication by scalar on the right)
VectorSmall< 3 > & operator-=(VectorSmall< 3 > const &vector)
Operator -=.
VectorSmall< 3 > operator*(Real const &factor) const
Operator * (multiplication by scalar on the right)
VectorSmall< 3 > & operator*=(Real const &factor)
Operator *= (multiplication by scalar)
VectorSmall(VectorSmall< 3 > const &vector)
Copy constructor.
Real & operator[](UInt const &i)
Operator [].
Real dot(VectorSmall< Dim > const &vector) const
Scalar product.
static UInt size()
function to get the size of the VectorSmall ( for compatibility with Eigen)
VectorSmall< Dim > & operator=(VectorSmall< Dim > const &vector)
Assignment operator.
Real M_coords[3]
Data storage.
Real const & operator()(UInt const &i) const
Operator ()
VectorSmall< 3 > & operator+=(VectorSmall< 3 > const &vector)
Operator +=.
Real M_coords[Dim]
Data storage.
VectorSmall< 3 > & operator/=(Real const &factor)
Operator /= (division by scalar)
double Real
Generic real data.
MatrixSmall< Dim, Dim > outerProduct(VectorSmall< Dim > const &vector) const
VectorSmall< 3 > normalized()
Create the versor associated to this VectorSmall.
VectorSmall< Dim > & operator+=(VectorSmall< Dim > const &vector)
Operator +=.
VectorSmall< 3 > operator/(Real const &factor) const
Operator / (division by scalar)
VectorSmall()
Empty constructor (all components are set to zero)
VectorSmall< 3 > operator*(Real const &factor, VectorSmall< 3 > const &vector)
Operator * (multiplication by scalar on the left)
Real & operator[](UInt const &i)
Operator [].
VectorSmall< 3 > Vector3D
VectorSmall(Real *rawVector)
VectorSmall< Dim > & operator-=(VectorSmall< Dim > const &vector)
Operator -=.
Real extract(UInt const &i) const
Extraction of a component.
static VectorSmall< Dim > Constant(Real const &value)
Constant initialization.
VectorSmall< Dim > castToVectorSmall(Vector const &coords)
Conversion of an array (std::vector, KN, ecc.) to a VectorSmall.
VectorSmall< Dim > & operator/=(Real const &factor)
Operator /= (division by scalar)
VectorSmall(Real const &x, Real const &y, Real const &z)
Full constructor with all components explicitly initialized.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
VectorSmall< Dim > operator*(Real const &factor, VectorSmall< Dim > const &vector)
Operator * (multiplication by scalar on the left)
Real & operator()(UInt const &i)
Operator ()
Real const & operator()(UInt const &i) const
Operator ()
VectorSmall(const Real value)
Non Empty constructor.