Skip to content

MagnitudeCorrection trait should be public #274

Open
@relf

Description

@relf

I tried to use TruncatedSvd with a generic Float type but it can not compile as it has to use the MagnitudeCorrection trait which is not exported from ndarray-linalg::lobpcg module. My test program here:

use ndarray::{arr1, arr2, Array1, Array2, ScalarOperand};
use ndarray_linalg::{close_l2, Lapack, TruncatedOrder, TruncatedSvd};  // should use MagnitudeCorrection as well
use num_traits::Float;

fn test_truncated_svd<F: Float + Lapack + ScalarOperand + Default>(  // should add MagnitudeCorrection trait bound
    a: Array2<F>,
) -> Array1<F> {
    let res = TruncatedSvd::new(a, TruncatedOrder::Largest)
        .precision(1e-5)
        .maxiter(10)
        .decompose(2)
        .unwrap();

    let (_, sigma, _) = res.values_vectors();
    sigma
}

fn main() {
    let a = arr2(&[[3., 2., 2.], [2., 3., -2.]]);

    let sigma = test_truncated_svd(a);

    close_l2(&sigma, &arr1(&[5.0, 3.0]), 1e-5);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @relf

      Issue actions

        MagnitudeCorrection trait should be public · Issue #274 · rust-ndarray/ndarray-linalg