SPH
Public Member Functions | Static Public Member Functions | Friends | List of all members
SymmetricTensor Class Reference

Symmetric tensor of 2nd order. More...

#include <SymmetricTensor.h>

Public Member Functions

 SymmetricTensor ()=default
 
INLINE SymmetricTensor (const SymmetricTensor &other)
 
INLINE SymmetricTensor (const Vector &diag, const Vector &off)
 Construct tensor given its diagonal vector and a vector of off-diagonal elements (sorted top-bottom and left-right). More...
 
INLINE SymmetricTensor (const Float value)
 Initialize all components of the tensor to given value. More...
 
INLINE SymmetricTensor (const Vector &v0, const Vector &v1, const Vector &v2)
 Construct tensor given three vectors as rows. More...
 
INLINE SymmetricTensoroperator= (const SymmetricTensor &other)
 
INLINE Vector row (const Size idx) const
 Returns a row of the matrix. More...
 
INLINE Floatoperator() (const Size rowIdx, const Size colIdx)
 Returns a given element of the matrix. More...
 
INLINE Float operator() (const Size rowIdx, const Size colIdx) const
 Returns a given element of the matrix, const version. More...
 
INLINE const Vectordiagonal () const
 Returns the diagonal part of the tensor. More...
 
INLINE const VectoroffDiagonal () const
 Returns the off-diagonal elements of the tensor. More...
 
INLINE Vector operator* (const Vector &v) const
 Applies the tensor on given vector. More...
 
INLINE SymmetricTensoroperator+= (const SymmetricTensor &other)
 
INLINE SymmetricTensoroperator-= (const SymmetricTensor &other)
 
INLINE SymmetricTensoroperator*= (const Float value)
 
INLINE SymmetricTensoroperator/= (const Float value)
 
INLINE SymmetricTensor operator- () const
 
INLINE bool operator== (const SymmetricTensor &other) const
 
INLINE bool operator!= (const SymmetricTensor &other) const
 
INLINE Float determinant () const
 Returns the determinant of the tensor. More...
 
INLINE Float trace () const
 Return the trace of the tensor. More...
 
template<int n>
INLINE Float invariant () const
 Returns n-th invariant of the tensor (1<=n<=3) More...
 
INLINE SymmetricTensor inverse () const
 
SymmetricTensor pseudoInverse (const Float eps) const
 

Static Public Member Functions

static INLINE SymmetricTensor identity ()
 Returns an identity tensor. More...
 
static INLINE SymmetricTensor null ()
 Returns a tensor with all zeros. More...
 

Friends

INLINE friend SymmetricTensor operator* (const SymmetricTensor &t, const Float v)
 Multiplies a tensor by a scalar. More...
 
INLINE friend SymmetricTensor operator* (const Float v, const SymmetricTensor &t)
 
INLINE friend SymmetricTensor operator* (const SymmetricTensor &t1, const SymmetricTensor &t2)
 Multiplies a tensor by another tensor, element-wise. Not a matrix multiplication! More...
 
INLINE friend SymmetricTensor operator/ (const SymmetricTensor &t, const Float v)
 Divides a tensor by a scalar. More...
 
INLINE friend SymmetricTensor operator/ (const SymmetricTensor &t1, const SymmetricTensor &t2)
 Divides a tensor by another tensor, element-wise. More...
 
INLINE friend SymmetricTensor operator+ (const SymmetricTensor &t1, const SymmetricTensor &t2)
 Sums up two tensors. More...
 
INLINE friend SymmetricTensor operator- (const SymmetricTensor &t1, const SymmetricTensor &t2)
 
std::ostream & operator<< (std::ostream &stream, const SymmetricTensor &t)
 

Detailed Description

Symmetric tensor of 2nd order.

Internally, data are stored in two vectors, representing the diagonal and the off-diagonal components.

Definition at line 18 of file SymmetricTensor.h.

Constructor & Destructor Documentation

◆ SymmetricTensor() [1/5]

SymmetricTensor::SymmetricTensor ( )
default

◆ SymmetricTensor() [2/5]

INLINE SymmetricTensor::SymmetricTensor ( const SymmetricTensor other)
inline

Definition at line 26 of file SymmetricTensor.h.

◆ SymmetricTensor() [3/5]

INLINE SymmetricTensor::SymmetricTensor ( const Vector diag,
const Vector off 
)
inline

Construct tensor given its diagonal vector and a vector of off-diagonal elements (sorted top-bottom and left-right).

Definition at line 32 of file SymmetricTensor.h.

◆ SymmetricTensor() [4/5]

INLINE SymmetricTensor::SymmetricTensor ( const Float  value)
inlineexplicit

Initialize all components of the tensor to given value.

Definition at line 37 of file SymmetricTensor.h.

◆ SymmetricTensor() [5/5]

INLINE SymmetricTensor::SymmetricTensor ( const Vector v0,
const Vector v1,
const Vector v2 
)
inline

Construct tensor given three vectors as rows.

Matrix represented by the vectors MUST be symmetric, checked by assert.

Definition at line 44 of file SymmetricTensor.h.

Member Function Documentation

◆ determinant()

INLINE Float SymmetricTensor::determinant ( ) const
inline

Returns the determinant of the tensor.

Definition at line 193 of file SymmetricTensor.h.

◆ diagonal()

INLINE const Vector& SymmetricTensor::diagonal ( ) const
inline

Returns the diagonal part of the tensor.

Definition at line 92 of file SymmetricTensor.h.

◆ identity()

