Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

MagnitudeCorrection trait should be public #274

Open
relf opened this issue Apr 7, 2021 · 0 comments · May be fixed by #275
Open

MagnitudeCorrection trait should be public #274

relf opened this issue Apr 7, 2021 · 0 comments · May be fixed by #275

Comments

@relf
Copy link

relf commented Apr 7, 2021

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);
}
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant