continuate.krylov¶
Krylov subspace methods
These methods are based on the Arnoldi process
where \(V_n\) denotes the basis of Krylov subspace, and \(H_n\) denotes the projected matrix with Hessenberg form.
-
continuate.krylov.arnoldi_common(A, r, krylov_tol=1e-09, **cfg)[source]¶ Support generator for Arnoldi process
Parameters: A : scipy.sparse.linalg.LinearOperator
*operator is needed.r : np.array
The base of Krylov subspace \(K = \left<r, Ar, A^2r, ...\right>\)
Yields: V : np.array (2d)
With shape \((N, n)\) (n starts with 2)
h : np.array (1d)
The last column of \(H_n\) with shape (n, )
-
continuate.krylov.default_options= {'krylov_maxiter': 100, 'krylov_tol': 1e-09}¶ default values of options
You can get these values through
continuate.get_default_options()Parameters: krylov_tol : float
Tolerrance of Krylov iteration
krylov_maxiter : float
Max iteration number of Krylov iteration
-
continuate.krylov.gmres(A, b, x0=None, krylov_tol=1e-09, krylov_maxiter=100, **cfg)[source]¶ Solve linear equations \(Ax=b\) by GMRES
Parameters: A : scipy.sparse.linalg.LinearOperator
*operator is needed.b : np.array
inhomogeneous term
x0 : np.array
Initial guess of linear problem
Returns: x : np.array
The solution
Examples
>>> from numpy.random import random >>> from scipy.sparse.linalg import aslinearoperator >>> A = aslinearoperator(random((5, 5))) >>> x = random(5) >>> b = A*x >>> ans = gmres(A, b) >>> np.allclose(ans, x) True
-
continuate.krylov.gmres_factorize(A, r, krylov_tol=1e-09, krylov_maxiter=100, **cfg)[source]¶ Execute a factorization \(AV = VQR\) to solve minimization problem \(|Ax-b| = |VQ(Ry-g)| = |Ry-g|\).
Parameters: A : scipy.sparse.linalg.LinearOperator
*operator is needed.b : np.array
inhomogeneous term
x0 : np.array
Initial guess of linear problem
Returns: V : np.array (2d)
The basis of Krylov subspace with shape \((N, n)\)
R : np.array (2d)
Projected, and QR-decomposed matrix \(AV = VQR\)
g : np.array (1d)
Q-rotated vector of \(b\)
Q : [np.array(2x2)]
Givens rotation matrix
Examples
>>> from numpy.random import random >>> from scipy.sparse.linalg import aslinearoperator
>>> A = aslinearoperator(random((5, 5))) >>> b = random(5) >>> V, R, g, Q = gmres_factorize(A, b) >>> V.shape, R.shape, g.shape ((5, 5), (5, 5), (5,))
>>> A = aslinearoperator(np.identity(5)) >>> V, R, g, Q = gmres_factorize(A, b) >>> V.shape, R.shape, g.shape ((5, 1), (1, 1), (1,))