Skip to main content

ApproxInv

Struct ApproxInv 

Source
pub struct ApproxInv<M, V, T> {
Show 16 fields pub pattern: SparsityPattern, pub tol: R, pub max_iter: usize, pub nbsteps: usize, pub max_size: usize, pub max_new: usize, pub block_size: usize, pub cache_size: usize, pub verbose: bool, pub sp: bool, pub inv_rows: Vec<Vec<(usize, T)>>, pub a: Option<M>, pub csr: Option<Arc<CsrMatrix<T>>>, pub last_sid: Option<StructureId>, pub last_vid: Option<ValuesId>, pub drop_tol: R, /* private fields */
}
👎Deprecated since 0.1.0:

legacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr

Available on crate feature backend-faer only.
Expand description

Sparse Approximate Inverse (SPAI) preconditioner

This struct stores the parameters and computed data for the SPAI preconditioner. The main field is inv_rows, which stores the sparse rows of the approximate inverse.

§Type Parameters

  • M: Matrix type (must implement MatVec<V>)
  • V: Vector type (must be convertible from/to Vec<T>)
  • T: Scalar type (must implement KrystScalar with Real = R)

Fields§

§pattern: SparsityPattern
👎Deprecated since 0.1.0:

legacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr

Sparsity pattern for the approximate inverse (manual or automatic)

§tol: R
👎Deprecated since 0.1.0:

legacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr

Tolerance for numerical operations (pivoting, etc.)

§max_iter: usize
👎Deprecated since 0.1.0:

legacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr

Maximum number of outer iterations (not used in this basic SPAI)

§nbsteps: usize
👎Deprecated since 0.1.0:

legacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr

Maximum number of improvement steps per row (not used in this basic SPAI)

§max_size: usize
👎Deprecated since 0.1.0:

legacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr

Maximum size of working arrays (not used in this basic SPAI)

§max_new: usize
👎Deprecated since 0.1.0:

legacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr

Maximum new fill per step (not used in this basic SPAI)

§block_size: usize
👎Deprecated since 0.1.0:

legacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr

Block size for block SPAI (not implemented)

§cache_size: usize
👎Deprecated since 0.1.0:

legacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr

Cache size hint (not implemented)

§verbose: bool
👎Deprecated since 0.1.0:

legacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr

Verbosity flag (print timing/stats)

§sp: bool
👎Deprecated since 0.1.0:

legacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr

Symmetric pattern flag (not implemented)

§inv_rows: Vec<Vec<(usize, T)>>
👎Deprecated since 0.1.0:

legacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr

Inverse rows: for each row i, a vector of (column, value) pairs (CSR-like storage)

§a: Option<M>
👎Deprecated since 0.1.0:

legacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr

Optionally stores the matrix A (not used in this implementation)

§csr: Option<Arc<CsrMatrix<T>>>
👎Deprecated since 0.1.0:

legacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr

Cached CSR view of the last operator (if setup via LinOp)

§last_sid: Option<StructureId>
👎Deprecated since 0.1.0:

legacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr

Last structure id (for reuse decisions)

§last_vid: Option<ValuesId>
👎Deprecated since 0.1.0:

legacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr

Last values id

§drop_tol: R
👎Deprecated since 0.1.0:

legacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr

Drop tolerance used when converting dense->CSR in setup

Implementations§

Source§

impl<M, V, T> ApproxInv<M, V, T>
where T: KrystScalar<Real = R>,

Source

pub fn new( pattern: SparsityPattern, tol: R, max_iter: usize, nbsteps: usize, max_size: usize, max_new: usize, block_size: usize, cache_size: usize, verbose: bool, sp: bool, ) -> Self

👎Deprecated since 0.1.0:

legacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr

Create a new SPAI preconditioner with the given parameters.

Most parameters are for future extensions; only pattern and tol are essential.

Source§

impl<M, V, T> ApproxInv<M, V, T>

Source

pub fn complex_setup_used_native(&self) -> bool

👎Deprecated since 0.1.0:

legacy ApproxInv is deprecated; use preconditioner::approxinv_csr (FsaiCsr/SpaiCsr) or PcType::ApproxInverse

