pub struct CgResult<T> {
pub solution: T,
pub iterations: usize,
pub residual_norm: f64,
pub converged: bool,
}Expand description
Solution and true-residual diagnostics returned by cg.
As with super::HermitianLanczosResult, residual_norm is an absolute
norm; super::GmresResult instead reports a relative norm by default.
§Examples
use tensor4all_core::{krylov::{cg, CgOptions}, DynIndex, IdxTensor, TensorIndex};
let b = IdxTensor::from_dense(vec![DynIndex::new_dyn(2)], vec![3.0_f64, -1.0])?;
let x0 = IdxTensor::zeros::<f64>(b.external_indices())?;
let result = cg(|x: &IdxTensor| Ok(x.clone()), &b, &x0, &CgOptions::default())?;
assert!(result.converged);
assert_eq!(result.solution.to_vec::<f64>()?, vec![3.0, -1.0]);
assert_eq!(result.residual_norm, 0.0);Fields§
§solution: TApproximate solution, including the initial guess’s contribution.
iterations: usizeNumber of completed CG steps, bounded by CgOptions::max_iter.
residual_norm: f64Absolute true residual norm ||b - A*x||, also on iteration exhaustion.
converged: boolWhether the true residual met max(atol, rtol * ||b||).
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for CgResult<T>where
T: Freeze,
impl<T> RefUnwindSafe for CgResult<T>where
T: RefUnwindSafe,
impl<T> Send for CgResult<T>where
T: Send,
impl<T> Sync for CgResult<T>where
T: Sync,
impl<T> Unpin for CgResult<T>where
T: Unpin,
impl<T> UnsafeUnpin for CgResult<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for CgResult<T>where
T: UnwindSafe,
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,
Casts
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
Mutably borrows from an owned value. Read more
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> ⓘ
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 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> ⓘ
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