cristal.helper_classes.incrementers module#
Incrementers for moments matrix using various methods.
- class cristal.helper_classes.incrementers.IMPLEMENTED_INCREMENTERS_OPTIONS(*values)#
Bases:
Enum
The implemented incrementers classes.
- INVERSE = <class 'cristal.helper_classes.incrementers.InverseIncrementer'>#
- SHERMAN = <class 'cristal.helper_classes.incrementers.ShermanIncrementer'>#
- WOODBURY = <class 'cristal.helper_classes.incrementers.WoodburyIncrementer'>#
- class cristal.helper_classes.incrementers.InverseIncrementer#
Bases:
BaseIncrementer
Incrementer for moments matrix using the inverse method. This method updates the moments matrix and then computes the inverse of the updated moments matrix directly.
- static increment(mm, x, n, inv_class, sym=True)#
Increment the moments matrix using the inverse method.
- Parameters:
mm (MomentsMatrix) – The moments matrix to increment.
x (np.ndarray (N', d)) – The input data.
n (int) – The number of points integrated in the moments matrix.
inv_class (type[BaseInverter]) – The inversion class to use.
sym (bool, optional) – Not used in this implementation, by default True
-
update_moments_matrix:
bool
= True# Whether the method updates the moments matrix during incrementing
- class cristal.helper_classes.incrementers.ShermanIncrementer#
Bases:
BaseIncrementer
Incrementer for moments matrix using the Sherman-Morrison formula. This method updates the inverse moments matrix iteratively and not modifies the moments matrix.
- static increment(mm, x, n, inv_class=None, sym=True)#
Increment the moments matrix using the Sherman-Morrison formula iteratively.
Sherman-Morrison formula:
\[(A + uv^T)^{-1} = A^{-1} - \frac{(A^{-1} u v^T A^{-1})}{(1 + v^T A^{-1} u)}\]\[\text{Here } u = v^T\]- Parameters:
mm (MomentsMatrix) – The moments matrix to increment.
x (np.ndarray (N', d)) – The input data.
n (int) – The number of points integrated in the moments matrix.
inv_class (type[BaseInverter] | None, optional) – Not used in this implementation, by default None
sym (bool, optional) – Whether to consider the matrix as symmetric, by default True
- class cristal.helper_classes.incrementers.WoodburyIncrementer#
Bases:
BaseIncrementer
Incrementer for moments matrix using the Woodbury matrix identity. This method updates the inverse moments matrix and not modifies the moments matrix.
- static increment(mm, x, n, inv_class, sym=True)#
Increment the moments matrix using the Woodbury matrix identity.
Woodbury matrix identity:
\[(A + UCV)^{-1} = A^{-1} - A^{-1} U (C^{-1} + V A^{-1} U)^{-1} V A^{-1}\]\[\text{Here } C = I \text{ and } U = V^T = \begin{bmatrix} v_1, v_2, \cdots, v_{N'} \end{bmatrix}\]- Parameters:
mm (MomentsMatrix) – The moments matrix to increment.
x (np.ndarray (N', d)) – The input data.
n (int) – The number of points integrated in the moments matrix.
inv_class (type[BaseInverter]) – The inversion class to use.
sym (bool, optional) – Whether to consider the matrix as symmetric, by default True