criptic v1
Cosmic Ray Interstellar Propagation Tool using Itô Calculus
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
criptic::RealTensor2 Class Reference

Class that represents a rank 2 tensor. More...

#include <RealTensor2.H>

Public Member Functions

 RealTensor2 ()
 Construct a RealTensor2 of all zeros.
 
 RealTensor2 (const Real &xx, const Real &xy, const Real &xz, const Real &yx, const Real &yy, const Real &yz, const Real &zx, const Real &zy, const Real &zz)
 Construct a RealTensor2 from nine scalars.
 
 RealTensor2 (const RealVec &a, const RealVec &b)
 Construct a RealTensor2 as the outer product of two RealVecs.
 
Realoperator() (int i, int j)
 Return an element of the tensor.
 
const Realoperator() (int i, int j) const
 Return a const ref to an element of the tensor.
 
Realoperator[] (int i)
 Return an element of the tensor.
 
const Realoperator[] (int i) const
 Return a const ref to an element of the tensor.
 
RealTensor2 operator- () const
 Return the negative of a RealTensor2.
 
RealTensor2operator+= (const Real a)
 Add a scalar to the RealTensor2 elementwise.
 
RealTensor2operator-= (const Real a)
 Subtract a scalar from the RealTensor2 elementwise.
 
RealTensor2operator*= (const Real a)
 Multiply a scalar by the RealTensor2 elementwise.
 
RealTensor2operator/= (const Real a)
 Divide the RealTensor2 by a scalar elementwise.
 
RealTensor2operator+= (const RealTensor2 &a)
 Add another RealTensor2 to the RealTensor2 elementwise.
 
RealTensor2operator-= (const RealTensor2 &a)
 Subtract another RealTensor2 from the RealTensor2 elementwise.
 
RealTensor2operator*= (const RealTensor2 &a)
 Multiply another RealTensor2 by the RealTensor2 elementwise.
 
RealTensor2operator/= (const RealTensor2 &a)
 Divide this RealTensor2 by another RealTensor2 elementwise.
 
RealTensor2operator= (const Real a)
 Assign a scalar value to every element of a RealTensor2.
 
RealTensor2 operator+ (const Real a) const
 Add a scalar and a RealTensor2 elementwise.
 
RealTensor2 operator- (const Real a) const
 Subtract a scalar from a RealTensor2 elementwise.
 
RealTensor2 operator* (const Real a) const
 Multiply a scalar by a RealTensor2 elementwise.
 
RealTensor2 operator/ (const Real a) const
 Divide a RealTensor2 by a scalar elementwise.
 
RealVec operator* (const RealVec &v) const
 Matrix-vector multiplication.
 
RealTensor2 operator+ (const RealTensor2 &a) const
 Add two RealTensor2s elementwise.
 
RealTensor2 operator- (const RealTensor2 &a) const
 Subtract two RealTensor2s elementwise.
 
RealTensor2 operator* (const RealTensor2 &a) const
 Multiply two RealTensor2s elementwise.
 
RealTensor2 operator/ (const RealTensor2 &a) const
 Divide two RealTensor2s elementwise.
 
RealVec contract1 (const RealVec &v) const
 Compute the tensor contraction v_i T_ij.
 
RealVec contract2 (const RealVec &v) const
 Compute the tensor contraction v_j T_ij.
 
Real contract (const RealVec &a, const RealVec &b) const
 Compute the tensor contraction a_i b_j T_ij.
 
Real contract (const RealTensor2 &a) const
 Compute the contraction of this tensor with another tensor.
 
Real divTangent (const RealVec &v) const
 Compute the divergence of the tangent vector.
 
Real trace () const
 Return the trace of this tensor.
 
RealTensor2 T () const
 Return the transpose of this tensor.
 
void transpose ()
 Transpose this tensor in place.
 
Real mag ()
 Total magnitude.
 
Real det () const
 Compute the determinant.
 
RealVec eVal () const
 Compute the eigenvalues of a symmetric tensor.
 
RealTensor2 eVec () const
 Compute the eigenvectors of a symmetric tensor.
 
void eigenDecompose (RealVec &eVal, RealTensor2 &eVec) const
 Compute the eigendecomposition of a symmetric tensor.
 
RealTensor2 inv () const
 Compute the inverse of a symmetric tensor.
 
RealTensor2 sqrt () const
 Compute the square root of a symmetric tensor.
 
RealTensor2 invSqrt () const
 Compute the inverse of the square root of a symmetric tensor.
 

Public Attributes

Real t [9]
 

Detailed Description

Class that represents a rank 2 tensor.

This class represents a rank 2 tensor in 3 dimensional space, and provides algebraic operations on this tensor. The tensor is indexed so that element ij is stored at memory position 3*i + j.

Constructor & Destructor Documentation

◆ RealTensor2() [1/3]

criptic::RealTensor2::RealTensor2 ( )
inline

Construct a RealTensor2 of all zeros.

◆ RealTensor2() [2/3]

criptic::RealTensor2::RealTensor2 ( const Real xx,
const Real xy,
const Real xz,
const Real yx,
const Real yy,
const Real yz,
const Real zx,
const Real zy,
const Real zz 
)
inline

