Skip to main content

Module factorize

Module factorize 

Source
Expand description

Unified tensor factorization module.

This module provides a unified factorize() function that dispatches to SVD, QR, LU, or CI (Cross Interpolation) algorithms based on options.

§Note

This module works with concrete types (DynIndex, IdxTensor) only. Generic tensor types are not supported.

§Example

use tensor4all_core::{factorize, Canonical, DynIndex, FactorizeOptions, IdxTensor, TensorLike};

let i = DynIndex::new_dyn(2);
let j = DynIndex::new_dyn(2);
let tensor = IdxTensor::from_dense(
    vec![i.clone(), j.clone()],
    vec![1.0, 0.0, 0.0, 1.0],
)?;
let result = factorize(
    &tensor,
    std::slice::from_ref(&i),
    &FactorizeOptions::svd().with_canonical(Canonical::Left),
)?;

assert_eq!(result.rank, 2);
assert_eq!(result.left.dims(), vec![2, 2]);

Re-exports§

pub use crate::tensor_like::Canonical;
pub use crate::tensor_like::FactorizeAlg;
pub use crate::tensor_like::FactorizeError;
pub use crate::tensor_like::FactorizeOptions;
pub use crate::tensor_like::FactorizeResult;

Functions§

factorize
Factorize a tensor into left and right factors.
factorize_full_rank
Factorize a tensor without applying algorithm-specific truncation options.
factorize_full_rank_in
Full-rank factorization in a caller-owned execution context.
factorize_in
Factorize a tensor in a caller-owned execution context.