Chaste Commit::1fd4e48e3990e67db148bc1bc4cf6991a0049d0c
UblasCustomFunctions.hpp File Reference
#include "UblasIncludes.hpp"
#include "Exception.hpp"
#include "MathsCustomFunctions.hpp"
+ Include dependency graph for UblasCustomFunctions.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<class T >
Determinant (const boost::numeric::ublas::c_matrix< T, 1, 1 > &rM)
 
template<class T >
Determinant (const boost::numeric::ublas::c_matrix< T, 2, 2 > &rM)
 
template<class T >
Determinant (const boost::numeric::ublas::c_matrix< T, 3, 3 > &rM)
 
template<class T >
Determinant (const boost::numeric::ublas::c_matrix< T, 3, 2 > &rM)
 
template<class T >
Determinant (const boost::numeric::ublas::c_matrix< T, 3, 1 > &rM)
 
template<class T >
Determinant (const boost::numeric::ublas::c_matrix< T, 2, 1 > &rM)
 
template<class T >
Determinant (const boost::numeric::ublas::c_matrix< T, 3, 0 > &rM)
 
template<class T >
Determinant (const boost::numeric::ublas::c_matrix< T, 2, 0 > &rM)
 
template<class T >
Determinant (const boost::numeric::ublas::c_matrix< T, 1, 0 > &rM)
 
template<class T >
SubDeterminant (const boost::numeric::ublas::c_matrix< T, 1, 1 > &rM, const unsigned missrow, const unsigned misscol)
 
template<class T >
SubDeterminant (const boost::numeric::ublas::c_matrix< T, 2, 2 > &rM, const unsigned missrow, const unsigned misscol)
 
template<class T >
SubDeterminant (const boost::numeric::ublas::c_matrix< T, 3, 3 > &rM, const unsigned missrow, const unsigned misscol)
 
template<class T >
SubDeterminant (const boost::numeric::ublas::c_matrix< T, 3, 2 > &rM, const unsigned missrow, const unsigned misscol)
 
template<class T >
SubDeterminant (const boost::numeric::ublas::c_matrix< T, 3, 1 > &rM, const unsigned missrow, const unsigned misscol)
 
template<class T >
SubDeterminant (const boost::numeric::ublas::c_matrix< T, 2, 1 > &rM, const unsigned missrow, const unsigned misscol)
 
template<class T >
SubDeterminant (const boost::numeric::ublas::c_matrix< T, 3, 0 > &rM, const unsigned missrow, const unsigned misscol)
 
template<class T >
SubDeterminant (const boost::numeric::ublas::c_matrix< T, 2, 0 > &rM, const unsigned missrow, const unsigned misscol)
 
template<class T >
SubDeterminant (const boost::numeric::ublas::c_matrix< T, 1, 0 > &rM, const unsigned missrow, const unsigned misscol)
 
template<class T >
boost::numeric::ublas::c_matrix< T, 1, 1 > Inverse (const boost::numeric::ublas::c_matrix< T, 1, 1 > &rM)
 
template<class T >
boost::numeric::ublas::c_matrix< T, 2, 2 > Inverse (const boost::numeric::ublas::c_matrix< T, 2, 2 > &rM)
 
template<class T >
boost::numeric::ublas::c_matrix< T, 3, 3 > Inverse (const boost::numeric::ublas::c_matrix< T, 3, 3 > &rM)
 
template<class T >
boost::numeric::ublas::c_matrix< T, 2, 3 > Inverse (const boost::numeric::ublas::c_matrix< T, 3, 2 > &rM)
 
template<class T >
boost::numeric::ublas::c_matrix< T, 1, 2 > Inverse (const boost::numeric::ublas::c_matrix< T, 2, 1 > &rM)
 
template<class T >
boost::numeric::ublas::c_matrix< T, 1, 3 > Inverse (const boost::numeric::ublas::c_matrix< T, 3, 1 > &rM)
 
template<class T >
Trace (const c_matrix< T, 1, 1 > &rM)
 
template<class T >
Trace (const c_matrix< T, 2, 2 > &rM)
 
template<class T >
Trace (const c_matrix< T, 3, 3 > &rM)
 
template<class T >
Trace (const c_matrix< T, 4, 4 > &rM)
 
template<class T >
SecondInvariant (const c_matrix< T, 3, 3 > &rM)
 
template<class T >
SecondInvariant (const c_matrix< T, 2, 2 > &rM)
 
c_vector< double, 3 > CalculateEigenvectorForSmallestNonzeroEigenvalue (c_matrix< double, 3, 3 > &rA)
 
double CalculateMaxEigenpair (c_matrix< double, 3, 3 > &rA, c_vector< double, 3 > &rEigenvector)
 
template<class T >
c_vector< T, 1 > VectorProduct (const c_vector< T, 1 > &rA, const c_vector< T, 1 > &rB)
 
template<class T >
c_vector< T, 2 > VectorProduct (const c_vector< T, 2 > &rA, const c_vector< T, 2 > &rB)
 
template<class T >
c_vector< T, 3 > VectorProduct (const c_vector< T, 3 > &rA, const c_vector< T, 3 > &rB)
 
c_vector< double, 1 > Create_c_vector (double x)
 
c_vector< double, 2 > Create_c_vector (double x, double y)
 
c_vector< double, 3 > Create_c_vector (double x, double y, double z)
 

Detailed Description

A collection of useful functions extending the functionality of the Boost Ublas library.

Definition in file UblasCustomFunctions.hpp.

Function Documentation

◆ CalculateEigenvectorForSmallestNonzeroEigenvalue()

c_vector< double, 3 > CalculateEigenvectorForSmallestNonzeroEigenvalue ( c_matrix< double, 3, 3 > &  rA)

Find the eigenvector corresponding real eigenvalue which is smallest in magnitude. Caveat: if there are zero eigenvalues they are ignored. It's the smallest magnitude non-zero real eigenvalue which is used.

Parameters
rA3x3 matrix is question. This should be symmetric and positive definite.
Returns
3-vector corresponding to right-eigenvector in question

Definition at line 62 of file UblasCustomFunctions.cpp.

References EXCEPTION, and UNUSED_OPT.

◆ CalculateMaxEigenpair()

double CalculateMaxEigenpair ( c_matrix< double, 3, 3 > &  rA,
c_vector< double, 3 > &  rEigenvector 
)

Helper function to get maximum eigenpair from a 3x3 matrix by the power method

Parameters
rA3x3 matrix is question.
rEigenvectora guess eigenvector which will be refined
Returns
the maximum eigenvalue

Definition at line 109 of file UblasCustomFunctions.cpp.

◆ Create_c_vector() [1/3]

c_vector< double, 1 > Create_c_vector ( double  x)

Convenience function for quickly creating test vectors (1D).

Parameters
xentry in vector
Returns
vector=(x)

Definition at line 38 of file UblasCustomFunctions.cpp.

◆ Create_c_vector() [2/3]

c_vector< double, 2 > Create_c_vector ( double  x,
double  y 
)

Convenience function for quickly creating test vectors (2D).

Parameters
xentry in vector
yentry in vector
Returns
vector=(x,y)

Definition at line 45 of file UblasCustomFunctions.cpp.

◆ Create_c_vector() [3/3]

c_vector< double, 3 > Create_c_vector ( double  x,
double  y,
double  z 
)

Convenience function for quickly creating test vectors (3D).

Parameters
xentry in vector
yentry in vector
zentry in vector
Returns
vector=(x,y,z)

Definition at line 53 of file UblasCustomFunctions.cpp.

◆ Determinant() [1/9]

template<class T >
T Determinant ( const boost::numeric::ublas::c_matrix< T, 1, 0 > &  rM)
Returns
(nothing) 1x0 (Generalized determinant) - not implement, but needed by some compilers.
Parameters
rMThe matrix of which to find the generalized determinant.

Definition at line 172 of file UblasCustomFunctions.hpp.

References NEVER_REACHED.

◆ Determinant() [2/9]

◆ Determinant() [3/9]

template<class T >
T Determinant ( const boost::numeric::ublas::c_matrix< T, 2, 0 > &  rM)
Returns
(nothing) 2x0 (Generalized determinant) - not implement, but needed by some compilers.
Parameters
rMThe matrix of which to find the generalized determinant.

Definition at line 160 of file UblasCustomFunctions.hpp.

References NEVER_REACHED.

◆ Determinant() [4/9]

template<class T >
T Determinant ( const boost::numeric::ublas::c_matrix< T, 2, 1 > &  rM)

2x1 (Generalized determinant).

