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 */
}legacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr
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 implementMatVec<V>)V: Vector type (must be convertible from/toVec<T>)T: Scalar type (must implementKrystScalarwithReal = R)
Fields§
§pattern: SparsityPatternlegacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr
Sparsity pattern for the approximate inverse (manual or automatic)
tol: Rlegacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr
Tolerance for numerical operations (pivoting, etc.)
max_iter: usizelegacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr
Maximum number of outer iterations (not used in this basic SPAI)
nbsteps: usizelegacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr
Maximum number of improvement steps per row (not used in this basic SPAI)
max_size: usizelegacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr
Maximum size of working arrays (not used in this basic SPAI)
max_new: usizelegacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr
Maximum new fill per step (not used in this basic SPAI)
block_size: usizelegacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr
Block size for block SPAI (not implemented)
cache_size: usizelegacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr
Cache size hint (not implemented)
verbose: boollegacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr
Verbosity flag (print timing/stats)
sp: boollegacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr
Symmetric pattern flag (not implemented)
inv_rows: Vec<Vec<(usize, T)>>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>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>>>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>legacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr
Last structure id (for reuse decisions)
last_vid: Option<ValuesId>legacy ApproxInv is deprecated; migrate to approxinv_csr::SpaiCsr/FsaiCsr
Last values id
drop_tol: Rlegacy 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>,
impl<M, V, T> ApproxInv<M, V, T>where
T: KrystScalar<Real = R>,
Sourcepub 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
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
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>
impl<M, V, T> ApproxInv<M, V, T>
pub fn complex_setup_used_native(&self) -> bool
legacy ApproxInv is deprecated; use preconditioner::approxinv_csr (FsaiCsr/SpaiCsr) or PcType::ApproxInverse
complex only.pub fn complex_setup_fallback_reason(&self) -> Option<&str>
legacy ApproxInv is deprecated; use preconditioner::approxinv_csr (FsaiCsr/SpaiCsr) or PcType::ApproxInverse
complex only.Trait Implementations§
Source§impl<M> KPreconditioner for ApproxInv<M, Vec<f64>, f64>
Available on crate feature complex only.
impl<M> KPreconditioner for ApproxInv<M, Vec<f64>, f64>
complex only.type Scalar = Complex<f64>
Source§fn apply_s(
&self,
side: PcSide,
x: &[S],
y: &mut [S],
scratch: &mut BridgeScratch,
) -> Result<(), KError>
fn apply_s( &self, side: PcSide, x: &[S], y: &mut [S], scratch: &mut BridgeScratch, ) -> Result<(), KError>
Source§fn apply_op_s(
&self,
op: Op,
x: &[Self::Scalar],
y: &mut [Self::Scalar],
scratch: &mut BridgeScratch,
) -> Result<(), KError>
fn apply_op_s( &self, op: Op, x: &[Self::Scalar], y: &mut [Self::Scalar], scratch: &mut BridgeScratch, ) -> Result<(), KError>
Source§fn capabilities_s(&self) -> PcCaps
fn capabilities_s(&self) -> PcCaps
Source§fn apply_mut_s(
&mut self,
side: PcSide,
x: &[Self::Scalar],
y: &mut [Self::Scalar],
scratch: &mut BridgeScratch,
) -> Result<(), KError>
fn apply_mut_s( &mut self, side: PcSide, x: &[Self::Scalar], y: &mut [Self::Scalar], scratch: &mut BridgeScratch, ) -> Result<(), KError>
Source§fn on_restart_s(
&mut self,
outer_iter: usize,
residual_norm: <Self::Scalar as KrystScalar>::Real,
) -> Result<(), KError>
fn on_restart_s( &mut self, outer_iter: usize, residual_norm: <Self::Scalar as KrystScalar>::Real, ) -> Result<(), KError>
Source§impl<M> Preconditioner for ApproxInv<M, Vec<f64>, f64>
Available on crate feature complex only.
impl<M> Preconditioner for ApproxInv<M, Vec<f64>, f64>
complex only.Source§fn setup(&mut self, op: &dyn LinOp<S = S>) -> Result<(), KError>
fn setup(&mut self, op: &dyn LinOp<S = S>) -> Result<(), KError>
Source§fn apply(&self, _side: PcSide, x: &[S], y: &mut [S]) -> Result<(), KError>
fn apply(&self, _side: PcSide, x: &[S], y: &mut [S]) -> Result<(), KError>
M^{-op} to input vector, writing result to output slice. Read moreSource§fn dims(&self) -> (usize, usize)
fn dims(&self) -> (usize, usize)
(nrows, ncols) of the preconditioner application. Read moreSource§fn apply_op_inplace(&self, op: Op, y: &mut [S]) -> Result<(), KError>
fn apply_op_inplace(&self, op: Op, y: &mut [S]) -> Result<(), KError>
Source§fn capabilities(&self) -> PcCaps
fn capabilities(&self) -> PcCaps
Source§fn distributed_support(&self) -> PcDistributedSupport
fn distributed_support(&self) -> PcDistributedSupport
Source§fn apply_mut(
&mut self,
side: PcSide,
x: &[S],
y: &mut [S],
) -> Result<(), KError>
fn apply_mut( &mut self, side: PcSide, x: &[S], y: &mut [S], ) -> Result<(), KError>
Source§fn on_restart(
&mut self,
_outer_iter: usize,
_residual_norm: R,
) -> Result<(), KError>
fn on_restart( &mut self, _outer_iter: usize, _residual_norm: R, ) -> Result<(), KError>
Source§fn direct_solve(
&mut self,
_op: &dyn LinOp<S = S>,
_b: &[S],
_x: &mut [S],
) -> Result<(), KError>
fn direct_solve( &mut self, _op: &dyn LinOp<S = S>, _b: &[S], _x: &mut [S], ) -> Result<(), KError>
op * x = b directly using the preconditioner. Read moreSource§fn supports_numeric_update(&self) -> bool
fn supports_numeric_update(&self) -> bool
Source§fn update_numeric(&mut self, _a: &dyn LinOp<S = S>) -> Result<(), KError>
fn update_numeric(&mut self, _a: &dyn LinOp<S = S>) -> Result<(), KError>
Source§fn update_symbolic(&mut self, a: &dyn LinOp<S = S>) -> Result<(), KError>
fn update_symbolic(&mut self, a: &dyn LinOp<S = S>) -> Result<(), KError>
Source§fn required_format(&self) -> OpFormat
fn required_format(&self) -> OpFormat
Source§impl<M, V, T> Preconditioner<M, V> for ApproxInv<M, V, T>
impl<M, V, T> Preconditioner<M, V> for ApproxInv<M, V, T>
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>
impl<M, V, T> Sync for ApproxInv<M, V, T>
impl<M, V, T> Unpin for ApproxInv<M, V, T>
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<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
Source§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Source§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Source§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
Source§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
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
Source§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
Source§impl<T> ConvUtil for T
impl<T> ConvUtil for T
Source§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Source§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> FlexiblePreconditioner for Twhere
T: Preconditioner + ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> ShellContext for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.