UblasCustomFunctions.hpp File Reference

#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/ublas/matrix_expression.hpp>
#include <cfloat>
#include "petsc.h"
#include "petscblaslapack.h"
#include "Exception.hpp"
#include "PetscTools.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)
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)
double SmallPow (double x, unsigned exponent)
bool Divides (double smallerNumber, double largerNumber)


Detailed Description

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

Definition in file UblasCustomFunctions.hpp.


Function Documentation

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

Use LAPACK functionality to 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:
rA 3x3 matrix is question
Returns:
3-vector corresponding to right-eigenvector in question

Definition at line 57 of file UblasCustomFunctions.cpp.

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

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

Parameters:
x entry in vector
y entry in vector
z entry in vector
Returns:
vector=(x,y,z)

Definition at line 48 of file UblasCustomFunctions.cpp.

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

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

Parameters:
x entry in vector
y entry in vector
Returns:
vector=(x,y)

Definition at line 40 of file UblasCustomFunctions.cpp.

c_vector<double, 1> Create_c_vector ( double  x  ) 

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

Parameters:
x entry in vector
Returns:
vector=(x)

Definition at line 33 of file UblasCustomFunctions.cpp.

template<class T>
T Determinant ( const boost::numeric::ublas::c_matrix< T, 1, 0 > &  rM  )  [inline]

1x0 (Generalized determinant) - not implement, but needed by some compilers

Parameters:
rM The matrix of which to find the generalized determinant.

Definition at line 175 of file UblasCustomFunctions.hpp.

References NEVER_REACHED.

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

2x0 (Generalized determinant) - not implement, but needed by some compilers

Parameters:
rM The matrix of which to find the generalized determinant.

Definition at line 165 of file UblasCustomFunctions.hpp.

References NEVER_REACHED.

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

3x0 (Generalized determinant) - not implement, but needed by some compilers

Parameters:
rM The matrix of which to find the generalized determinant.

Definition at line 155 of file UblasCustomFunctions.hpp.

References NEVER_REACHED.

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

