VTK
Public Member Functions | Static Public Member Functions | List of all members
vtkMomentsTensor Class Reference

helper class that stores a tensor of arbitrary rank and dimension More...

#include <vtkMomentsTensor.h>

Public Member Functions

 vtkMomentsTensor ()
 empty constructor More...
 
 vtkMomentsTensor (size_t dimension, size_t rank, size_t fieldRank)
 constructor allocating the data vector More...
 
 vtkMomentsTensor (vtkMomentsTensor *tensor)
 copy constructor More...
 
 vtkMomentsTensor (size_t dimension, size_t rank, size_t fieldRank, size_t momentRank)
 constructor allocating the data vector More...
 
 vtkMomentsTensor (Eigen::MatrixXd data)
 copy constructor from eigen matrix More...
 
size_t getIndex (const std::vector< size_t > &indices)
 inverse function to getIndices More...
 
size_t getRank ()
 get rank of the tensor, i.e. More...
 
size_t getFieldRank ()
 get field rank, 0 for scalars, 1 for vectors, 3 for matrices More...
 
size_t getMomentRank ()
 get moment rank, order of the moment tensor More...
 
size_t getDimension ()
 get dimension, e.g. More...
 
std::vector< doublegetData ()
 get data vector More...
 
std::vector< size_t > getContractionInfo ()
 get the vector with the indices that indicate which tensor this one was produced from through contraction More...
 
std::vector< size_t > getProductInfo ()
 get the vector with the indices that indicate which tensor this one was produced from through multiplication More...
 
size_t size ()
 get the number of entries of this tensor More...
 
std::vector< size_t > getIndices (size_t index)
 inverse function to getIndex More...
 
std::vector< size_t > getIndexSum (size_t index)
 this function adds the numbers of zeros, ones, and twos in the tensor index it is used to determine the tensor's properties under reflection iff the sum is odd, the sign of the entry changes More...
 
std::vector< size_t > getMomentIndices (size_t index)
 the moment tensors have two types of indices fieldIndices and momentIndices fieldIndices of length fieldRank refer to the components of the original data (3 for vector, 9 for matrix) momentIndices of length momentRank refer to the basis function More...
 
std::vector< size_t > getFieldIndices (size_t index)
 the moment tensors have two types of indices fieldIndices and momentIndices fieldIndices of length fieldRank refer to the components of the original data (3 for vector, 9 for matrix) momentIndices of length momentRank refer to the basis function More...
 
size_t getFieldIndex (size_t index)
 IMPORTANT this function forms the bridge to vtk it translates the order of the fieldIndices to vtk's order as used by vtkDoubleArray.SetTuple() there the values are stored as follows: 2D and 3D: scalar: 0, vector: 0,1,2 matrix: 00,10,20,01,11,21,02,12,22 2D has zeros in the indices containing a 2. More...
 
double get (const std::vector< size_t > &indices)
 Get data entry for given tensor indices. More...
 
double get (size_t index)
 Get data entry for given flat c++ vector index. More...
 
void set (const std::vector< size_t > &indices, double value)
 Set data entry for given tensor indices. More...
 
void set (size_t index, double value)
 Set data entry for given tensor indices. More...
 
void set (const std::vector< double > &data)
 Set the whole data vector. More...
 
vtkMomentsTensor contract ()
 This function produces a tensor contraction of the last two indices T'i = sum{j=k} T_ijk (i is multiindex) for arbitrary contractions, use the transpose function and move the indices there prior to calling this function. More...
 
vtkMomentsTensor contract (size_t i, size_t j)
 This function produces a tensor contraction of the indices i and k T'i = sum{j=k} T_ijk (i is multiindex) we use the transpose function and move the indices i and k to the end and then call the contract() function. More...
 
vtkMomentsTensor contract (std::vector< size_t > contractor)
 This function produces a tensor contraction of the indices stored in contractor. More...
 
