Skip to main content

SolverAlgorithm

Trait SolverAlgorithm 

Source
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§

Source

type State: SolverState

Solver-specific state type

Required Methods§

Source

fn initialize( &self, matrix: &dyn Matrix, b: &[Precision], options: &SolverOptions, ) -> Result<Self::State>

Initialize the solver state for a given problem.

Source

fn step(&self, state: &mut Self::State) -> Result<StepResult>

Perform a single iteration step.

Source

fn is_converged(&self, state: &Self::State) -> bool

Check if the current state meets convergence criteria.

Source

fn extract_solution(&self, state: &Self::State) -> Vec<Precision>

Extract the current solution from the state.

Source

fn update_rhs( &self, state: &mut Self::State, delta_b: &[(usize, Precision)], ) -> Result<()>

Update the right-hand side for incremental solving.

Source

fn algorithm_name(&self) -> &'static str

Get the algorithm name for identification.

Provided Methods§

Source

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".

Implementors§