pub struct BiCgStabOptions {
pub max_iter: usize,
pub rtol: f64,
pub atol: f64,
}Expand description
Convergence controls for bicgstab, which retains a fixed number of vectors.
Start with the defaults for double precision and use rtol = 1e-5 for
single precision.
§Examples
use tensor4all_core::{krylov::{bicgstab, BiCgStabOptions}, DynIndex, IdxTensor};
let i = DynIndex::new_dyn(2);
let b = IdxTensor::from_dense(vec![i.clone()], vec![1.0_f64, -2.0])?;
let x0 = IdxTensor::zeros::<f64>(vec![i])?;
let options = BiCgStabOptions { max_iter: 1, ..BiCgStabOptions::default() };
let result = bicgstab(|x: &IdxTensor| Ok(x.clone()), &b, &x0, &options)?;
assert_eq!(result.solution.to_vec::<f64>()?, vec![1.0, -2.0]);
assert_eq!(result.iterations, 1);Fields§
§max_iter: usizeMaximum BiCGSTAB cycles, including cycles restarted after residual
replacement. Default: 100. Zero checks the initial residual only.
rtol: f64Finite, nonnegative relative tolerance. Default: 1e-10.
The stopping threshold is max(atol, rtol * ||b||).
atol: f64Finite, nonnegative absolute tolerance. Default: 0.0.
Set a positive value for an absolute target with a tiny RHS.
Both tolerances zero require an exactly zero true residual.
Implementations§
Source§impl BiCgStabOptions
impl BiCgStabOptions
Sourcepub fn validate(&self) -> Result<(), KrylovError>
pub fn validate(&self) -> Result<(), KrylovError>
Validate finite, nonnegative static tolerances without applying an operator.
A zero iteration budget and zero tolerances are valid. The RHS-dependent stopping threshold is checked when solving.
§Errors
Returns KrylovError::InvalidOptions when a tolerance is negative or
non-finite.
§Examples
use tensor4all_core::krylov::{BiCgStabOptions, KrylovError};
let options = BiCgStabOptions { rtol: f64::NAN, ..Default::default() };
assert!(matches!(options.validate(), Err(KrylovError::InvalidOptions { .. })));
assert!(BiCgStabOptions::default().validate().is_ok());Trait Implementations§
Source§impl Clone for BiCgStabOptions
impl Clone for BiCgStabOptions
Source§impl Debug for BiCgStabOptions
impl Debug for BiCgStabOptions
Auto Trait Implementations§
impl Freeze for BiCgStabOptions
impl RefUnwindSafe for BiCgStabOptions
impl Send for BiCgStabOptions
impl Sync for BiCgStabOptions
impl Unpin for BiCgStabOptions
impl UnsafeUnpin for BiCgStabOptions
impl UnwindSafe for BiCgStabOptions
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
U: Sized,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
U: Sized,
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read moreSource§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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more