void print ()
 This function prints the properties of this tensor. More...
 
std::vector< vtkMomentsTensorcontractAll ()
 This function produces a list of all possible 2-index combinations, which is used to generate all possible contractions. More...
 
double norm ()
 This function computes the Euclidean norm of the tensor. More...
 
std::vector< size_t > getOrders (size_t index)
 for vector and matrix fields, the last indizes don't belong to the moment-indices, but the fieldIndex the number of zeros in the moment-indices equals p in the basis function x^p*y^q*z^r the number of one in a tensor-multiindex equals q in the basis function x^p*y^q*z^r the number of twos in a tensor-multiindex equals r in the basis function x^p*y^q*z^r More...
 
vtkMomentsTensor rotate (Eigen::MatrixXd rotMat)
 rotate the tensor More...
 
Eigen::VectorXd getVector ()
 convenience function converting a rank 1 tensor into a vector More...
 
Eigen::MatrixXd getMatrix ()
 convenience function converting a rank 2 tensor into a matrix More...
 
std::vector< vtkMomentsTensoreigenVectors ()
 this function computes the eigenvectors of a rank 2 tensor they are not normalized, but weighted with how distinct their corresponding eigenvalues are e.g. More...
 
void otherEV ()
 if we have a rank 1 tensor that was made from an eigenvector, its sign is arbitrary that means for the standard position, we need to take it and its negative into account this function generates the negative its contractionInfo is encoded as the eigenvector index plus the dimension e.g. More...
 

Static Public Member Functions

static vtkMomentsTensor tensorProduct (vtkMomentsTensor tensor1, vtkMomentsTensor tensor2)
 multiply two tensors. More...
 
static vtkMomentsTensor tensorSum (vtkMomentsTensor tensor1, vtkMomentsTensor tensor2, double a, double b)
 sum two tensors. More...
 
static double tensorDistance (vtkMomentsTensor tensor1, vtkMomentsTensor tensor2)
 Euclidean distance between two tensors. More...
 
static vtkMomentsTensor getEpsilon (size_t dimension)
 this function produces the anti-symmetric Levi-Civita tensor More...
 

Detailed Description

helper class that stores a tensor of arbitrary rank and dimension

A tensor in general is a multidimensional array its rank gives the number of indices to reference its entries the number of entries is dimension^rank the application of this class is the moment invariant pattern detection the theory and the algorithm is described in Roxana Bujack and Hans Hagen: "Moment Invariants for Multi-Dimensional Data" http://www.informatik.uni-leipzig.de/~bujack/2017TensorDagstuhl.pdf for this purpose, we split the rank into fieldrank and moment rank the class mainly first multiplies and the contracts moment tensors and tracks these processes.

Thanks:
Developed by Roxana Bujack at Los Alamos National Laboratory.

Definition at line 89 of file vtkMomentsTensor.h.

Constructor & Destructor Documentation

◆ vtkMomentsTensor() [1/5]

vtkMomentsTensor::vtkMomentsTensor ( )
inline

empty constructor

Definition at line 226 of file vtkMomentsTensor.h.

◆ vtkMomentsTensor() [2/5]

vtkMomentsTensor::vtkMomentsTensor ( size_t  dimension,
size_t  rank,
size_t  fieldRank 
)
inline

constructor allocating the data vector

Parameters
dimensione.g. 2D or 3D
rankrank of the tensor, i.e. number of indices to reference its entries
fieldRank0 for scalars, 1 for vectors, 3 for matrices

Definition at line 240 of file vtkMomentsTensor.h.

◆ vtkMomentsTensor() [3/5]

vtkMomentsTensor::vtkMomentsTensor ( vtkMomentsTensor tensor)
inline

copy constructor

Definition at line 253 of file vtkMomentsTensor.h.

◆ vtkMomentsTensor() [4/5]

vtkMomentsTensor::vtkMomentsTensor ( size_t  dimension,
size_t  rank,
size_t  fieldRank,
size_t  momentRank 
)
inline

