KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
List of all members
Kratos::SVDUtils< TDataType > Class Template Reference

Various mathematical utilities to compute SVD and the condition number of a matrix. More...

#include <svd_utils.h>

Collaboration diagram for Kratos::SVDUtils< TDataType >:

Static Public Member Functions

Operations
static std::size_t SingularValueDecomposition (const MatrixType &InputMatrix, MatrixType &UMatrix, MatrixType &SMatrix, MatrixType &VMatrix, Parameters ThisParameters)
 This function gives the SVD of a given mxn matrix (m>=n), returns U,S; where A=U*S*V. More...
 
static std::size_t SingularValueDecomposition (const MatrixType &InputMatrix, MatrixType &UMatrix, MatrixType &SMatrix, MatrixType &VMatrix, const std::string &TypeSVD="Jacobi", const TDataType Tolerance=std::numeric_limits< double >::epsilon(), const IndexType MaxIter=200)
 This function gives the SVD of a given mxn matrix (m>=n), returns U,S; where A=U*S*V. More...
 
static std::size_t JacobiSingularValueDecomposition (const MatrixType &InputMatrix, MatrixType &UMatrix, MatrixType &SMatrix, MatrixType &VMatrix, const TDataType Tolerance=std::numeric_limits< double >::epsilon(), const IndexType MaxIter=200)
 This function gives the Jacobi SVD of a given mxn matrix (m>=n), returns U,S; where A=U*S*V. More...
 
static void SingularValueDecomposition2x2 (const MatrixType &InputMatrix, MatrixType &UMatrix, MatrixType &SMatrix, MatrixType &VMatrix)
 This function gives the Jacobi SVD of a given 2x2 matrix, returns U,S; where A=U*S*V. More...
 
static void SingularValueDecomposition2x2Symmetric (const MatrixType &InputMatrix, MatrixType &UMatrix, MatrixType &SMatrix, MatrixType &VMatrix)
 
static void Jacobi (MatrixType &J1, MatrixType &J2, const MatrixType &InputMatrix, const SizeType &Size1, const SizeType &Size2, const SizeType &Index1, const SizeType &Index2)
 This method computes the Jacobi rotation operation. More...
 
static void Jacobi (MatrixType &J1, const MatrixType &InputMatrix, const SizeType &Size1, const SizeType &Index1, const SizeType &Index2)
 This method computes the Jacobi rotation operation. More...
 
static TDataType SVDConditionNumber (const MatrixType &InputMatrix, const std::string TypeSVD="Jacobi", const TDataType Tolerance=std::numeric_limits< double >::epsilon(), const IndexType MaxIter=200)
 This method computes the condition number using the SVD. More...
 

Type Definitions

typedef Matrix MatrixType
 Definition of the matrix type. More...
 
typedef Vector VectorType
 Definition of the vector type. More...
 
typedef std::size_t SizeType
 Definition of the size type. More...
 
typedef std::size_t IndexType
 Definition of index type. More...
 
typedef UblasSpace< TDataType, Matrix, VectorLocalSpaceType
 Definition of local space. More...
 
constexpr static TDataType ZeroTolerance = std::numeric_limits<double>::epsilon()
 Definition of epsilon zero tolerance. More...
 

Detailed Description

template<class TDataType>
class Kratos::SVDUtils< TDataType >

Various mathematical utilities to compute SVD and the condition number of a matrix.

Defines several utility functions

Author
Vicente Mataix Ferrandiz

Member Typedef Documentation

◆ IndexType

template<class TDataType >
typedef std::size_t Kratos::SVDUtils< TDataType >::IndexType

Definition of index type.

◆ LocalSpaceType

template<class TDataType >
typedef UblasSpace<TDataType, Matrix, Vector> Kratos::SVDUtils< TDataType >::LocalSpaceType

Definition of local space.

◆ MatrixType

template<class TDataType >
typedef Matrix Kratos::SVDUtils< TDataType >::MatrixType

Definition of the matrix type.

◆ SizeType

template<class TDataType >
typedef std::size_t Kratos::SVDUtils< TDataType >::SizeType

Definition of the size type.

◆ VectorType

template<class TDataType >
typedef Vector Kratos::SVDUtils< TDataType >::VectorType

Definition of the vector type.

Member Function Documentation

◆ Jacobi() [1/2]

template<class TDataType >
static void Kratos::SVDUtils< TDataType >::Jacobi ( MatrixType J1,
const MatrixType InputMatrix,
const SizeType Size1,
const SizeType Index1,
const SizeType Index2 
)
inlinestatic

This method computes the Jacobi rotation operation.

Parameters
J1First Jacobi matrix
InputMatrixThe matrix to compute the Jacobi tolerance
Size1The size of the matrix (number of rows)
Size2The size of the matrix (number of columns)
Index1The index to compute (row)
Index2The index to compute (column)

◆ Jacobi() [2/2]

template<class TDataType >
static void Kratos::SVDUtils< TDataType >::Jacobi ( MatrixType J1,
MatrixType J2,
const MatrixType InputMatrix,
const SizeType Size1,
const SizeType Size2,
const SizeType Index1,
const SizeType Index2 
)
inlinestatic

This method computes the Jacobi rotation operation.

Parameters
J1First Jacobi matrix
J2Second Jacobi matrix
InputMatrixThe matrix to compute the Jacobi tolerance
Size1The size of the matrix (number of rows)
Size2The size of the matrix (number of columns)
Index1The index to compute (row)
Index2The index to compute (column)

◆ JacobiSingularValueDecomposition()

