pub struct CpDecomposition {
pub weights: Vec<f64>,
pub factors: Vec<Matrix>,
}Expand description
CP (CANDECOMP/PARAFAC) decomposition result.
Represents a tensor as a weighted sum of rank-one tensors:
X ≈ Σ_r λ_r · a_r^(1) ◦ a_r^(2) ◦ ... ◦ a_r^(N)
Fields§
§weights: Vec<f64>Weights (lambda) for each rank-one component.
factors: Vec<Matrix>Factor matrices, one per mode. Factor[n] is I_n × R.
Implementations§
Source§impl CpDecomposition
impl CpDecomposition
Sourcepub fn reconstruct(&self) -> SolverResult<Tensor>
pub fn reconstruct(&self) -> SolverResult<Tensor>
Reconstructs the full tensor from the CP factors.
Sourcepub fn fit_error(&self, original: &Tensor) -> SolverResult<f64>
pub fn fit_error(&self, original: &Tensor) -> SolverResult<f64>
Computes the relative fit error: ||X - X_hat|| / ||X||.
Trait Implementations§
Source§impl Clone for CpDecomposition
impl Clone for CpDecomposition
Source§fn clone(&self) -> CpDecomposition
fn clone(&self) -> CpDecomposition
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CpDecomposition
impl RefUnwindSafe for CpDecomposition
impl Send for CpDecomposition
impl Sync for CpDecomposition
impl Unpin for CpDecomposition
impl UnsafeUnpin for CpDecomposition
impl UnwindSafe for CpDecomposition
Blanket Implementations§
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
Mutably borrows from an owned value. Read more