constructor allocating the data vector

Parameters
dimensione.g. 2D or 3D
rankrank of the tensor, i.e. number of indices to reference its entries
fieldRank0 for scalars, 1 for vectors, 3 for matrices
momentRankorder of the moment tensor

Definition at line 271 of file vtkMomentsTensor.h.

◆ vtkMomentsTensor() [5/5]

vtkMomentsTensor::vtkMomentsTensor ( Eigen::MatrixXd  data)
inline

copy constructor from eigen matrix

Definition at line 284 of file vtkMomentsTensor.h.

Member Function Documentation

◆ getIndex()

size_t vtkMomentsTensor::getIndex ( const std::vector< size_t > &  indices)
inline

inverse function to getIndices

Parameters
indicesvector of tensor indices that identify an entry
Returns
the place in the flat c++ std vector

Definition at line 302 of file vtkMomentsTensor.h.

◆ getRank()

size_t vtkMomentsTensor::getRank ( )
inline

get rank of the tensor, i.e.

number of indices to reference its entries

Definition at line 317 of file vtkMomentsTensor.h.

◆ getFieldRank()

size_t vtkMomentsTensor::getFieldRank ( )
inline

get field rank, 0 for scalars, 1 for vectors, 3 for matrices

Definition at line 322 of file vtkMomentsTensor.h.

◆ getMomentRank()

size_t vtkMomentsTensor::getMomentRank ( )
inline

get moment rank, order of the moment tensor

Definition at line 327 of file vtkMomentsTensor.h.

◆ getDimension()

size_t vtkMomentsTensor::getDimension ( )
inline

get dimension, e.g.

2D or 3D

Definition at line 332 of file vtkMomentsTensor.h.

◆ getData()

std::vector<double> vtkMomentsTensor::getData ( )
inline

get data vector

Definition at line 337 of file vtkMomentsTensor.h.

◆ getContractionInfo()

std::vector<size_t> vtkMomentsTensor::getContractionInfo ( )
inline

get the vector with the indices that indicate which tensor this one was produced from through contraction

Definition at line 343 of file vtkMomentsTensor.h.

◆ getProductInfo()

std::vector<size_t> vtkMomentsTensor::getProductInfo ( )
inline

get the vector with the indices that indicate which tensor this one was produced from through multiplication

Definition at line 349 of file vtkMomentsTensor.h.

◆ size()

size_t vtkMomentsTensor::size ( )
inline

get the number of entries of this tensor

Definition at line 354 of file vtkMomentsTensor.h.

◆ getIndices()

std::vector<size_t> vtkMomentsTensor::getIndices ( size_t  index)
inline

inverse function to getIndex

Parameters
indexthe place in the flat c++ std vector
Returns
: vector of tensor indices that identify an entry

Definition at line 361 of file vtkMomentsTensor.h.

◆ getIndexSum()

std::vector<size_t> vtkMomentsTensor::getIndexSum ( size_t  index)
inline

this function adds the numbers of zeros, ones, and twos in the tensor index it is used to determine the tensor's properties under reflection iff the sum is odd, the sign of the entry changes

Returns
the vector with the added values

Definition at line 378 of file vtkMomentsTensor.h.

◆ getMomentIndices()

std::vector<size_t> vtkMomentsTensor::getMomentIndices ( size_t  index)
inline

the moment tensors have two types of indices fieldIndices and momentIndices fieldIndices of length fieldRank refer to the components of the original data (3 for vector, 9 for matrix) momentIndices of length momentRank refer to the basis function

Parameters
indexthe place in the flat c++ std vector
Returns
: the indices that correspond to the basis function

Definition at line 396 of file vtkMomentsTensor.h.

◆ getFieldIndices()

std::vector<size_t> vtkMomentsTensor::getFieldIndices ( size_t  index)
inline