2x1 (Generalized determinant) Calculate the generalized determinant of a 2x1 matrix. The generalized determinant is given by det(T) = sqrt(det(T'T));

Parameters:
rM The matrix of which to find the generalized determinant.

Definition at line 142 of file UblasCustomFunctions.hpp.

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

3x1 (Generalized determinant) Calculate the generalized determinant of a 3x1 matrix. The generalized determinant is given by det(T) = sqrt(det(T'T));

Parameters:
rM The matrix of which to find the generalized determinant.

Definition at line 129 of file UblasCustomFunctions.hpp.

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

3x2 (Generalized determinant) Calculate the generalized determinant of a 3x2 matrix. The generalized determinant is given by det(T) = sqrt(det(T'T));

Parameters:
rM The matrix of which to find the generalized determinant.

Definition at line 115 of file UblasCustomFunctions.hpp.

References Determinant().

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

3x3 Determinant Get the determinant of a ublas matrix

Parameters:
rM The matrix of which to find the determinant.

Definition at line 95 of file UblasCustomFunctions.hpp.

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

2x2 Determinant Get the determinant of a ublas matrix

Parameters:
rM The matrix of which to find the determinant.

Definition at line 82 of file UblasCustomFunctions.hpp.

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

bool Divides ( double  smallerNumber,
double  largerNumber 
)

Uses fmod to determine if smallerNumber divides the largerNumber. We expect smallerNumber/largerNumber <= 1 and therefore fmod(largerNumber,smallerNumber) should be close zero or close to smallerNumber

Parameters:
smallerNumber the smaller
largerNumber the larger

Definition at line 150 of file UblasCustomFunctions.cpp.

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

3x1 pseudo-inverse of a matrix.

The pseudo-inverse is given by pinv(T) = (T'T)^(-1)*T'

Parameters:
rM The matrix of which to find the inverse.
Returns:
The inverse

Definition at line 508 of file UblasCustomFunctions.hpp.

References Determinant().

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

2x1 pseudo-inverse of a matrix.

The pseudo-inverse is given by pinv(T) = (T'T)^(-1)*T'

Parameters:
rM The matrix of which to find the inverse.
Returns:
The inverse

Definition at line 487 of file UblasCustomFunctions.hpp.

References Determinant().

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

2x3 pseudo-inverse of a matrix.

The pseudo-inverse is given by pinv(T) = (T'T)^(-1)*T'

Parameters:
rM The matrix of which to find the inverse.
Returns:
The inverse

Definition at line 446 of file UblasCustomFunctions.hpp.

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

3x3 Inverse Get the inverse of a ublas matrix

Parameters:
rM The matrix of which to find the inverse.
Returns:
The inverse

Definition at line 415 of file UblasCustomFunctions.hpp.

References Determinant().

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

2x2 Inverse Get the inverse of a ublas matrix

Parameters:
rM The matrix of which to find the inverse.
Returns:
The inverse

Definition at line 392 of file UblasCustomFunctions.hpp.

References Determinant().

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

template<class T>
T SecondInvariant ( const c_matrix< T, 2, 2 > &  rM  )  [inline]

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:
rM The matrix

Definition at line 597 of file UblasCustomFunctions.hpp.

References Determinant().

template<class T>
T SecondInvariant ( const c_matrix< T, 3, 3 > &  rM  )  [inline]

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:
rM The matrix

Definition at line 583 of file UblasCustomFunctions.hpp.

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

double SmallPow ( double  x,
unsigned  exponent 
)

Replacement "pow" function

Parameters:
x number to be raised to a small power
exponent small integer exponent
Returns:
x^exponent a.k.a x**exponent.

Definition at line 113 of file UblasCustomFunctions.cpp.

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

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

Parameters:
rM The matrix of which to find the subdeterminant.
missrow The index to the row to remove
misscol The index to the column to remove

Definition at line 355 of file UblasCustomFunctions.hpp.

References NEVER_REACHED.

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

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

Parameters:
rM The matrix of which to find the subdeterminant.
missrow The index to the row to remove
misscol The index to the column to remove

Definition at line 342 of file UblasCustomFunctions.hpp.

References NEVER_REACHED.

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

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

Parameters:
rM The matrix of which to find the subdeterminant.
missrow The index to the row to remove
misscol The index to the column to remove

Definition at line 329 of file UblasCustomFunctions.hpp.

References NEVER_REACHED.

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

SubDeterminant 2x1 Determinant of a submatrix after removing a particular row and column.

Parameters:
rM The matrix of which to find the subdeterminant.
missrow The index to the row to remove
misscol The index to the column to remove

Definition at line 305 of file UblasCustomFunctions.hpp.

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

SubDeterminant 3x1 Determinant of a submatrix after removing a particular row and column.

Parameters:
rM The matrix of which to find the subdeterminant.
missrow The index to the row to remove
misscol The index to the column to remove

Definition at line 283 of file UblasCustomFunctions.hpp.

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

SubDeterminant 3x2 Determinant of a submatrix after removing a particular row and column.

Parameters:
rM The matrix of which to find the subdeterminant.
missrow The index to the row to remove
misscol The index to the column to remove

Definition at line 261 of file UblasCustomFunctions.hpp.

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

SubDeterminant 3x3 Determinant of a submatrix after removing a particular row and column.

Parameters:
rM The matrix of which to find the subdeterminant.
missrow The index to the row to remove
misscol The index to the column to remove

Definition at line 236 of file UblasCustomFunctions.hpp.

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

2x2 SubDeterminant Return the determinant of a submatrix after removing a particular row and column

Parameters:
rM The matrix of which to find the subdeterminant.
missrow The index to the row to remove
misscol The index to the column to remove

Definition at line 216 of file UblasCustomFunctions.hpp.

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

1x1 SubDeterminant Return 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:
rM The matrix of which to find the subdeterminant.
missrow The index to the row to remove
misscol The index to the column to remove

Definition at line 196 of file UblasCustomFunctions.hpp.

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

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

4x4 matrix trace (sum of diagonal elements).

Parameters:
rM The matrix of which to find the trace.
Returns:
The trace

Definition at line 568 of file UblasCustomFunctions.hpp.

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

3x3 matrix trace (sum of diagonal elements).

Parameters:
rM The matrix of which to find the trace.
Returns:
The trace

Definition at line 556 of file UblasCustomFunctions.hpp.

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

2x2 matrix trace (sum of diagonal elements).

Parameters:
rM The matrix of which to find the trace.
Returns:
The trace

Definition at line 544 of file UblasCustomFunctions.hpp.

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

1x1 matrix trace (sum of diagonal elements).

Parameters:
rM The matrix of which to find the trace.
Returns:
The trace

Definition at line 532 of file UblasCustomFunctions.hpp.

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

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

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

Parameters:
rA first vector
rB second vector
Returns:
rA x rB

Definition at line 623 of file UblasCustomFunctions.hpp.

Referenced by StreeterFibreGenerator< SPACE_DIM >::GenerateOrthotropicFibreOrientation().


Generated on Tue May 31 14:31:54 2011 for Chaste by  doxygen 1.5.5