pub trait SolverAlgorithm: Send + Sync {
type State: SolverState;
// Required methods
fn initialize(
&self,
matrix: &dyn Matrix,
b: &[Precision],
options: &SolverOptions,
) -> Result<Self::State>;
fn step(&self, state: &mut Self::State) -> Result<StepResult>;
fn is_converged(&self, state: &Self::State) -> bool;
fn extract_solution(&self, state: &Self::State) -> Vec<Precision> ⓘ;
fn update_rhs(
&self,
state: &mut Self::State,
delta_b: &[(usize, Precision)],
) -> Result<()>;
fn algorithm_name(&self) -> &'static str;
// Provided method
fn solve(
&self,
matrix: &dyn Matrix,
b: &[Precision],
options: &SolverOptions,
) -> Result<SolverResult> { ... }
}Expand description
Core trait for all solver algorithms.
This trait defines the interface that all sublinear-time solvers must implement, providing both batch and streaming solution capabilities.
Required Associated Types§
Sourcetype State: SolverState
type State: SolverState
Solver-specific state type
Required Methods§
Sourcefn initialize(
&self,
matrix: &dyn Matrix,
b: &[Precision],
options: &SolverOptions,
) -> Result<Self::State>
fn initialize( &self, matrix: &dyn Matrix, b: &[Precision], options: &SolverOptions, ) -> Result<Self::State>
Initialize the solver state for a given problem.
Sourcefn step(&self, state: &mut Self::State) -> Result<StepResult>
fn step(&self, state: &mut Self::State) -> Result<StepResult>
Perform a single iteration step.
Sourcefn is_converged(&self, state: &Self::State) -> bool
fn is_converged(&self, state: &Self::State) -> bool
Check if the current state meets convergence criteria.
Sourcefn extract_solution(&self, state: &Self::State) -> Vec<Precision> ⓘ
fn extract_solution(&self, state: &Self::State) -> Vec<Precision> ⓘ
Extract the current solution from the state.
Sourcefn update_rhs(
&self,
state: &mut Self::State,
delta_b: &[(usize, Precision)],
) -> Result<()>
fn update_rhs( &self, state: &mut Self::State, delta_b: &[(usize, Precision)], ) -> Result<()>
Update the right-hand side for incremental solving.
Sourcefn algorithm_name(&self) -> &'static str
fn algorithm_name(&self) -> &'static str
Get the algorithm name for identification.
Provided Methods§
Sourcefn solve(
&self,
matrix: &dyn Matrix,
b: &[Precision],
options: &SolverOptions,
) -> Result<SolverResult>
fn solve( &self, matrix: &dyn Matrix, b: &[Precision], options: &SolverOptions, ) -> Result<SolverResult>
Solve the linear system Ax = b.
This is the main interface for solving linear systems. It handles the iteration loop and convergence checking automatically.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".