Construct a RealTensor2 from nine scalars.

Parameters
xxxx element of tensor
xyxy element of tensor
xzxz element of tensor
yxyx element of tensor
yyyy element of tensor
yzyz element of tensor
zxzx element of tensor
zyzy element of tensor
zzzz element of tensor

◆ RealTensor2() [3/3]

criptic::RealTensor2::RealTensor2 ( const RealVec a,
const RealVec b 
)
inline

Construct a RealTensor2 as the outer product of two RealVecs.

Parameters
aThe first vector
bThe second vector

The constructed RealTensor2 will be indexed as T_ij = a_i * b_j

Member Function Documentation

◆ contract() [1/2]

Real criptic::RealTensor2::contract ( const RealTensor2 a) const
inline

Compute the contraction of this tensor with another tensor.

Parameters
aThe tensor with which to contract this tensor
Returns
The contraction T_ij a_ij

◆ contract() [2/2]

Real criptic::RealTensor2::contract ( const RealVec a,
const RealVec b 
) const
inline

Compute the tensor contraction a_i b_j T_ij.

Parameters
aFirst vector with which to contract
bSecond vector with which to contract
Returns
The contraction

◆ contract1()

RealVec criptic::RealTensor2::contract1 ( const RealVec v) const
inline

Compute the tensor contraction v_i T_ij.

Parameters
vThe vector with which to contract this tensor
Returns
A RealVec containing the tensor contraction v_i T_ij

◆ contract2()

RealVec criptic::RealTensor2::contract2 ( const RealVec v) const
inline

Compute the tensor contraction v_j T_ij.

Parameters
vThe vector with which to contract this tensor
Returns
A RealVec containing the tensor contraction v_j T_ij

◆ det()

Real criptic::RealTensor2::det ( ) const
inline

Compute the determinant.

Returns
The determinant of this tensor

◆ divTangent()

Real criptic::RealTensor2::divTangent ( const RealVec v) const
inline

Compute the divergence of the tangent vector.

Parameters
vThe vector field
Returns
Divergence of tangent vector

Assuming that this tensor represents the gradient of a vector field at some point, and that v is the corresponding value of the vector field itself, this routine computes the divergence of the tangent vector to the vector field.

◆ eigenDecompose()

void criptic::RealTensor2::eigenDecompose ( RealVec eVal,
RealTensor2 eVec 
) const
inline

Compute the eigendecomposition of a symmetric tensor.

Parameters
eValThe eigenvalues
eVecThe eigenvectors

The eigenvectors are returned in another tensor, which can be interpreted as the rotation matrix required to diagonalize the tensor. This method assumes that the tensor is symmetric; if it is not, the results are undefined.

◆ eVal()

RealVec criptic::RealTensor2::eVal ( ) const
inline

Compute the eigenvalues of a symmetric tensor.

Returns
The eigenvalues of the tensor

This method assumes that the tensor is symmetric; if it is not, the results are undefined.

◆ eVec()

RealTensor2 criptic::RealTensor2::eVec ( ) const
inline

Compute the eigenvectors of a symmetric tensor.

Returns
The eigenvectors of the tensor

This method assumes that the tensor is symmetric; if it is not, the results are undefined.

◆ inv()

RealTensor2 criptic::RealTensor2::inv ( ) const
inline

Compute the inverse of a symmetric tensor.

Returns
The inverse of the tensor

This method assumes that the tensor is symmetric; if it is not, the results are undefined.

◆ invSqrt()

RealTensor2 criptic::RealTensor2::invSqrt ( ) const
inline

Compute the inverse of the square root of a symmetric tensor.

Returns
The inverse square root of the tensor

This method assumes that the tensor is symmetric; if it is not, the results are undefined.

◆ mag()

Real criptic::RealTensor2::mag ( )
inline

Total magnitude.

Returns
Square root of the sum of the squares of all elements

◆ operator()() [1/2]

criptic::RealTensor2::operator() ( int  i,
int  j 
)
inline

Return an element of the tensor.

Parameters
iFirst tensor index
jSecond tensor index
Returns
Tensor element (i,j)

◆ operator()() [2/2]

criptic::RealTensor2::operator() ( int  i,
int  j 
) const
inline

Return a const ref to an element of the tensor.

Parameters
iFirst tensor index
jSecond tensor index
Returns
Tensor element (i,j)

◆ operator*() [1/3]

criptic::RealTensor2::operator* ( const Real  a) const
inline

Multiply a scalar by a RealTensor2 elementwise.

Parameters
aThe scalar
Returns
A RealTensor2 containing the elementwise product

◆ operator*() [2/3]

criptic::RealTensor2::operator* ( const RealTensor2 a) const
inline

Multiply two RealTensor2s elementwise.

Parameters
aThe RealTensor2 to multiply
Returns
A RealTensor2 containing the elementwise product

◆ operator*() [3/3]

criptic::RealTensor2::operator* ( const RealVec v) const
inline

Matrix-vector multiplication.

Parameters
vThe vector by which to multiply
Returns
The product T_ij v_j