static INLINE SymmetricTensor SymmetricTensor::identity ( )
inlinestatic

Returns an identity tensor.

Definition at line 183 of file SymmetricTensor.h.

◆ invariant()

template<int n>
INLINE Float SymmetricTensor::invariant ( ) const
inline

Returns n-th invariant of the tensor (1<=n<=3)

Todo:
optimize with shuffle

Definition at line 205 of file SymmetricTensor.h.

◆ inverse()

INLINE SymmetricTensor SymmetricTensor::inverse ( ) const
inline
Todo:
optimize using SSE

Definition at line 219 of file SymmetricTensor.h.

◆ null()

static INLINE SymmetricTensor SymmetricTensor::null ( )
inlinestatic

Returns a tensor with all zeros.

Definition at line 188 of file SymmetricTensor.h.

◆ offDiagonal()

INLINE const Vector& SymmetricTensor::offDiagonal ( ) const
inline

Returns the off-diagonal elements of the tensor.

Definition at line 97 of file SymmetricTensor.h.

◆ operator!=()

INLINE bool SymmetricTensor::operator!= ( const SymmetricTensor other) const
inline

Definition at line 178 of file SymmetricTensor.h.

◆ operator()() [1/2]

INLINE Float& SymmetricTensor::operator() ( const Size  rowIdx,
const Size  colIdx 
)
inline

Returns a given element of the matrix.

Definition at line 74 of file SymmetricTensor.h.

◆ operator()() [2/2]

INLINE Float SymmetricTensor::operator() ( const Size  rowIdx,
const Size  colIdx 
) const
inline

Returns a given element of the matrix, const version.

Definition at line 83 of file SymmetricTensor.h.

◆ operator*()

INLINE Vector SymmetricTensor::operator* ( const Vector v) const
inline

Applies the tensor on given vector.

Todo:
optimize using _mm_shuffle_ps

Definition at line 102 of file SymmetricTensor.h.

◆ operator*=()

INLINE SymmetricTensor& SymmetricTensor::operator*= ( const Float  value)
inline

Definition at line 154 of file SymmetricTensor.h.

◆ operator+=()

INLINE SymmetricTensor& SymmetricTensor::operator+= ( const SymmetricTensor other)
inline

Definition at line 142 of file SymmetricTensor.h.

◆ operator-()

INLINE SymmetricTensor SymmetricTensor::operator- ( ) const
inline

Definition at line 166 of file SymmetricTensor.h.

◆ operator-=()

INLINE SymmetricTensor& SymmetricTensor::operator-= ( const SymmetricTensor other)
inline

Definition at line 148 of file SymmetricTensor.h.

◆ operator/=()

INLINE SymmetricTensor& SymmetricTensor::operator/= ( const Float  value)
inline

Definition at line 160 of file SymmetricTensor.h.

◆ operator=()

INLINE SymmetricTensor& SymmetricTensor::operator= ( const SymmetricTensor other)
inline

Definition at line 52 of file SymmetricTensor.h.

◆ operator==()

INLINE bool SymmetricTensor::operator== ( const SymmetricTensor other) const
inline

Definition at line 174 of file SymmetricTensor.h.

◆ pseudoInverse()

NAMESPACE_SPH_BEGIN SymmetricTensor SymmetricTensor::pseudoInverse ( const Float  eps) const

Definition at line 6 of file SymmetricTensor.cpp.

◆ row()

INLINE Vector SymmetricTensor::row ( const Size  idx) const
inline

Returns a row of the matrix.

Definition at line 59 of file SymmetricTensor.h.

◆ trace()

INLINE Float SymmetricTensor::trace ( ) const
inline

Return the trace of the tensor.

Definition at line 199 of file SymmetricTensor.h.

Friends And Related Function Documentation

◆ operator* [1/3]

INLINE friend SymmetricTensor operator* ( const Float  v,
const SymmetricTensor t 
)
friend

Definition at line 114 of file SymmetricTensor.h.

◆ operator* [2/3]

INLINE friend SymmetricTensor operator* ( const SymmetricTensor t,
const Float  v 
)
friend

Multiplies a tensor by a scalar.

Definition at line 110 of file SymmetricTensor.h.

◆ operator* [3/3]

INLINE friend SymmetricTensor operator* ( const SymmetricTensor t1,
const SymmetricTensor t2 
)
friend

Multiplies a tensor by another tensor, element-wise. Not a matrix multiplication!

Definition at line 119 of file SymmetricTensor.h.

◆ operator+

INLINE friend SymmetricTensor operator+ ( const SymmetricTensor t1,
const SymmetricTensor t2 
)
friend

Sums up two tensors.

Definition at line 134 of file SymmetricTensor.h.

◆ operator-

INLINE friend SymmetricTensor operator- ( const SymmetricTensor t1,
const SymmetricTensor t2 
)
friend

Definition at line 138 of file SymmetricTensor.h.

◆ operator/ [1/2]

INLINE friend SymmetricTensor operator/ ( const SymmetricTensor t,
const Float  v 
)
friend

Divides a tensor by a scalar.

Definition at line 124 of file SymmetricTensor.h.

◆ operator/ [2/2]

INLINE friend SymmetricTensor operator/ ( const SymmetricTensor t1,
const SymmetricTensor t2 
)
friend

Divides a tensor by another tensor, element-wise.

Definition at line 129 of file SymmetricTensor.h.

◆ operator<<

std::ostream& operator<< ( std::ostream &  stream,
const SymmetricTensor t 
)
friend

Definition at line 236 of file SymmetricTensor.h.


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