low_rank_toolbox.krylov.spaces.inverted_krylov_space
Inverted Krylov subspace construction.
Author: Benjamin Carrel, University of Geneva, 2022-2023
Classes
|
Inverted Krylov space. |
- class low_rank_toolbox.krylov.spaces.inverted_krylov_space.InvertedKrylovSpace(A, X, invA=None, **extra_args)[source]
Bases:
KrylovSpaceInverted Krylov space.
- Constructs the inverted Krylov space:
IK_m(A, X) = span{A^(-1)X, A^(-2)X, …, A^(-m)X}
This class wraps the KrylovSpace class by providing a custom matvec function that computes A^(-1) * v instead of A * v.
How to use
Initialize the inverted Krylov space with matrix A and vector/matrix X.
Augment the basis as needed with the augment_basis method.
Access the basis via the basis or Q attribute.
- A
Sparse matrix of shape (n, n)
- Type:
spmatrix
- X
Initial vector or matrix of shape (n, r)
- Type:
ndarray
- invA
Function that computes A^(-1) * v for a given vector/matrix v
- Type:
callable
- Q
Orthonormal basis of the inverted Krylov space
- Type:
ndarray
- basis
Pointer to Q
- Type:
ndarray
Examples
>>> import numpy as np >>> from scipy.sparse import csr_matrix >>> from low_rank_toolbox.krylov import InvertedKrylovSpace >>> # Create a sparse matrix >>> A = csr_matrix([[4, 1, 0], [1, 3, 1], [0, 1, 2]]) >>> X = np.array([[1.0], [0.0], [0.0]]) >>> # Build inverted Krylov space >>> IK = InvertedKrylovSpace(A, X) >>> # Start with A^(-1)*X >>> IK.Q.shape (3, 1) >>> # Augment with A^(-2)*X >>> IK.augment_basis() >>> IK.Q.shape (3, 2) >>> # Basis is orthonormal >>> np.allclose(IK.Q.T @ IK.Q, np.eye(2)) True