Available on crate feature complex only.
Source

pub fn complex_setup_fallback_reason(&self) -> Option<&str>

👎Deprecated since 0.1.0:

legacy ApproxInv is deprecated; use preconditioner::approxinv_csr (FsaiCsr/SpaiCsr) or PcType::ApproxInverse

Available on crate feature complex only.

Trait Implementations§

Source§

impl<M> KPreconditioner for ApproxInv<M, Vec<f64>, f64>
where M: MatVec<Vec<f64>> + Send + Sync + 'static,

Available on crate feature complex only.
Source§

type Scalar = Complex<f64>

Source§

fn dims(&self) -> (usize, usize)

Dimensions of the preconditioner, typically (n, n).
Source§

fn apply_s( &self, side: PcSide, x: &[S], y: &mut [S], scratch: &mut BridgeScratch, ) -> Result<(), KError>

Apply the preconditioner.
Source§

fn apply_op_s( &self, op: Op, x: &[Self::Scalar], y: &mut [Self::Scalar], scratch: &mut BridgeScratch, ) -> Result<(), KError>

Apply a selected matrix operation through the preconditioner.
Source§

fn capabilities_s(&self) -> PcCaps

Capabilities exposed by the wrapped preconditioner.
Source§

fn apply_mut_s( &mut self, side: PcSide, x: &[Self::Scalar], y: &mut [Self::Scalar], scratch: &mut BridgeScratch, ) -> Result<(), KError>

Apply the preconditioner in a mutable/flexible mode. Read more
Source§

fn on_restart_s( &mut self, outer_iter: usize, residual_norm: <Self::Scalar as KrystScalar>::Real, ) -> Result<(), KError>

Optional hook invoked at solver restarts.
Source§

impl<M> Preconditioner for ApproxInv<M, Vec<f64>, f64>
where M: MatVec<Vec<f64>> + 'static + Send + Sync,

Available on crate feature complex only.
Source§

fn setup(&mut self, op: &dyn LinOp<S = S>) -> Result<(), KError>

Build any factorization/hierarchy once from the system matrix.
Source§

fn apply(&self, _side: PcSide, x: &[S], y: &mut [S]) -> Result<(), KError>

Apply M^{-op} to input vector, writing result to output slice. Read more
Source§

fn dims(&self) -> (usize, usize)

Dimensions (nrows, ncols) of the preconditioner application. Read more
Source§

fn apply_op(&self, op: Op, x: &[S], y: &mut [S]) -> Result<(), KError>

Apply M^{-op} where the operation (op) specifies transpose handling. Read more
Source§

fn apply_op_inplace(&self, op: Op, y: &mut [S]) -> Result<(), KError>

Convenience helper for in-place application (y := M^{-op} y). Read more
Source§

fn capabilities(&self) -> PcCaps

Capabilities advertised by this preconditioner.
Source§

fn distributed_support(&self) -> PcDistributedSupport

Report whether the preconditioner is distributed-aware under MPI.
Source§

fn apply_mut( &mut self, side: PcSide, x: &[S], y: &mut [S], ) -> Result<(), KError>

Mutable application (flexible/nonlinear preconditioners). Read more
Source§

fn on_restart( &mut self, _outer_iter: usize, _residual_norm: R, ) -> Result<(), KError>

Optional hook called at solver restarts (e.g., by FGMRES). Read more
Source§

fn direct_solve( &mut self, _op: &dyn LinOp<S = S>, _b: &[S], _x: &mut [S], ) -> Result<(), KError>

Attempt to solve op * x = b directly using the preconditioner. Read more
Source§

fn supports_numeric_update(&self) -> bool

True if we can keep the symbolic structure and only refresh numeric values.
Source§

fn update_numeric(&mut self, _a: &dyn LinOp<S = S>) -> Result<(), KError>

Pattern unchanged: re-use hierarchy/structure, BUT refresh all numeric data.
Source§

fn update_symbolic(&mut self, a: &dyn LinOp<S = S>) -> Result<(), KError>