◆ operator*=() [1/2]

criptic::RealTensor2::operator*= ( const Real  a)
inline

Multiply a scalar by the RealTensor2 elementwise.

Parameters
aThe scalar
Returns
A reference to the modified RealTensor2

◆ operator*=() [2/2]

criptic::RealTensor2::operator*= ( const RealTensor2 a)
inline

Multiply another RealTensor2 by the RealTensor2 elementwise.

Parameters
aThe RealTensor2 to multiply
Returns
A reference to the modified RealTensor2

◆ operator+() [1/2]

criptic::RealTensor2::operator+ ( const Real  a) const
inline

Add a scalar and a RealTensor2 elementwise.

Parameters
aThe scalar
Returns
A RealTensor2 containing the elementwise sum

◆ operator+() [2/2]

criptic::RealTensor2::operator+ ( const RealTensor2 a) const
inline

Add two RealTensor2s elementwise.

Parameters
aThe RealTensor2 to add
Returns
A RealTensor2 containing the elementwise sum

◆ operator+=() [1/2]

criptic::RealTensor2::operator+= ( const Real  a)
inline

Add a scalar to the RealTensor2 elementwise.

Parameters
aThe scalar
Returns
A reference to the modified RealTensor2

◆ operator+=() [2/2]

criptic::RealTensor2::operator+= ( const RealTensor2 a)
inline

Add another RealTensor2 to the RealTensor2 elementwise.

Parameters
aThe RealTensor2 to add
Returns
A reference to the modified RealTensor2

◆ operator-() [1/3]

criptic::RealTensor2::operator- ( ) const
inline

Return the negative of a RealTensor2.

Returns
A copy of the RealTensor2 with every element multiplied by -1

◆ operator-() [2/3]

criptic::RealTensor2::operator- ( const Real  a) const
inline

Subtract a scalar from a RealTensor2 elementwise.

Parameters
aThe scalar
Returns
A RealTensor2 containing the elementwise difference

◆ operator-() [3/3]

criptic::RealTensor2::operator- ( const RealTensor2 a) const
inline

Subtract two RealTensor2s elementwise.

Parameters
aThe RealTensor2 to subtract
Returns
A RealTensor2 containing the elementwise difference

◆ operator-=() [1/2]

criptic::RealTensor2::operator-= ( const Real  a)
inline

Subtract a scalar from the RealTensor2 elementwise.

Parameters
aThe scalar
Returns
A reference to the modified RealTensor2

◆ operator-=() [2/2]

criptic::RealTensor2::operator-= ( const RealTensor2 a)
inline

Subtract another RealTensor2 from the RealTensor2 elementwise.

Parameters
aThe RealTensor2 to subtract
Returns
A reference to the modified RealTensor2

◆ operator/() [1/2]

criptic::RealTensor2::operator/ ( const Real  a) const
inline

Divide a RealTensor2 by a scalar elementwise.

Parameters
aThe scalar
Returns
A RealTensor2 containing the elementwise dividend

◆ operator/() [2/2]

criptic::RealTensor2::operator/ ( const RealTensor2 a) const
inline

Divide two RealTensor2s elementwise.

Parameters
aThe RealTensor2 to divide by
Returns
A RealTensor2 containing the elementwise dividend

◆ operator/=() [1/2]

criptic::RealTensor2::operator/= ( const Real  a)
inline

Divide the RealTensor2 by a scalar elementwise.

Parameters
aThe scalar
Returns
A reference to the modified RealTensor2

◆ operator/=() [2/2]

criptic::RealTensor2::operator/= ( const RealTensor2 a)
inline

Divide this RealTensor2 by another RealTensor2 elementwise.

Parameters
aThe RealTensor2 to divide by
Returns
A reference to the modified RealTensor2

◆ operator=()

criptic::RealTensor2::operator= ( const Real  a)
inline

Assign a scalar value to every element of a RealTensor2.

Parameters
aThe scalar
Returns
The RealTensor2 with every element set equal to a

◆ operator[]() [1/2]

criptic::RealTensor2::operator[] ( int  i)
inline

Return an element of the tensor.

Parameters
i1D index of the tensor
Returns
Tensor element (i/3, i mod 3)

◆ operator[]() [2/2]

criptic::RealTensor2::operator[] ( int  i) const
inline

Return a const ref to an element of the tensor.

Parameters
i1D index of the tensor
Returns
Tensor element (i/3, i mod 3)

◆ sqrt()

RealTensor2 criptic::RealTensor2::sqrt ( ) const
inline

Compute the square root of a symmetric tensor.

Returns
The square root of the tensor

This method assumes that the tensor is symmetric; if it is not, the results are undefined.

◆ T()

RealTensor2 criptic::RealTensor2::T ( ) const
inline

Return the transpose of this tensor.

Returns
The transpose of this tensor

◆ trace()

Real criptic::RealTensor2::trace ( ) const
inline

Return the trace of this tensor.

◆ transpose()

void criptic::RealTensor2::transpose ( )
inline

Transpose this tensor in place.

Member Data Documentation

◆ t

Real criptic::RealTensor2::t[9]

Data in RealTensor2


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