the moment tensors have two types of indices fieldIndices and momentIndices fieldIndices of length fieldRank refer to the components of the original data (3 for vector, 9 for matrix) momentIndices of length momentRank refer to the basis function

Parameters
indexthe place in the flat c++ std vector
Returns
: the indices that correspond to the function components

Definition at line 421 of file vtkMomentsTensor.h.

◆ getFieldIndex()

size_t vtkMomentsTensor::getFieldIndex ( size_t  index)
inline

IMPORTANT this function forms the bridge to vtk it translates the order of the fieldIndices to vtk's order as used by vtkDoubleArray.SetTuple() there the values are stored as follows: 2D and 3D: scalar: 0, vector: 0,1,2 matrix: 00,10,20,01,11,21,02,12,22 2D has zeros in the indices containing a 2.

Parameters
indexthe place in the flat c++ std vector of this class
Returns
: the corresponding index as used by vtkDoubleArray.SetTuple().

Definition at line 454 of file vtkMomentsTensor.h.

◆ get() [1/2]

double vtkMomentsTensor::get ( const std::vector< size_t > &  indices)
inline

Get data entry for given tensor indices.

Definition at line 467 of file vtkMomentsTensor.h.

◆ get() [2/2]

double vtkMomentsTensor::get ( size_t  index)
inline

Get data entry for given flat c++ vector index.

Definition at line 472 of file vtkMomentsTensor.h.

◆ set() [1/3]

void vtkMomentsTensor::set ( const std::vector< size_t > &  indices,
double  value 
)
inline

Set data entry for given tensor indices.

Definition at line 477 of file vtkMomentsTensor.h.

◆ set() [2/3]

void vtkMomentsTensor::set ( size_t  index,
double  value 
)
inline

Set data entry for given tensor indices.

Definition at line 485 of file vtkMomentsTensor.h.

◆ set() [3/3]

void vtkMomentsTensor::set ( const std::vector< double > &  data)
inline

Set the whole data vector.

Definition at line 490 of file vtkMomentsTensor.h.

◆ contract() [1/3]

vtkMomentsTensor vtkMomentsTensor::contract ( )
inline

This function produces a tensor contraction of the last two indices T'i = sum{j=k} T_ijk (i is multiindex) for arbitrary contractions, use the transpose function and move the indices there prior to calling this function.

Returns
the contracted tensor. its rank is two lower than the rank of its parent

Definition at line 499 of file vtkMomentsTensor.h.

◆ contract() [2/3]

vtkMomentsTensor vtkMomentsTensor::contract ( size_t  i,
size_t  j 
)
inline

This function produces a tensor contraction of the indices i and k T'i = sum{j=k} T_ijk (i is multiindex) we use the transpose function and move the indices i and k to the end and then call the contract() function.

Parameters
i index for contraction
k index for contraction
Returns
the contracted tensor. its rank is two lower than the rank of its parent

Definition at line 536 of file vtkMomentsTensor.h.

◆ contract() [3/3]

vtkMomentsTensor vtkMomentsTensor::contract ( std::vector< size_t >  contractor)
inline

This function produces a tensor contraction of the indices stored in contractor.

Parameters
contractorlist of indices to be contracted
Returns
the contracted tensor. its rank is length(contractor) lower than the rank of its parent

Definition at line 569 of file vtkMomentsTensor.h.

◆ print()

void vtkMomentsTensor::print ( )
inline

This function prints the properties of this tensor.

Definition at line 616 of file vtkMomentsTensor.h.

◆ contractAll()

std::vector<vtkMomentsTensor> vtkMomentsTensor::contractAll ( )
inline

This function produces a list of all possible 2-index combinations, which is used to generate all possible contractions.

Returns
vector of the contracted tensors. their rank is 2 lower than the rank of the parent

Definition at line 667 of file vtkMomentsTensor.h.

◆ norm()

double vtkMomentsTensor::norm ( )
inline

This function computes the Euclidean norm of the tensor.