Pattern may have changed: rebuild structure (potentially expensive).
Source§

fn required_format(&self) -> OpFormat

Preferred matrix format for setup/update_* calls. Read more
Source§

fn preferred_drop_tol_for_format(&self) -> Option<R>

Optional numerical drop tolerance to use when creating the preferred format. Read more
Source§

impl<M, V, T> Preconditioner<M, V> for ApproxInv<M, V, T>
where M: MatVec<V> + 'static + Sync, V: From<Vec<T>> + AsRef<[T]> + AsMut<[T]> + Clone + Sync, T: KrystScalar<Real = R> + 'static + Send + Sync,

Source§

fn setup(&mut self, a: &M) -> Result<(), KError>

Setup the SPAI preconditioner by computing the approximate inverse rows.

For each column j, solves $A m_j \approx e_j$ with the given sparsity pattern. Uses LU or QR from faer for f64, otherwise falls back to normal equations.

Source§

fn apply(&self, _side: PcSide, x: &V, y: &mut V) -> Result<(), KError>

Apply the SPAI preconditioner to a vector x, storing the result in y.

Computes y = Mx, where M is the approximate inverse (stored in sparse row format).

Auto Trait Implementations§

§

impl<M, V, T> Freeze for ApproxInv<M, V, T>
where M: Freeze,

§

impl<M, V, T> RefUnwindSafe for ApproxInv<M, V, T>

§

impl<M, V, T> Send for ApproxInv<M, V, T>
where M: Send, V: Send, T: Sync + Send,

§

impl<M, V, T> Sync for ApproxInv<M, V, T>
where M: Sync, V: Sync, T: Sync + Send,

§

impl<M, V, T> Unpin for ApproxInv<M, V, T>
where M: Unpin, V: Unpin, T: Unpin,

§

impl<M, V, T> UnsafeUnpin for ApproxInv<M, V, T>
where M: UnsafeUnpin,

§

impl<M, V, T> UnwindSafe for ApproxInv<M, V, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src
where Scheme: ApproxScheme,

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>

Convert the given value into an approximately equivalent representation.
Source§

impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src
where Dst: ApproxFrom<Src, Scheme>, Scheme: ApproxScheme,

Source§

type Err = <Dst as ApproxFrom<Src, Scheme>>::Err

The error type produced by a failed conversion.
Source§

fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>

Convert the subject into an approximately equivalent representation.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T, Dst> ConvAsUtil<Dst> for T

Source§

fn approx(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject with the default scheme.
Source§

fn approx_by<Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject with a specific scheme.
Source§

impl<T> ConvUtil for T

Source§

fn approx_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject to a given type with the default scheme.
Source§

fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject to a given type with a specific scheme.
Source§

fn into_as<Dst>(self) -> Dst
where Self: Sized + Into<Dst>,

Convert the subject to a given type.
Source§

fn try_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + TryInto<Dst>,

Attempt to convert the subject to a given type.
Source§

fn value_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ValueInto<Dst>,

Attempt a value conversion of the subject to a given type.
Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> FlexiblePreconditioner for T
where T: Preconditioner + ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ShellContext for T
where T: Send + Sync + Any,

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

unsafe fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<Src> TryFrom<Src> for Src

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn try_from(src: Src) -> Result<Src, <Src as TryFrom<Src>>::Err>

Convert the given value into the subject type.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<Src, Dst> TryInto<Dst> for Src
where Dst: TryFrom<Src>,

Source§

type Err = <Dst as TryFrom<Src>>::Err

The error type produced by a failed conversion.
Source§

fn try_into(self) -> Result<Dst, <Src as TryInto<Dst>>::Err>

Convert the subject into the destination type.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<Src> ValueFrom<Src> for Src

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>

Convert the given value into an exactly equivalent representation.
Source§

impl<Src, Dst> ValueInto<Dst> for Src
where Dst: ValueFrom<Src>,

Source§

type Err = <Dst as ValueFrom<Src>>::Err

The error type produced by a failed conversion.
Source§

fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>

Convert the subject into an exactly equivalent representation.