pub struct ConjugateGradientSolver { /* private fields */ }Expand description
Conjugate Gradient solver for symmetric positive-definite sparse systems.
Stores the solver configuration (tolerance, iteration cap, preconditioning). The solve itself is stateless and may be invoked concurrently on different inputs from multiple threads.
Implementations§
Source§impl ConjugateGradientSolver
impl ConjugateGradientSolver
Sourcepub fn new(
tolerance: f64,
max_iterations: usize,
use_preconditioner: bool,
) -> Self
pub fn new( tolerance: f64, max_iterations: usize, use_preconditioner: bool, ) -> Self
Create a new CG solver.
§Arguments
tolerance– Relative residual threshold for convergence. Must be positive and finite.max_iterations– Upper bound on CG iterations. Must be >= 1.use_preconditioner– Enable diagonal (Jacobi) preconditioning.
Sourcepub fn max_iterations(&self) -> usize
pub fn max_iterations(&self) -> usize
Return the configured maximum iterations.
Sourcepub fn use_preconditioner(&self) -> bool
pub fn use_preconditioner(&self) -> bool
Return whether preconditioning is enabled.
Trait Implementations§
Source§impl Clone for ConjugateGradientSolver
impl Clone for ConjugateGradientSolver
Source§fn clone(&self) -> ConjugateGradientSolver
fn clone(&self) -> ConjugateGradientSolver
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConjugateGradientSolver
impl Debug for ConjugateGradientSolver
Source§impl SolverEngine for ConjugateGradientSolver
impl SolverEngine for ConjugateGradientSolver
Source§fn solve(
&self,
matrix: &CsrMatrix<f64>,
rhs: &[f64],
budget: &ComputeBudget,
) -> Result<SolverResult, SolverError>
fn solve( &self, matrix: &CsrMatrix<f64>, rhs: &[f64], budget: &ComputeBudget, ) -> Result<SolverResult, SolverError>
Solve Ax = b using the Conjugate Gradient method.
§Errors
SolverError::InvalidInput– dimension mismatch or invalid params.SolverError::NumericalInstability– divergence or non-SPD matrix.SolverError::NonConvergence– iteration limit exceeded.SolverError::BudgetExhausted– wall-time limit exceeded.
Source§fn estimate_complexity(
&self,
profile: &SparsityProfile,
n: usize,
) -> ComplexityEstimate
fn estimate_complexity( &self, profile: &SparsityProfile, n: usize, ) -> ComplexityEstimate
Estimate CG complexity from the sparsity profile.
CG converges in O(sqrt(kappa)) iterations, each costing O(nnz) for
the SpMV plus O(n) for the vector updates.
Auto Trait Implementations§
impl Freeze for ConjugateGradientSolver
impl RefUnwindSafe for ConjugateGradientSolver
impl Send for ConjugateGradientSolver
impl Sync for ConjugateGradientSolver
impl Unpin for ConjugateGradientSolver
impl UnsafeUnpin for ConjugateGradientSolver
impl UnwindSafe for ConjugateGradientSolver
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more