Linear Algebra API#
Linear algebra routines operate on SpaceCore spaces and operators. Preconditions are mathematical: square, Hermitian, positive-definite, and residual statements refer to the domain and codomain inner products, not only coordinate arrays.
Linear solves#
Solve \(A x = b\) by conjugate gradients. |
|
Store the result returned by |
cgsolvesA x = bfor Hermitian positive-definiteA : X -> Xwith residuals measured inX.norm.CGResultstoresx, convergence flag, iteration count, residual norm, and status details.
Least squares#
Solve \(\min_x \|A x - b\|\) by LSQR. |
|
Store the result returned by |
lsqrsolves least-squares problems forA : X -> YusingX.innerandY.inner.LSQRResultstores the solution, convergence data, and residual diagnostics.
Eigenvalue and spectral methods#
Approximate the smallest eigenpair of a Hermitian operator. |
|
Estimate the dominant eigenpair of a self-adjoint action. |
|
Store the result returned by |
|
Store the result returned by |
lanczos_smallestapproximates the smallest eigenpair of a HermitianA : X -> X.power_iterationestimates the dominant eigenpair of a self-adjoint action or quadratic-form Hessian.
Matrix functions#
Compute \(\exp(t A) v\) by Krylov projection. |
|
Store the result returned by |
expm_multiplyapproximatesexp(t A) vfor square HermitianA : X -> Xusing Krylov projection.
Autodoc#
- spacecore.linalg.cg(A, b, *, x0=None, tol=1e-06, atol=0.0, maxiter=None, check_every=64)[source]#
Solve \(A x = b\) by conjugate gradients.
Require
Ato be square in the SpaceCore sense (A.domain == A.codomain), Hermitian, and positive-definite with respect toA.domain.inner. The implementation uses onlyLinOp.apply()and the domain-space inner product; it never materializes a dense matrix.- Parameters:
A (LinOp) – Linear operator that must be Hermitian positive-definite with respect to
A.domain.inner.A.domainmust equalA.codomain, including the underlying space type and inner-product geometry. An operator that is provably non-self-adjoint in this geometry (A.is_hermitian() is False) is rejected at entry with aValueError. Operators whose Hermiticity is unknown (A.is_hermitian() is None, e.g. matrix-free operators) are accepted unchecked; positive-definiteness is likewise not validated, so indefinite or otherwise unsuitable operators can still diverge or produce NaN outputs without an explicit error.b (array-like) – Right-hand side in
A.codomain.x0 (array-like or None, optional) – Initial guess in
A.domain. Default is the zero vector.tol (float, optional) – Relative tolerance on the linear-system residual.
result.convergedisTruewhen the residual norm is belowatol + tol * norm(b). Default is 1e-6.atol (float, optional) – Absolute residual tolerance. Default is 0.0.
maxiter (int or None, optional) – Maximum number of iterations. Default is
prod(A.domain.shape).check_every (int, optional) – Refresh convergence diagnostics every this many iterations and always on the final iteration. Default is
DEFAULT_CONVERGENCE_CHECK_INTERVAL.
- Returns:
Named tuple with fields:
x: approximate solution inA.domainconverged: whether the requested tolerance was metnum_iters: number of iterations executedresidual_norm: final residual norm
- Return type:
- Raises:
TypeError – If
Ais not aLinOp.ValueError – If
Ais not square or if iteration parameters are invalid.
See also
lsqrSolve least-squares systems for rectangular operators.
lanczos_smallestApproximate the smallest eigenpair of a Hermitian operator.
Notes
The residual norm is compared with \(\text{atol} + \text{tol} \| b \|\) only every
check_everyiterations, and always on the final iteration. This keeps convergence checks out of the hot loop while remaining compatible with JAX JIT control flow.maxiterandcheck_everyshould be treated as static JAX arguments.Iteration also stops when no numerically useful CG update remains: either the squared residual is at machine-precision scale or the curvature
inner(p, A p)is nonpositive/tiny relative to the residual scale. The residual is refreshed before this early exit, soconvergedstill reflects the returned iterate.For complex operators, residual norms and step sizes are computed from the real part of
A.domain.inner(x, y). SpaceCore’s complex inner-product convention conjugates the first argument; customSpacesubclasses must follow that convention for CG to converge correctly.Inner products and norms use
A.domain.innerandA.domain.norm. The method is correct on non-Euclidean geometries when the space supplies Riesz maps andAis Hermitian positive-definite in that geometry.References
Hestenes, M. R. and Stiefel, E., “Methods of Conjugate Gradients for Solving Linear Systems,” J. Res. Natl. Bur. Stand., 49 (1952), 409-436.
Examples
Solve a small positive-definite system.
>>> import numpy as np >>> import spacecore as sc >>> ctx = sc.Context(sc.NumpyOps(), dtype=np.float64) >>> X = sc.DenseCoordinateSpace((3,), ctx) >>> M = ctx.asarray([[4.0, 1.0, 0.0], [1.0, 3.0, 1.0], [0.0, 1.0, 2.0]]) >>> A = sc.DenseLinOp(M, X, X, ctx) >>> b = ctx.asarray([1.0, 2.0, 3.0]) >>> result = sc.cg(A, b, tol=1e-10) >>> bool(result.converged) True >>> np.allclose(A.apply(result.x), b) True
- class spacecore.linalg.CGResult(x, converged, num_iters, residual_norm)[source]#
Bases:
NamedTupleStore the result returned by
cg().- Parameters:
x (array-like) – Approximate solution in
A.domain.converged (bool-like) – Whether the final residual norm satisfied the requested tolerance.
num_iters (int-like) – Number of conjugate-gradient iterations executed.
residual_norm (scalar) – Norm of the final residual in
A.codomain.
- x: Any#
Alias for field number 0
- converged: Any#
Alias for field number 1
- num_iters: Any#
Alias for field number 2
- residual_norm: Any#
Alias for field number 3
- count(value, /)#
Return number of occurrences of value.
- index(value, start=0, stop=sys.maxsize, /)#
Return first index of value.
Raises ValueError if the value is not present.
- spacecore.linalg.lsqr(A, b, *, x0=None, tol=1e-06, atol=0.0, maxiter=None, check_every=64, residual_mode='exact')[source]#
Solve \(\min_x \|A x - b\|\) by LSQR.
Allow
Ato map between distinctdomainandcodomainspaces. The method usesLinOp.apply()for forward products andA.H.applyfor adjoint products, so the normal equations are represented implicitly and no dense matrix is formed.- Parameters:
A (LinOp) – Linear operator with possibly distinct
domainandcodomain. For squareA(A.domain == A.codomain),cg()is usually preferred whenAis also Hermitian positive-definite.b (array-like) – Right-hand side in
A.codomain.x0 (array-like or None, optional) – Initial guess in
A.domain. Default is the zero vector.tol (float, optional) – Relative tolerance for the normal-equation residual
norm(A.H @ (A @ x - b)).result.convergedisTruewhen that residual is belowatol + tol * norm(b). Default is 1e-6.atol (float, optional) – Absolute tolerance for the normal-equation residual. Default is 0.0.
maxiter (int or None, optional) – Maximum number of iterations. Default is
prod(A.domain.shape).check_every (int, optional) – Refresh residual diagnostics every this many iterations and always on the final iteration. Default is
DEFAULT_CONVERGENCE_CHECK_INTERVAL.residual_mode ({"exact", "recurrence"}, optional) – Residual diagnostic mode.
"exact"preserves the historical behavior: every diagnostic refresh recomputesA @ x - bandA.H @ (A @ x - b). This costs one additional forward application and one additional adjoint application on each check iteration, so smallcheck_everyvalues, especiallycheck_every=1, can substantially increase runtime for expensive operators. Use larger values such ascheck_every=10orcheck_every=20when exact diagnostics are needed for matrix-free, PDE, neural-network, GPU, or JAX workloads."recurrence"uses LSQR scalar recurrences for both returned residual diagnostics and avoids those extra applications.
- Returns:
Named tuple with fields:
x: approximate least-squares solution inA.domainconverged: whether the requested tolerance was metnum_iters: number of iterations executedresidual_norm: final residual norm or recurrence estimatenormal_residual_norm: final normal-equation residual norm or recurrence estimate
- Return type:
- Raises:
TypeError – If
Ais not aLinOp.ValueError – If iteration parameters are invalid or
residual_modeis unknown.
See also
cgSolve square Hermitian positive-definite systems.
power_iterationEstimate a dominant eigenpair.
Notes
Convergence is tested using \(\|A^*(A x - b)\| < \text{atol} + \text{tol}\|b\|\). In
residual_mode="exact", exact residual diagnostics are refreshed only everycheck_everyiterations, and always on the final iteration. Each refresh performs one additional forward product and one additional adjoint product beyond the LSQR recurrence itself.In
residual_mode="recurrence",residual_normis the standard LSQR estimateabs(phi_bar)andnormal_residual_normis the LSQR scalar estimatealpha * abs(tau)withtau = s * phi. These estimates avoid extra operator applications during checks, including the final check. This function is JIT-compatible on the JAX backend whenmaxiter,check_every, andresidual_modeare static arguments.The normal-equation residual can be much smaller than the solution error for ill-conditioned
A. For ill-conditioned problems, use a tightertolor check the residual and solution quality directly.Works on real and complex operators. For complex operators,
A.Huses the conjugate adjoint.Inner products and norms use
A.domain.inner/A.domain.normfor domain-space quantities andA.codomain.normfor least-squares residuals. The method is therefore correct on non-Euclidean geometries when the spaces provide Riesz maps andA.rapplyis the true metric adjoint.References
Paige, C. C. and Saunders, M. A., “LSQR: An Algorithm for Sparse Linear Equations and Sparse Least Squares,” ACM Trans. Math. Soft., 8 (1982), 43-71.
Examples
Solve a small overdetermined least-squares problem.
>>> import numpy as np >>> import spacecore as sc >>> ctx = sc.Context(sc.NumpyOps(), dtype=np.float64) >>> X = sc.DenseCoordinateSpace((2,), ctx) >>> Y = sc.DenseCoordinateSpace((3,), ctx) >>> M = ctx.asarray([[1.0, 0.0], [0.0, 1.0], [1.0, 1.0]]) >>> A = sc.DenseLinOp(M, X, Y, ctx) >>> b = ctx.asarray([1.0, 2.0, 3.0]) >>> result = sc.lsqr(A, b, tol=1e-10) >>> np.allclose(result.x, [1.0, 2.0]) True
- class spacecore.linalg.LSQRResult(x, converged, num_iters, residual_norm, normal_residual_norm)[source]#
Bases:
NamedTupleStore the result returned by
lsqr().- Parameters:
x (array-like) – Approximate least-squares solution in
A.domain.converged (bool-like) – Whether the normal-equation residual satisfied the requested tolerance.
num_iters (int-like) – Number of LSQR iterations executed.
residual_norm (scalar) – Norm of
A x - binA.codomainin exact mode, or the LSQR recurrence estimate in recurrence mode.normal_residual_norm (scalar) – Norm of
A.H @ (A x - b)inA.domainin exact mode, or the LSQR recurrence estimate in recurrence mode.
- x: Any#
Alias for field number 0
- converged: Any#
Alias for field number 1
- num_iters: Any#
Alias for field number 2
- residual_norm: Any#
Alias for field number 3
- normal_residual_norm: Any#
Alias for field number 4
- count(value, /)#
Return number of occurrences of value.
- index(value, start=0, stop=sys.maxsize, /)#
Return first index of value.
Raises ValueError if the value is not present.
- spacecore.linalg.lanczos_smallest(A, initial_vector, *, max_iter=100, tol=1e-06, check_every=64)[source]#
Approximate the smallest eigenpair of a Hermitian operator.
The operator is supplied as a square
LinOpin the SpaceCore sense (A.domain == A.codomain), andinitial_vectoris an element ofA.domain. The implementation keeps fixed-size coordinate arrays for JAX compatibility, safely handles zero initial vectors, and refines the returned eigenvalue with the Rayleigh quotient of the reconstructed Ritz vector in the original space.Mathematically, Lanczos builds an orthonormal Krylov basis
Vforspan{v, A v, A^2 v, ...}and a tridiagonal projection \(T_k = V^* A V\). The returned vector is the Ritz vector reconstructed in the original coordinates, and the returned scalar is the Rayleigh quotient \(\langle x, A x \rangle_X / \langle x, x \rangle_X\).- Parameters:
A (LinOp) – Linear operator that must be Hermitian/self-adjoint with respect to
A.domain.inner.A.domainmust equalA.codomain, including the underlying space type and inner-product geometry. Operators with structurally unknown Hermiticity (A.is_hermitian()returnsNone) are accepted on trust; the caller is responsible for ensuring Hermiticity. Non-Hermitian inputs produce undefined results.initial_vector (array-like) – Starting vector in
A.domain. If it is numerically zero, the algorithm falls back to a deterministic coordinate vector.max_iter (int, optional) – Maximum Krylov dimension. Must be a Python
intrather than a traced JAX scalar; underjax.jitit is treated as a static argument and changing it triggers retracing. Default is 100.tol (float, optional) – Tolerance used for two purposes. Iteration stops at a check point when the off-diagonal Lanczos coefficient falls below
tol; the returnedconvergedflag isTruewhen the Ritz residual estimate is belowtol. Default is 1e-6.check_every (int, optional) – Refresh the breakdown-based stopping decision every this many iterations and always on the final iteration. Default is
DEFAULT_CONVERGENCE_CHECK_INTERVAL.
- Returns:
Named tuple with fields:
eigenvalue: smallest Ritz eigenvalue estimateeigenvector: associated Ritz vector inA.domainresidual_norm: standard Ritz residual estimatekrylov_dim: actual Krylov dimension reachedconverged: whetherresidual_norm < tol
- Return type:
- Raises:
TypeError – If
Ais not aLinOp.ValueError – If
Ais not square, is known to be non-Hermitian, or ifmax_iteris invalid.
See also
power_iterationEstimate the dominant eigenpair.
expm_multiplyApply a matrix exponential using the Lanczos basis.
Notes
The residual estimate is computed from the tridiagonal recurrence as \(\beta_m |y_{m-1}|\). Callers that need the true residual can evaluate
A.apply(eigenvector) - eigenvalue * eigenvectoronce more in the original space.The “smallest Ritz value” is the smallest eigenvalue of the projected tridiagonal matrix, not necessarily a good approximation of the smallest eigenvalue of
A. Convergence to the actual smallest eigenvalue requires the bottom of the spectrum to be separated and the initial vector to have nonzero projection onto the corresponding eigenspace. For clustered low eigenvalues, increasemax_iteror use multiple initial vectors.Hermiticity is enforced only when it can be structurally verified: known non-Hermitian operators raise
ValueError. Operators with unknown structure, such as many matrix-free operators and operators on custom spaces, are trusted.This function is JIT-compatible on the JAX backend when
max_iterandcheck_everyare static arguments. For plainVectorSpacedomains, Euclidean reorthogonalization is vectorized; custom spaces useSpace.inner()to preserve the declared geometry.Inner products and norms use
A.domain.innerandA.domain.norm. The method is correct on non-Euclidean geometries when the space supplies Riesz maps andAis self-adjoint in that geometry.References
Lanczos, C., “An Iteration Method for the Solution of the Eigenvalue Problem of Linear Differential and Integral Operators,” J. Res. Natl. Bur. Stand., 45 (1950), 255-282.
Examples
Approximate the smallest eigenpair of a diagonal operator.
>>> import numpy as np >>> import spacecore as sc >>> ctx = sc.Context(sc.NumpyOps(), dtype=np.float64) >>> X = sc.DenseCoordinateSpace((3,), ctx) >>> A = sc.DiagonalLinOp(ctx.asarray([1.0, 2.0, 4.0]), X, ctx) >>> result = sc.lanczos_smallest(A, ctx.asarray([1.0, 1.0, 1.0]), max_iter=3) >>> np.allclose(result.eigenvalue, 1.0) True
- class spacecore.linalg.LanczosResult(eigenvalue, eigenvector, residual_norm, krylov_dim, converged)[source]#
Bases:
NamedTupleStore the result returned by
lanczos_smallest().- Parameters:
eigenvalue (scalar) – Ritz approximation to the smallest eigenvalue.
eigenvector (array-like) – Ritz vector in
A.domain.residual_norm (scalar) – Standard Ritz residual estimate.
krylov_dim (int-like) – Krylov dimension reached before breakdown or
max_iter.converged (bool-like) – Whether
residual_norm < tol.
- eigenvalue: Any#
Alias for field number 0
- eigenvector: Any#
Alias for field number 1
- residual_norm: Any#
Alias for field number 2
- krylov_dim: Any#
Alias for field number 3
- converged: Any#
Alias for field number 4
- count(value, /)#
Return number of occurrences of value.
- index(value, start=0, stop=sys.maxsize, /)#
Return first index of value.
Raises ValueError if the value is not present.
- spacecore.linalg.power_iteration(A, *, x0=None, tol=1e-06, maxiter=None, check_every=64)[source]#
Estimate the dominant eigenpair of a self-adjoint action.
Accept a square
LinOpor aQuadraticFormexposinghess_apply. Public dispatch converts either input into a fixed self-adjoint action before entering the numerical loop. Power iteration still requireshess_applyfor quadratic forms because the vector update isx_next = normalize(H x). Optional two-sided scalar diagnostics such ashess_quad(x, Hx=None)can improve Rayleigh quotient evaluation, but they cannot replace the Hessian-vector action. “Dominant” means largest eigenvalue in absolute value, not necessarily the largest positive eigenvalue.- Parameters:
A (LinOp or QuadraticForm) – Square operator or quadratic form whose dominant eigenpair, largest in absolute value, is sought. Linear-operator inputs must satisfy
A.domain == A.codomain; this includes the underlying space type and inner-product geometry. Quadratic-form inputs must providehess_apply. If they also exposehess_quad(x, Hx=None), it is used for the Rayleigh quotient and must be compatible with being called ashess_quad(x, Hx=Hx). TheHxargument is the cached Hessian-vector product already computed by power iteration. If the quadratic form exposeshess_residual_norm(x, Hx, eigenvalue), it is used for the residual diagnostic. Otherwise generic space inner-product and norm diagnostics are used. For spectral-norm estimates of a rectangular operator, passA.H @ A.x0 (array-like or None, optional) – Initial vector in the action domain. Default is a normalized all-ones vector in the domain geometry.
tol (float, optional) – Residual-norm tolerance.
result.convergedisTruewhennorm(A @ x - lambda * x) < tol. Default is 1e-6.maxiter (int or None, optional) – Maximum number of iterations. Default is
prod(A.domain.shape).check_every (int, optional) – Accepted for backward compatibility. Residual diagnostics are now refreshed every iteration because the loop already carries
A @ x; this argument is ignored and may be removed in a future release.
- Returns:
Named tuple with fields:
eigenvalue: Rayleigh-quotient eigenvalue estimateeigenvector: normalized eigenvector estimateconverged: whetherresidual_norm < tolnum_iters: number of iterations executedresidual_norm: norm ofA x - eigenvalue * x
- Return type:
- Raises:
TypeError – If
Ais neither aLinOpnor aQuadraticForm.ValueError – If a linear-operator input is not square, is known to be non-Hermitian, or if iteration parameters are invalid.
See also
lanczos_smallestApproximate the smallest eigenpair of a Hermitian operator.
cgSolve Hermitian positive-definite systems.
Notes
The residual-based stopping criterion uses \(\|A x - \lambda x\|\) and is refreshed every iteration. The
check_everyargument is accepted for backward compatibility but is no longer used. This function is JIT-compatible on the JAX backend whenmaxiteris static.Inner products and norms use
domain.inneranddomain.normthrough the normalized self-adjoint action. The method is correct on non-Euclidean geometries when the space supplies Riesz maps and the action is self-adjoint in that geometry.For operators with eigenvalues of mixed sign, the dominant eigenvalue is the one with largest absolute value, which may be negative. Convergence requires that this eigenvalue be separated from the rest in absolute value. If the dominant modulus is degenerate, for example both
lambdaand-lambdahave maximum modulus, the iteration may oscillate between subspaces.For most dense vector-space problems, the generic Rayleigh quotient
real(inner(x, Hx))is already cheap. Specialized quadratic-form scalar diagnostics are mainly useful when a subclass can evaluate<x, Hx>or the residual norm more accurately or with less overhead than reconstructing the scalar from generic space operations. A specializedhess_quadmust accept the cached Hessian-vector product ashess_quad(x, Hx=Hx); implementations may ignoreHxor use it to avoid recomputation.Examples
Estimate the largest eigenvalue of a diagonal operator.
>>> import numpy as np >>> import spacecore as sc >>> ctx = sc.Context(sc.NumpyOps(), dtype=np.float64) >>> X = sc.DenseCoordinateSpace((3,), ctx) >>> A = sc.DiagonalLinOp(ctx.asarray([1.0, 3.0, 2.0]), X, ctx) >>> result = sc.power_iteration(A, maxiter=20, tol=1e-10) >>> np.allclose(result.eigenvalue, 3.0) True
- class spacecore.linalg.PowerIterationResult(eigenvalue, eigenvector, converged, num_iters, residual_norm)[source]#
Bases:
NamedTupleStore the result returned by
power_iteration().- Parameters:
eigenvalue (scalar) – Rayleigh-quotient estimate of the dominant eigenvalue.
eigenvector (array-like) – Normalized eigenvector estimate in the operator domain.
converged (bool-like) – Whether the residual norm satisfied
tol.num_iters (int-like) – Number of power iterations executed.
residual_norm (scalar) – Norm of
A x - eigenvalue * x.
- eigenvalue: Any#
Alias for field number 0
- eigenvector: Any#
Alias for field number 1
- converged: Any#
Alias for field number 2
- num_iters: Any#
Alias for field number 3
- residual_norm: Any#
Alias for field number 4
- count(value, /)#
Return number of occurrences of value.
- index(value, start=0, stop=sys.maxsize, /)#
Return first index of value.
Raises ValueError if the value is not present.
- spacecore.linalg.expm_multiply(A, v, t=1.0, *, max_iter=30, tol=1e-10)[source]#
Compute \(\exp(t A) v\) by Krylov projection.
Require
Ato be square in the SpaceCore sense (A.domain == A.codomain) and Hermitian with respect toA.domain.inner. The method builds a Lanczos basis and applies the exponential of the small tridiagonal projection, avoiding dense materialization ofA.- Parameters:
A (LinOp) – Linear operator that must be Hermitian/self-adjoint with respect to
A.domain.inner.A.domainmust equalA.codomain, including the underlying space type and inner-product geometry. Operators with structurally unknown Hermiticity (A.is_hermitian()returnsNone) are accepted on trust; the caller is responsible for ensuring Hermiticity. Non-Hermitian inputs produce undefined results.v (array-like) – Initial vector in
A.domain.t (float or complex, optional) – Scalar multiplier on
A. Complex values require a complex-valuedctx.dtypesuch ascomplex64orcomplex128. Using a complextwith a real-valued context produces backend-dependent results. Default is 1.0.max_iter (int, optional) – Maximum Krylov dimension. Values around 20-50 are usually sufficient when \(|t|\|A\|\) is moderate. Must be a Python
intrather than a traced JAX scalar; underjax.jitit is treated as a static argument and changing it triggers retracing. Default is 30.tol (float, optional) – Tolerance used both for Lanczos breakdown and for the convergence flag:
result.convergedisTruewhen the projected exponential residual estimate is belowtol. Default is 1e-10.
- Returns:
Result vector in
A.domain, the Krylov dimension used, the standard estimateabs(beta[m] * phi[m - 1]), and a convergence flag.- Return type:
- Raises:
TypeError – If
Ais not aLinOp.ValueError – If
Ais not square, is known to be non-Hermitian, or ifmax_iteris invalid.
See also
lanczos_smallestBuild the related Hermitian Krylov projection.
power_iterationEstimate a dominant eigenpair.
Notes
The projected exponential is computed as \(\exp(t T) e_0\) using an eigendecomposition of the small real symmetric tridiagonal matrix
T. This is JIT-compatible on the JAX backend whenmax_iteris static.Hermiticity is enforced only when it can be structurally verified: known non-Hermitian operators raise
ValueError. Operators with unknown structure, such as many matrix-free operators and operators on custom spaces, are trusted.The returned residual estimate is \(|\beta_m \phi_{m-1}|\), where
phiis the projected exponential vector. Callers that need the true residual can perform one additional operator application.Examples
Apply the exponential of a diagonal operator.
>>> import numpy as np >>> import spacecore as sc >>> ctx = sc.Context(sc.NumpyOps(), dtype=np.float64) >>> X = sc.DenseCoordinateSpace((2,), ctx) >>> A = sc.DiagonalLinOp(ctx.asarray([0.0, 1.0]), X, ctx) >>> v = ctx.asarray([2.0, 3.0]) >>> result = sc.expm_multiply(A, v, t=0.5, max_iter=5) >>> np.allclose(result.result, [2.0, 3.0 * np.exp(0.5)], atol=1e-10) True
- class spacecore.linalg.ExpmMultiplyResult(result, krylov_dim, residual_estimate, converged)[source]#
Bases:
NamedTupleStore the result returned by
expm_multiply().- Parameters:
result (array-like) – Vector in the domain of the input operator approximating
exp(t * A) @ v.krylov_dim (int-like) – Actual Krylov dimension reached before breakdown or
max_iter.residual_estimate (scalar) – Projected exponential residual estimate
abs(beta[m] * phi[m - 1]).converged (bool-like) – Boolean indicating whether
residual_estimate < tol.
- result: Any#
Alias for field number 0
- krylov_dim: Any#
Alias for field number 1
- residual_estimate: Any#
Alias for field number 2
- converged: Any#
Alias for field number 3
- count(value, /)#
Return number of occurrences of value.
- index(value, start=0, stop=sys.maxsize, /)#
Return first index of value.
Raises ValueError if the value is not present.