template<class TDataType >
static std::size_t Kratos::SVDUtils< TDataType >::JacobiSingularValueDecomposition ( const MatrixType InputMatrix,
MatrixType UMatrix,
MatrixType SMatrix,
MatrixType VMatrix,
const TDataType  Tolerance = std::numeric_limits<double>::epsilon(),
const IndexType  MaxIter = 200 
)
inlinestatic

This function gives the Jacobi SVD of a given mxn matrix (m>=n), returns U,S; where A=U*S*V.

U and V are unitary, and S is a diagonal matrix. Where s_i >= 0, and s_i >= s_i+1 (which means that the biggest number is the first one and the smallest the last one)

Todo:
This version is quite innefficient, look for a real and mathematical implementation (not the algorithm found in Wikipedia!!)
Parameters
InputMatrixThe matrix where perform the SVD
UMatrixThe unitary U matrix
SMatrixThe diagonal S matrix
VMatrixThe unitary V matrix
ToleranceThe tolerance considered
MaxIterMaximum number of iterations
Returns
iter: The number of iterations

◆ SingularValueDecomposition() [1/2]

template<class TDataType >
static std::size_t Kratos::SVDUtils< TDataType >::SingularValueDecomposition ( const MatrixType InputMatrix,
MatrixType UMatrix,
MatrixType SMatrix,
MatrixType VMatrix,
const std::string &  TypeSVD = "Jacobi",
const TDataType  Tolerance = std::numeric_limits<double>::epsilon(),
const IndexType  MaxIter = 200 
)
inlinestatic

This function gives the SVD of a given mxn matrix (m>=n), returns U,S; where A=U*S*V.

U and V are unitary, and S is a diagonal matrix. Where s_i >= 0, and s_i >= s_i+1 (which means that the biggest number is the first one and the smallest the last one)

Todo:
This version is quite innefficient, look for a real and mathematical implementation (not the algorithm found in Wikipedia!!)
Parameters
InputMatrixThe matrix where perform the SVD
UMatrixThe unitary U matrix
SMatrixThe diagonal S matrix
VMatrixThe unitary V matrix
TypeSVDThe type of SVD algorithm (Jacobi by default)
ToleranceThe tolerance considered
MaxIterMaximum number of iterations
Returns
iter: The number of iterations

◆ SingularValueDecomposition() [2/2]

template<class TDataType >
static std::size_t Kratos::SVDUtils< TDataType >::SingularValueDecomposition ( const MatrixType InputMatrix,
MatrixType UMatrix,
MatrixType SMatrix,
MatrixType VMatrix,
Parameters  ThisParameters 
)
inlinestatic

This function gives the SVD of a given mxn matrix (m>=n), returns U,S; where A=U*S*V.

U and V are unitary, and S is a diagonal matrix. Where s_i >= 0, and s_i >= s_i+1 (which means that the biggest number is the first one and the smallest the last one)

Todo:
This version is quite innefficient, look for a real and mathematical implementation (not the algorithm found in Wikipedia!!)
Parameters
InputMatrixThe matrix where perform the SVD
UMatrixThe unitary U matrix
SMatrixThe diagonal S matrix
VMatrixThe unitary V matrix
ThisParametersThe configuration parameters
Returns
iter: The number of iterations

◆ SingularValueDecomposition2x2()

template<class TDataType >
static void Kratos::SVDUtils< TDataType >::SingularValueDecomposition2x2 ( const MatrixType InputMatrix,
MatrixType UMatrix,
MatrixType SMatrix,
MatrixType VMatrix 
)
inlinestatic

This function gives the Jacobi SVD of a given 2x2 matrix, returns U,S; where A=U*S*V.

U and V are unitary, and S is a diagonal matrix. Where s_i >= 0, and s_i >= s_i+1

Parameters
InputMatrixThe matrix where perform the SVD
UMatrixThe unitary U matrix
SMatrixThe diagonal S matrix
VMatrixThe unitary V matrix

◆ SingularValueDecomposition2x2Symmetric()

template<class TDataType >
static void Kratos::SVDUtils< TDataType >::SingularValueDecomposition2x2Symmetric ( const MatrixType InputMatrix,
MatrixType UMatrix,
MatrixType SMatrix,
MatrixType VMatrix 
)
inlinestatic

This function gives the Jacobi SVD of a given 2x2 matrix, returns U,S; where A=U*S*V U and V are unitary, and S is a diagonal matrix. Where s_i >= 0, and s_i >= s_i+1

Parameters
InputMatrixThe matrix where perform the SVD
UMatrixThe unitary U matrix
SMatrixThe diagonal S matrix
VMatrixThe unitary V matrix

◆ SVDConditionNumber()

template<class TDataType >
static TDataType Kratos::SVDUtils< TDataType >::SVDConditionNumber ( const MatrixType InputMatrix,
const std::string  TypeSVD = "Jacobi",
const TDataType  Tolerance = std::numeric_limits<double>::epsilon(),
const IndexType  MaxIter = 200 
)
inlinestatic

This method computes the condition number using the SVD.

The condition number can be estimated as the ratio between the largest singular value and the smallest singular value

Parameters
InputMatrixThe matrix to be evaluated
ToleranceThe tolerance considered
Returns
condition_number: The ratio between the largest SV and the smallest SV

Member Data Documentation

◆ ZeroTolerance

template<class TDataType >
constexpr static TDataType Kratos::SVDUtils< TDataType >::ZeroTolerance = std::numeric_limits<double>::epsilon()
staticconstexpr

Definition of epsilon zero tolerance.


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