cristal.helper_classes.inversion module#

Inversion methods for matrices.

class cristal.helper_classes.inversion.FPDInverter#

Bases: BaseInverter

Inverter for positive definite matrices using Cholesky decomposition in LAPACK. See https://stackoverflow.com/a/58719188 for more details.

inds_cache = {}#
static invert(matrix)#

Compute the inverse of a positive definite matrix. According to: https://stackoverflow.com/a/58719188

Return type:

ndarray

Parameters:

matrix (np.ndarray (n, n)) – The input matrix to invert.

Returns:

The inverse of the input matrix.

Return type:

np.ndarray (n, n)

Raises:

ValueError – If the input matrix is not positive definite / if the Cholesky decomposition fails.

static upper_triangular_to_symmetric(ut)#

Convert an upper triangular matrix to a symmetric matrix.

Return type:

None

Parameters:

ut (np.ndarray (n, n)) – The upper triangular matrix to convert.

class cristal.helper_classes.inversion.IMPLEMENTED_INVERSION_OPTIONS(*values)#

Bases: Enum

The implemented inversion classes.

FPD_INV = <class 'cristal.helper_classes.inversion.FPDInverter'>#
INV = <class 'cristal.helper_classes.inversion.InvInverter'>#
PD_INV = <class 'cristal.helper_classes.inversion.PDInverter'>#
PINV = <class 'cristal.helper_classes.inversion.PseudoInverter'>#
class cristal.helper_classes.inversion.InvInverter#

Bases: BaseInverter

Inverter for matrices using the standard inverse method from SciPy.

static invert(matrix)#

Compute the inverse of a matrix.

Return type:

ndarray

Parameters:

matrix (np.ndarray (n, n)) – The input matrix to invert.

Returns:

The inverse of the input matrix.

Return type:

np.ndarray (n, n)

class cristal.helper_classes.inversion.PDInverter#

Bases: BaseInverter

Inverter for positive definite matrices. See https://stackoverflow.com/a/40709871 for more details.

static invert(matrix)#

Compute the inverse of a positive definite matrix. According to: https://stackoverflow.com/a/40709871

Return type:

ndarray

Parameters:

matrix (np.ndarray (n, n)) – The input matrix to invert.

Returns:

The inverse of the input matrix.

Return type:

np.ndarray (n, n)

class cristal.helper_classes.inversion.PseudoInverter#

Bases: BaseInverter

Inverter for matrices using the Moore-Penrose pseudo-inverse method from SciPy.

static invert(matrix)#

Compute the pseudo-inverse of a matrix.

Return type:

ndarray

Parameters:

matrix (np.ndarray (n, n)) – The input matrix to invert.

Returns:

The pseudo-inverse of the input matrix.

Return type:

np.ndarray (n, n)