Returns
Euclidean norm of the tensor

Definition at line 684 of file vtkMomentsTensor.h.

◆ getOrders()

std::vector<size_t> vtkMomentsTensor::getOrders ( size_t  index)
inline

for vector and matrix fields, the last indizes don't belong to the moment-indices, but the fieldIndex the number of zeros in the moment-indices equals p in the basis function x^p*y^q*z^r the number of one in a tensor-multiindex equals q in the basis function x^p*y^q*z^r the number of twos in a tensor-multiindex equals r in the basis function x^p*y^q*z^r

Parameters
indexthe place in the flat c++ std vector
Returns
: vector of summed tensor indices corresponds to p, q, r

Definition at line 702 of file vtkMomentsTensor.h.

◆ rotate()

vtkMomentsTensor vtkMomentsTensor::rotate ( Eigen::MatrixXd  rotMat)
inline

rotate the tensor

Parameters
rotMatrotation matrix that is applied
Returns
: rotated tensor

Definition at line 719 of file vtkMomentsTensor.h.

◆ tensorProduct()

static vtkMomentsTensor vtkMomentsTensor::tensorProduct ( vtkMomentsTensor  tensor1,
vtkMomentsTensor  tensor2 
)
inlinestatic

multiply two tensors.

the rank of the result is the sum of the ranks of its parents

Parameters
tensor1factor
tensor2factor
Returns
: tensor product

Definition at line 754 of file vtkMomentsTensor.h.

◆ tensorSum()

static vtkMomentsTensor vtkMomentsTensor::tensorSum ( vtkMomentsTensor  tensor1,
vtkMomentsTensor  tensor2,
double  a,
double  b 
)
inlinestatic

sum two tensors.

the rank of the result is the same as the rank of its parents

Parameters
tensor1summand
tensor2summand
Returns
: tensor sum

Definition at line 786 of file vtkMomentsTensor.h.

◆ tensorDistance()

static double vtkMomentsTensor::tensorDistance ( vtkMomentsTensor  tensor1,
vtkMomentsTensor  tensor2 
)
inlinestatic

Euclidean distance between two tensors.

Parameters
tensor1tensor
tensor2tensor
Returns
: tensor distance

Definition at line 818 of file vtkMomentsTensor.h.

◆ getVector()

Eigen::VectorXd vtkMomentsTensor::getVector ( )
inline

convenience function converting a rank 1 tensor into a vector

Returns
: vector

Definition at line 827 of file vtkMomentsTensor.h.

◆ getMatrix()

Eigen::MatrixXd vtkMomentsTensor::getMatrix ( )
inline

convenience function converting a rank 2 tensor into a matrix

Returns
: matrix

Definition at line 846 of file vtkMomentsTensor.h.

◆ getEpsilon()

static vtkMomentsTensor vtkMomentsTensor::getEpsilon ( size_t  dimension)
inlinestatic

this function produces the anti-symmetric Levi-Civita tensor

Returns
: Levi-Civita tensor

Definition at line 864 of file vtkMomentsTensor.h.

◆ eigenVectors()

std::vector<vtkMomentsTensor> vtkMomentsTensor::eigenVectors ( )
inline

this function computes the eigenvectors of a rank 2 tensor they are not normalized, but weighted with how distinct their corresponding eigenvalues are e.g.

if an eigenvalue appears twice, the corresponding vectors will be weighted with zero

Returns
: vector with the weighted eigenvectors

Definition at line 892 of file vtkMomentsTensor.h.

◆ otherEV()

void vtkMomentsTensor::otherEV ( )
inline

if we have a rank 1 tensor that was made from an eigenvector, its sign is arbitrary that means for the standard position, we need to take it and its negative into account this function generates the negative its contractionInfo is encoded as the eigenvector index plus the dimension e.g.

the largest 3D EV will have a 0 andits negative a 3

Definition at line 987 of file vtkMomentsTensor.h.


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