pylops.optimization.cls_basic.CGยถ
- class pylops.optimization.cls_basic.CG(Op, callbacks=None)[source]ยถ
Conjugate gradient
Solve a square system of equations given an operator
Opand datayusing conjugate gradient iterations.- Parameters:
- Op
pylops.LinearOperator Operator to invert of size \([N \times N]\)
- Op
- Attributes:
- ncp
module Array module used by the solver (obtained via
pylops.utils.backend.get_array_module) ). Available only aftersetupis called.- isjax
bool True if the input data is a JAX array. Available only after
setupis called and updated at each call tostep.- r
numpy.ndarray Residual vector of size \([N \times 1]\). Available only after
setupis called and updated at each call tostep.- c
numpy.ndarray Conjugate direction vector of size \([N \times 1]\). Available only after
setupis called and updated at each call tostep.- c1
numpy.ndarray Pre-allocated vector of size \([N \times 1]\) used in the solver when
preallocate=True. Available only aftersetupis called and updated at each call tostep.- kold
float Squared norm of the residual at previous iteration. Available only after
setupis called and updated at each call tostep.- cost
list History of the L2 norm of the residual. Available only after
setupis called and updated at each call tostep.- iiter
int Current iteration number. Available only after
setupis called and updated at each call tostep.
- ncp
Notes
Solve the \(\mathbf{y} = \mathbf{Op}\,\mathbf{x}\) problem using conjugate gradient iterations [1].
[1]Hestenes, M R., Stiefel, E., โMethods of Conjugate Gradients for Solving Linear Systemsโ, Journal of Research of the National Bureau of Standards. vol. 49. 1952.
Methods
__init__(Op[, callbacks])callback(x, *args, **kwargs)Callback routine
finalize([show])Finalize solver
memory_usage([show, unit])Compute memory usage of the solver
run(x[, niter, show, itershow])Run solver
setup(y[, x0, niter, tol, preallocate, show])Setup solver
solve(y[, x0, niter, tol, preallocate, ...])Run entire solver
step(x[, show])Run one step of solver