MagnitudeCorrection trait should be public

Open
#274 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
42/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Stale
Tech stack
rust
Domain
backend

Research direction

Start at the public exports for the ndarray-linalg::lobpcg module and trace how MagnitudeCorrection is defined and used by TruncatedSvd. Reproduce the provided generic-Float example, then verify that the trait can be imported and used as a bound and that the example compiles.

Written by the indexing model from the issue text.

Description

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);
}
Dominant language
Rust
Stars
452
Forks
95
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-ndarray/ndarray-linalg

All issues in rust-ndarray/ndarray-linalg

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.