Returns
calculated generalized determinant of a 2x1 matrix. The generalized determinant is given by det(T) = sqrt(det(T'T));
Parameters
rMThe matrix of which to find the generalized determinant.

Definition at line 135 of file UblasCustomFunctions.hpp.

◆ Determinant() [5/9]

template<class T >
T Determinant ( const boost::numeric::ublas::c_matrix< T, 2, 2 > &  rM)

2x2 Determinant.

Returns
the determinant of a ublas matrix.
Parameters
rMThe matrix of which to find the determinant.

Definition at line 73 of file UblasCustomFunctions.hpp.

◆ Determinant() [6/9]

template<class T >
T Determinant ( const boost::numeric::ublas::c_matrix< T, 3, 0 > &  rM)
Returns
(nothing) 3x0 (Generalized determinant) - not implement, but needed by some compilers.
Parameters
rMThe matrix of which to find the generalized determinant.

Definition at line 148 of file UblasCustomFunctions.hpp.

References NEVER_REACHED.

◆ Determinant() [7/9]

template<class T >
T Determinant ( const boost::numeric::ublas::c_matrix< T, 3, 1 > &  rM)

3x1 (Generalized determinant).

Returns
calculated generalized determinant of a 3x1 matrix. The generalized determinant is given by det(T) = sqrt(det(T'T));
Parameters
rMThe matrix of which to find the generalized determinant.

Definition at line 121 of file UblasCustomFunctions.hpp.

◆ Determinant() [8/9]

template<class T >
T Determinant ( const boost::numeric::ublas::c_matrix< T, 3, 2 > &  rM)

3x2 (Generalized determinant).

Returns
calculated generalized determinant of a 3x2 matrix. The generalized determinant is given by det(T) = sqrt(det(T'T));
Parameters
rMThe matrix of which to find the generalized determinant.

Definition at line 106 of file UblasCustomFunctions.hpp.

References Determinant().

◆ Determinant() [9/9]

template<class T >
T Determinant ( const boost::numeric::ublas::c_matrix< T, 3, 3 > &  rM)

3x3 Determinant.

Returns
the determinant of a ublas matrix.
Parameters
rMThe matrix of which to find the determinant.

Definition at line 87 of file UblasCustomFunctions.hpp.

◆ Inverse() [1/6]

◆ Inverse() [2/6]

template<class T >
boost::numeric::ublas::c_matrix< T, 1, 2 > Inverse ( const boost::numeric::ublas::c_matrix< T, 2, 1 > &  rM)

2x1 pseudo-inverse of a matrix. The pseudo-inverse is given by pinv(T) = (T'T)^(-1)*T'.

Parameters
rMThe matrix of which to find the inverse.
Returns
The inverse

Definition at line 480 of file UblasCustomFunctions.hpp.

References Determinant().

◆ Inverse() [3/6]

template<class T >
boost::numeric::ublas::c_matrix< T, 2, 2 > Inverse ( const boost::numeric::ublas::c_matrix< T, 2, 2 > &  rM)

2x2 Inverse. Get the inverse of a ublas matrix.

Parameters
rMThe matrix of which to find the inverse.
Returns
The inverse

Definition at line 386 of file UblasCustomFunctions.hpp.

References Determinant().

◆ Inverse() [4/6]

template<class T >
boost::numeric::ublas::c_matrix< T, 1, 3 > Inverse ( const boost::numeric::ublas::c_matrix< T, 3, 1 > &  rM)

3x1 pseudo-inverse of a matrix. The pseudo-inverse is given by pinv(T) = (T'T)^(-1)*T'.

Parameters
rMThe matrix of which to find the inverse.
Returns
The inverse

Definition at line 501 of file UblasCustomFunctions.hpp.

References Determinant().

◆ Inverse() [5/6]

template<class T >
boost::numeric::ublas::c_matrix< T, 2, 3 > Inverse ( const boost::numeric::ublas::c_matrix< T, 3, 2 > &  rM)

2x3 pseudo-inverse of a matrix. The pseudo-inverse is given by pinv(T) = (T'T)^(-1)*T'.

Parameters
rMThe matrix of which to find the inverse.
Returns
The inverse

Definition at line 440 of file UblasCustomFunctions.hpp.

◆ Inverse() [6/6]

template<class T >
boost::numeric::ublas::c_matrix< T, 3, 3 > Inverse ( const boost::numeric::ublas::c_matrix< T, 3, 3 > &  rM)

3x3 Inverse. Get the inverse of a ublas matrix.

Parameters
rMThe matrix of which to find the inverse.
Returns
The inverse

Definition at line 409 of file UblasCustomFunctions.hpp.

References Determinant().

◆ SecondInvariant() [1/2]

template<class T >
T SecondInvariant ( const c_matrix< T, 2, 2 > &  rM)
Returns
2x2 second invariant. Second invariant of a 2d matrix, i.e. the determinant. This function is mainly here just so that the same code can be used in 2d and 3d.
Parameters
rMThe matrix

Definition at line 590 of file UblasCustomFunctions.hpp.

References Determinant().

◆ SecondInvariant() [2/2]

template<class T >
T SecondInvariant ( const c_matrix< T, 3, 3 > &  rM)
Returns
3x3 second invariant.
Note
Implementation only correct for a SYMMETRIC matrix though. It is up to the user to check the input matrix is symmetric.
Parameters
rMThe matrix

Definition at line 576 of file UblasCustomFunctions.hpp.

Referenced by AbstractIsotropicCompressibleMaterialLaw< DIM >::ComputeStressAndStressDerivative(), and AbstractIsotropicIncompressibleMaterialLaw< DIM >::ComputeStressAndStressDerivative().

◆ SubDeterminant() [1/9]

template<class T >
T SubDeterminant ( const boost::numeric::ublas::c_matrix< T, 1, 0 > &  rM,
const unsigned  missrow,
const unsigned  misscol 
)

SubDeterminant 1x0 - Not implemented, but needed by some compilers for recursive template calls. Determinant of a submatrix after removing a particular row and column.

Returns
(nothing)
Parameters
rMThe matrix of which to find the subdeterminant.
missrowThe index to the row to remove
misscolThe index to the column to remove

Definition at line 351 of file UblasCustomFunctions.hpp.

References NEVER_REACHED.

◆ SubDeterminant() [2/9]

template<class T >
T SubDeterminant ( const boost::numeric::ublas::c_matrix< T, 1, 1 > &  rM,
const unsigned  missrow,
const unsigned  misscol 
)

1x1 SubDeterminant.

Returns
the determinant of a submatrix after removing a particular row and column For a 1x1 matrix this should always remove the only row and column (0,0).
Parameters
rMThe matrix of which to find the subdeterminant.
missrowThe index to the row to remove
misscolThe index to the column to remove

Definition at line 189 of file UblasCustomFunctions.hpp.

Referenced by AbstractTetrahedralElement< ELEMENT_DIM, SPACE_DIM >::CalculateWeightedDirection().

◆ SubDeterminant() [3/9]

template<class T >
T SubDeterminant ( const boost::numeric::ublas::c_matrix< T, 2, 0 > &  rM,
const unsigned  missrow,
const unsigned  misscol 
)

SubDeterminant 2x0 - Not implemented, but needed by some compilers for recursive template calls.

Returns
(nothing)
Parameters
rMThe matrix of which to find the subdeterminant.
missrowThe index to the row to remove
misscolThe index to the column to remove

Definition at line 337 of file UblasCustomFunctions.hpp.

References NEVER_REACHED.

◆ SubDeterminant() [4/9]

template<class T >
T SubDeterminant ( const boost::numeric::ublas::c_matrix< T, 2, 1 > &  rM,
const unsigned  missrow,
const unsigned  misscol 
)

SubDeterminant 2x1.

Returns
determinant of a submatrix after removing a particular row and column.
Parameters
rMThe matrix of which to find the subdeterminant.
missrowThe index to the row to remove
misscolThe index to the column to remove

Definition at line 299 of file UblasCustomFunctions.hpp.

◆ SubDeterminant() [5/9]

template<class T >
T SubDeterminant ( const boost::numeric::ublas::c_matrix< T, 2, 2 > &  rM,
const unsigned  missrow,
const unsigned  misscol 
)

2x2 SubDeterminant.

Returns
the determinant of a submatrix after removing a particular row and column.
Parameters
rMThe matrix of which to find the subdeterminant.
missrowThe index to the row to remove
misscolThe index to the column to remove

Definition at line 207 of file UblasCustomFunctions.hpp.

◆ SubDeterminant() [6/9]

template<class T >
T SubDeterminant ( const boost::numeric::ublas::c_matrix< T, 3, 0 > &  rM,
const unsigned  missrow,
const unsigned  misscol 
)

SubDeterminant 3x0 - Not implemented, but needed by some compilers for recursive template calls.

Returns
(nothing)
Parameters
rMThe matrix of which to find the subdeterminant.
missrowThe index to the row to remove
misscolThe index to the column to remove

Definition at line 323 of file UblasCustomFunctions.hpp.

References NEVER_REACHED.

◆ SubDeterminant() [7/9]

template<class T >
T SubDeterminant ( const boost::numeric::ublas::c_matrix< T, 3, 1 > &  rM,
const unsigned  missrow,
const unsigned  misscol 
)

SubDeterminant 3x1.

Returns
determinant of a submatrix after removing a particular row and column.
Parameters
rMThe matrix of which to find the subdeterminant.
missrowThe index to the row to remove
misscolThe index to the column to remove

Definition at line 276 of file UblasCustomFunctions.hpp.

◆ SubDeterminant() [8/9]

template<class T >
T SubDeterminant ( const boost::numeric::ublas::c_matrix< T, 3, 2 > &  rM,
const unsigned  missrow,
const unsigned  misscol 
)

SubDeterminant 3x2.

Returns
determinant of a submatrix after removing a particular row and column.
Parameters
rMThe matrix of which to find the subdeterminant.
missrowThe index to the row to remove
misscolThe index to the column to remove

Definition at line 253 of file UblasCustomFunctions.hpp.

◆ SubDeterminant() [9/9]

template<class T >
T SubDeterminant ( const boost::numeric::ublas::c_matrix< T, 3, 3 > &  rM,
const unsigned  missrow,
const unsigned  misscol 
)

SubDeterminant 3x3.

Returns
determinant of a submatrix after removing a particular row and column.
Parameters
rMThe matrix of which to find the subdeterminant.
missrowThe index to the row to remove
misscolThe index to the column to remove

Definition at line 228 of file UblasCustomFunctions.hpp.

◆ Trace() [1/4]

template<class T >
T Trace ( const c_matrix< T, 1, 1 > &  rM)
inline

1x1 matrix trace (sum of diagonal elements).

Parameters
rMThe matrix of which to find the trace.
Returns
The trace

Definition at line 524 of file UblasCustomFunctions.hpp.

Referenced by AbstractIsotropicCompressibleMaterialLaw< DIM >::ComputeStressAndStressDerivative(), and AbstractIsotropicIncompressibleMaterialLaw< DIM >::ComputeStressAndStressDerivative().

◆ Trace() [2/4]

template<class T >
T Trace ( const c_matrix< T, 2, 2 > &  rM)
inline

2x2 matrix trace (sum of diagonal elements).

Parameters
rMThe matrix of which to find the trace.
Returns
The trace

Definition at line 536 of file UblasCustomFunctions.hpp.

◆ Trace() [3/4]

template<class T >
T Trace ( const c_matrix< T, 3, 3 > &  rM)
inline

3x3 matrix trace (sum of diagonal elements).

Parameters
rMThe matrix of which to find the trace.
Returns
The trace

Definition at line 548 of file UblasCustomFunctions.hpp.

◆ Trace() [4/4]

template<class T >
T Trace ( const c_matrix< T, 4, 4 > &  rM)
inline

4x4 matrix trace (sum of diagonal elements).

Parameters
rMThe matrix of which to find the trace.
Returns
The trace

Definition at line 560 of file UblasCustomFunctions.hpp.

◆ VectorProduct() [1/3]

template<class T >
c_vector< T, 1 > VectorProduct ( const c_vector< T, 1 > &  rA,
const c_vector< T, 1 > &  rB 
)

This is a fake cross-product aka vector-product. Fake because it's only implemented for 3-vectors. This version is to satisfy template compilation.

Parameters
rAfirst vector
rBsecond vector
Returns
Does not return rA x rB

Definition at line 626 of file UblasCustomFunctions.hpp.

References NEVER_REACHED.

Referenced by VertexMesh< ELEMENT_DIM, SPACE_DIM >::CalculateUnitNormalToFaceWithArea(), and StreeterFibreGenerator< SPACE_DIM >::Visit().

◆ VectorProduct() [2/3]

template<class T >
c_vector< T, 2 > VectorProduct ( const c_vector< T, 2 > &  rA,
const c_vector< T, 2 > &  rB 
)

This is a fake cross-product aka vector-product. Fake because it's only implemented for 3-vectors. This version is to satisfy template compilation.

Parameters
rAfirst vector
rBsecond vector
Returns
Does not return rA x rB

Definition at line 639 of file UblasCustomFunctions.hpp.

References NEVER_REACHED.

◆ VectorProduct() [3/3]

template<class T >
c_vector< T, 3 > VectorProduct ( const c_vector< T, 3 > &  rA,
const c_vector< T, 3 > &  rB 
)

This is a cross-product aka vector-product, only implemented for 3-vectors.

Parameters
rAfirst vector
rBsecond vector
Returns
rA x rB

Definition at line 652 of file UblasCustomFunctions.hpp.