Linear solvers#
Warning
Some capabilities may require the installation of GEMSEO with all its features and some others may depend on plugins.
Warning
All the features of the wrapped libraries may not be exposed through GEMSEO.
Note
The algorithm settings can be passed to a function of the form
function(..., settings_model: AlgorithmSettings | None = None, **settings: Any)
either one by one:
function(..., setting_name_1=setting_name_1, setting_name_2=setting_name_2, ...)
or using the argument name "settings_model"
and the Pydantic model associated with the algorithm:
settings_model = AlgorithmSettings(setting_name_1=setting_name_1, setting_name_2=setting_name_2, ...)
function(..., settings_model=settings_model)
BICG#
Module: gemseo.algos.linear_solvers.scipy_linalg.scipy_linalg
BI-Conjugate Gradient
from gemseo.settings.linear_solvers import BICG_Settings
More details about the algorithm and its settings on https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.bicg.html.
- Optional settings
atol : <class 'float'>, optional
The absolute tolerance.
Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol).
By default it is set to 0.0.
callback : typing.Optional[typing.Annotated[collections.abc.Callable, WithJsonSchema(json_schema={}, mode=None)]], optional
The user-supplied function to call after each iteration.
It is called as callback(xk), where xk is the current solution vector. If
None
, no function is called.By default it is set to None.
M : scipy.sparse.linalg._interface.LinearOperator | numpy.ndarray | scipy.sparse._base.sparray | None, optional
The preconditioner approximating the inverse of A.
By default it is set to None.
maxiter : <class 'int'>, optional
Maximum number of iterations.
By default it is set to 1000.
rtol : <class 'float'>, optional
The relative tolerance.
Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol).
By default it is set to 1e-12.
save_when_fail : <class 'bool'>, optional
Whether to use an incomplete LU factorization as preconditioner.
By default it is set to False.
store_residuals : <class 'bool'>, optional
Whether to store the residual norms at each iterations.
By default it is set to False.
use_ilu_precond : <class 'bool'>, optional
Whether to use an incomplete LU factorization as preconditioner.
By default it is set to False.
x0 : numpy.ndarray | None, optional
Starting guess for the solution.
If
None
, start from a matrix of zeros.By default it is set to None.
BICGSTAB#
Module: gemseo.algos.linear_solvers.scipy_linalg.scipy_linalg
Bi-Conjugate Gradient STABilized
from gemseo.settings.linear_solvers import BICGSTAB_Settings
More details about the algorithm and its settings on https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.bicgstab.html.
- Optional settings
atol : <class 'float'>, optional
The absolute tolerance.
Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol).
By default it is set to 0.0.
callback : typing.Optional[typing.Annotated[collections.abc.Callable, WithJsonSchema(json_schema={}, mode=None)]], optional
The user-supplied function to call after each iteration.
It is called as callback(xk), where xk is the current solution vector. If
None
, no function is called.By default it is set to None.
M : scipy.sparse.linalg._interface.LinearOperator | numpy.ndarray | scipy.sparse._base.sparray | None, optional
The preconditioner approximating the inverse of A.
By default it is set to None.
maxiter : <class 'int'>, optional
Maximum number of iterations.
By default it is set to 1000.
rtol : <class 'float'>, optional
The relative tolerance.
Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol).
By default it is set to 1e-12.
save_when_fail : <class 'bool'>, optional
Whether to use an incomplete LU factorization as preconditioner.
By default it is set to False.
store_residuals : <class 'bool'>, optional
Whether to store the residual norms at each iterations.
By default it is set to False.
use_ilu_precond : <class 'bool'>, optional
Whether to use an incomplete LU factorization as preconditioner.
By default it is set to False.
x0 : numpy.ndarray | None, optional
Starting guess for the solution.
If
None
, start from a matrix of zeros.By default it is set to None.
CG#
Module: gemseo.algos.linear_solvers.scipy_linalg.scipy_linalg
Conjugate Gradient
from gemseo.settings.linear_solvers import CG_Settings
More details about the algorithm and its settings on https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.cg.html.
- Optional settings
atol : <class 'float'>, optional
The absolute tolerance.
Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol).
By default it is set to 0.0.
callback : typing.Optional[typing.Annotated[collections.abc.Callable, WithJsonSchema(json_schema={}, mode=None)]], optional
The user-supplied function to call after each iteration.
It is called as callback(xk), where xk is the current solution vector. If
None
, no function is called.By default it is set to None.
M : scipy.sparse.linalg._interface.LinearOperator | numpy.ndarray | scipy.sparse._base.sparray | None, optional
The preconditioner approximating the inverse of A.
By default it is set to None.
maxiter : <class 'int'>, optional
Maximum number of iterations.
By default it is set to 1000.
rtol : <class 'float'>, optional
The relative tolerance.
Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol).
By default it is set to 1e-12.
save_when_fail : <class 'bool'>, optional
Whether to use an incomplete LU factorization as preconditioner.
By default it is set to False.
store_residuals : <class 'bool'>, optional
Whether to store the residual norms at each iterations.
By default it is set to False.
use_ilu_precond : <class 'bool'>, optional
Whether to use an incomplete LU factorization as preconditioner.
By default it is set to False.
x0 : numpy.ndarray | None, optional
Starting guess for the solution.
If
None
, start from a matrix of zeros.By default it is set to None.
CGS#
Module: gemseo.algos.linear_solvers.scipy_linalg.scipy_linalg
Conjugate Gradient Squared
from gemseo.settings.linear_solvers import CGS_Settings
More details about the algorithm and its settings on https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.cgs.html.
- Optional settings
atol : <class 'float'>, optional
The absolute tolerance.
Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol).
By default it is set to 0.0.
callback : typing.Optional[typing.Annotated[collections.abc.Callable, WithJsonSchema(json_schema={}, mode=None)]], optional
The user-supplied function to call after each iteration.
It is called as callback(xk), where xk is the current solution vector. If
None
, no function is called.By default it is set to None.
M : scipy.sparse.linalg._interface.LinearOperator | numpy.ndarray | scipy.sparse._base.sparray | None, optional
The preconditioner approximating the inverse of A.
By default it is set to None.
maxiter : <class 'int'>, optional
Maximum number of iterations.
By default it is set to 1000.
rtol : <class 'float'>, optional
The relative tolerance.
Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol).
By default it is set to 1e-12.
save_when_fail : <class 'bool'>, optional
Whether to use an incomplete LU factorization as preconditioner.
By default it is set to False.
store_residuals : <class 'bool'>, optional
Whether to store the residual norms at each iterations.
By default it is set to False.
use_ilu_precond : <class 'bool'>, optional
Whether to use an incomplete LU factorization as preconditioner.
By default it is set to False.
x0 : numpy.ndarray | None, optional
Starting guess for the solution.
If
None
, start from a matrix of zeros.By default it is set to None.
DEFAULT#
Module: gemseo.algos.linear_solvers.scipy_linalg.scipy_linalg
Default solver (LGMRES)
from gemseo.settings.linear_solvers import LGMRES_Settings
More details about the algorithm and its settings on https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.lgmres.html.
- Optional settings
atol : <class 'float'>, optional
The absolute tolerance.
Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol).
By default it is set to 0.0.
callback : typing.Optional[typing.Annotated[collections.abc.Callable, WithJsonSchema(json_schema={}, mode=None)]], optional
The user-supplied function to call after each iteration.
It is called as callback(xk), where xk is the current solution vector. If
None
, no function is called.By default it is set to None.
inner_m : <class 'int'>, optional
Number of inner GMRES iterations per each outer iteration.
By default it is set to 30.
M : scipy.sparse.linalg._interface.LinearOperator | numpy.ndarray | scipy.sparse._base.sparray | None, optional
The preconditioner approximating the inverse of A.
By default it is set to None.
maxiter : <class 'int'>, optional
Maximum number of iterations.
By default it is set to 1000.
outer_k : <class 'int'>, optional
Number of vectors to carry between inner GMRES iterations.
By default it is set to 3.
outer_v : list[tuple[numpy.ndarray[typing.Any, numpy.dtype[numpy.number[typing.Any]]], numpy.ndarray[typing.Any, numpy.dtype[numpy.number[typing.Any]]]]], optional
List of tuples (v, Av) used to augment the Krylov subspace.
By default it is set to [].
prepend_outer_v : <class 'bool'>, optional
Whether to put outer_v augmentation vectors before Krylov iterates.
By default it is set to False.
rtol : <class 'float'>, optional
The relative tolerance.
Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol).
By default it is set to 1e-12.
save_when_fail : <class 'bool'>, optional
Whether to use an incomplete LU factorization as preconditioner.
By default it is set to False.
store_outer_Av : <class 'bool'>, optional
Whether A @ v should be additionnaly stored in outer_v list.
By default it is set to True.
store_residuals : <class 'bool'>, optional
Whether to store the residual norms at each iterations.
By default it is set to False.
use_ilu_precond : <class 'bool'>, optional
Whether to use an incomplete LU factorization as preconditioner.
By default it is set to False.
x0 : numpy.ndarray | None, optional
Starting guess for the solution.
If
None
, start from a matrix of zeros.By default it is set to None.
GCROT#
Module: gemseo.algos.linear_solvers.scipy_linalg.scipy_linalg
Generalized Conjugate Residual with Optimal Truncation
from gemseo.settings.linear_solvers import GCROT_Settings
More details about the algorithm and its settings on https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.gcrotmk.html.
- Optional settings
atol : <class 'float'>, optional
The absolute tolerance.
Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol).
By default it is set to 0.0.
callback : typing.Optional[typing.Annotated[collections.abc.Callable, WithJsonSchema(json_schema={}, mode=None)]], optional
The user-supplied function to call after each iteration.
It is called as callback(xk), where xk is the current solution vector. If
None
, no function is called.By default it is set to None.
CU : collections.abc.Iterable[tuple[numpy.ndarray[typing.Any, numpy.dtype[numpy.number[typing.Any]]], numpy.ndarray[typing.Any, numpy.dtype[numpy.number[typing.Any]]]]] | None, optional
List of tuples (c, u) required to form the matrices C and U.
If
None
start from empty matrices.By default it is set to None.
discard_C : <class 'bool'>, optional
Whether to discard the C-vectors at the end.
By default it is set to True.
k : <class 'int'>, optional
Number of vectors to carry between inner FGMRES iterations.
If
None
use the same value asm
.By default it is set to 30.
M : scipy.sparse.linalg._interface.LinearOperator | numpy.ndarray | scipy.sparse._base.sparray | None, optional
The preconditioner approximating the inverse of A.
By default it is set to None.
m : <class 'int'>, optional
Number of inner FGMRES iterations per each outer iteration.
By default it is set to 30.
maxiter : <class 'int'>, optional
Maximum number of iterations.
By default it is set to 1000.
rtol : <class 'float'>, optional
The relative tolerance.
Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol).
By default it is set to 1e-12.
save_when_fail : <class 'bool'>, optional
Whether to use an incomplete LU factorization as preconditioner.
By default it is set to False.
store_residuals : <class 'bool'>, optional
Whether to store the residual norms at each iterations.
By default it is set to False.
truncate : typing.Literal['oldest', 'smallest'], optional
The vectors from the previous cycle to drop.
By default it is set to oldest.
use_ilu_precond : <class 'bool'>, optional
Whether to use an incomplete LU factorization as preconditioner.
By default it is set to False.
x0 : numpy.ndarray | None, optional
Starting guess for the solution.
If
None
, start from a matrix of zeros.By default it is set to None.
GMRES#
Module: gemseo.algos.linear_solvers.scipy_linalg.scipy_linalg
Generalized Minimum RESidual
from gemseo.settings.linear_solvers import GMRES_Settings
More details about the algorithm and its settings on https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.gmres.html.
- Optional settings
atol : <class 'float'>, optional
The absolute tolerance.
Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol).
By default it is set to 0.0.
callback : typing.Optional[typing.Annotated[collections.abc.Callable, WithJsonSchema(json_schema={}, mode=None)]], optional
The user-supplied function to call after each iteration.
It is called as callback(xk), where xk is the current solution vector. If
None
, no function is called.By default it is set to None.
M : scipy.sparse.linalg._interface.LinearOperator | numpy.ndarray | scipy.sparse._base.sparray | None, optional
The preconditioner approximating the inverse of A.
By default it is set to None.
maxiter : <class 'int'>, optional
Maximum number of iterations.
By default it is set to 1000.
restart : <class 'int'>, optional
Number of iterations between restarts.
By default it is set to 20.
rtol : <class 'float'>, optional
The relative tolerance.
Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol).
By default it is set to 1e-12.
save_when_fail : <class 'bool'>, optional
Whether to use an incomplete LU factorization as preconditioner.
By default it is set to False.
store_residuals : <class 'bool'>, optional
Whether to store the residual norms at each iterations.
By default it is set to False.
use_ilu_precond : <class 'bool'>, optional
Whether to use an incomplete LU factorization as preconditioner.
By default it is set to False.
x0 : numpy.ndarray | None, optional
Starting guess for the solution.
If
None
, start from a matrix of zeros.By default it is set to None.
LGMRES#
Module: gemseo.algos.linear_solvers.scipy_linalg.scipy_linalg
Loose Generalized Minimum RESidual
from gemseo.settings.linear_solvers import LGMRES_Settings
More details about the algorithm and its settings on https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.lgmres.html.
- Optional settings
atol : <class 'float'>, optional
The absolute tolerance.
Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol).
By default it is set to 0.0.
callback : typing.Optional[typing.Annotated[collections.abc.Callable, WithJsonSchema(json_schema={}, mode=None)]], optional
The user-supplied function to call after each iteration.
It is called as callback(xk), where xk is the current solution vector. If
None
, no function is called.By default it is set to None.
inner_m : <class 'int'>, optional
Number of inner GMRES iterations per each outer iteration.
By default it is set to 30.
M : scipy.sparse.linalg._interface.LinearOperator | numpy.ndarray | scipy.sparse._base.sparray | None, optional
The preconditioner approximating the inverse of A.
By default it is set to None.
maxiter : <class 'int'>, optional
Maximum number of iterations.
By default it is set to 1000.
outer_k : <class 'int'>, optional
Number of vectors to carry between inner GMRES iterations.
By default it is set to 3.
outer_v : list[tuple[numpy.ndarray[typing.Any, numpy.dtype[numpy.number[typing.Any]]], numpy.ndarray[typing.Any, numpy.dtype[numpy.number[typing.Any]]]]], optional
List of tuples (v, Av) used to augment the Krylov subspace.
By default it is set to [].
prepend_outer_v : <class 'bool'>, optional
Whether to put outer_v augmentation vectors before Krylov iterates.
By default it is set to False.
rtol : <class 'float'>, optional
The relative tolerance.
Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol).
By default it is set to 1e-12.
save_when_fail : <class 'bool'>, optional
Whether to use an incomplete LU factorization as preconditioner.
By default it is set to False.
store_outer_Av : <class 'bool'>, optional
Whether A @ v should be additionnaly stored in outer_v list.
By default it is set to True.
store_residuals : <class 'bool'>, optional
Whether to store the residual norms at each iterations.
By default it is set to False.
use_ilu_precond : <class 'bool'>, optional
Whether to use an incomplete LU factorization as preconditioner.
By default it is set to False.
x0 : numpy.ndarray | None, optional
Starting guess for the solution.
If
None
, start from a matrix of zeros.By default it is set to None.
TFQMR#
Module: gemseo.algos.linear_solvers.scipy_linalg.scipy_linalg
Transpose-Free Quasi-Minimal Residual
from gemseo.settings.linear_solvers import BaseSciPyLinalgSettingsBase
More details about the algorithm and its settings on https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.tfqmr.html.
- Optional settings
atol : <class 'float'>, optional
The absolute tolerance.
Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol).
By default it is set to 0.0.
callback : typing.Optional[typing.Annotated[collections.abc.Callable, WithJsonSchema(json_schema={}, mode=None)]], optional
The user-supplied function to call after each iteration.
It is called as callback(xk), where xk is the current solution vector. If
None
, no function is called.By default it is set to None.
M : scipy.sparse.linalg._interface.LinearOperator | numpy.ndarray | scipy.sparse._base.sparray | None, optional
The preconditioner approximating the inverse of A.
By default it is set to None.
maxiter : <class 'int'>, optional
Maximum number of iterations.
By default it is set to 1000.
rtol : <class 'float'>, optional
The relative tolerance.
Algorithm stops if norm(b - A @ x) <= max(rtol*norm(b), atol).
By default it is set to 1e-12.
save_when_fail : <class 'bool'>, optional
Whether to use an incomplete LU factorization as preconditioner.
By default it is set to False.
store_residuals : <class 'bool'>, optional
Whether to store the residual norms at each iterations.
By default it is set to False.
use_ilu_precond : <class 'bool'>, optional
Whether to use an incomplete LU factorization as preconditioner.
By default it is set to False.
x0 : numpy.ndarray | None, optional
Starting guess for the solution.
If
None
, start from a matrix of zeros.By default it is set to None.