Skip to content

linalg svd unwrap issues #11

Open
Open
@ADMoreau

Description

@ADMoreau

Maybe this isn't the correct place to ask or maybe I just need a fresh pair of eyes but I'm having trouble using the ndarray-linalg svd function.

the following code throws and error at the unwrap()

    X : &ArrayBase<impl Data<Elem = f64>, Ix2>,
) -> Array2<f64> {
    let temp:Array2<f64> = X.to_owned().clone();
    let (u, s, v) = temp.svd(true, true).unwrap();

while the following does not

    x : &ArrayBase<impl Data<Elem = f64>, Ix2>,
    n_components : f64,
) -> Self {

    let (_n, _m) = x.dim();

    //calculate the array of columnar means
    let mean = x.mean_axis(Axis(0)).unwrap();

    // subtract means from X
    let h:Array2<f64> = Array2::ones((_n, _m));
    let temp:Array2<f64> = h * &mean;
    let b:Array2<f64> = x - &temp;

    // compute SVD
    let (u, sigma, v) = b.svd(true, true).unwrap();

any help would be appreciated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions