pub struct RsvdResult {
pub u: IdxTensor,
pub s: IdxTensor,
pub vh: IdxTensor,
pub singular_values: Vec<f64>,
pub timings: RsvdTimings,
}Expand description
Approximate SVD factors with directly contractible index identities.
Contract u, s, then vh to reconstruct the approximation. Unlike a
deterministic SVD, singular_values describes the projected matrix only.
§Examples
use rand::SeedableRng;
use rand_chacha::ChaCha8Rng;
use tensor4all_core::{randomized_svd, DynIndex, IdxTensor, RsvdOptions, TensorContractionLike};
let i = DynIndex::new_dyn(2);
let j = DynIndex::new_dyn(2);
let a = IdxTensor::from_dense(vec![i.clone(), j], vec![3., 0., 0., 0.])?;
let mut rng = ChaCha8Rng::seed_from_u64(11);
let result = randomized_svd(&a, &[i], &RsvdOptions::new(1), &mut rng)?;
let reconstructed = result.u.contract_pair(&result.s)?.contract_pair(&result.vh)?;
assert!(a.sub(&reconstructed)?.maxabs()? < 1e-12);Fields§
§u: IdxTensorOrthonormal left singular vectors with the original left indices.
s: IdxTensorSingular values as a diagonal tensor connecting the two factor bonds.
vh: IdxTensorConjugate-transposed right singular vectors and original right indices.
singular_values: Vec<f64>Retained singular values of Q† A, in nonincreasing order.
timings: RsvdTimingsMeasured cost attribution for this call; instrumentation is included.
Trait Implementations§
Source§impl Clone for RsvdResult
impl Clone for RsvdResult
Auto Trait Implementations§
impl !RefUnwindSafe for RsvdResult
impl !UnwindSafe for RsvdResult
impl Freeze for RsvdResult
impl Send for RsvdResult
impl Sync for RsvdResult
impl Unpin for RsvdResult
impl UnsafeUnpin for RsvdResult
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