Skip to content

Unable to import traits implementation from ndarray #230

Open
@Riotpiaole

Description

@Riotpiaole

Question

  • Hi I run in a problem related with LeastSquare: I am trying to import the ndarray_linalg:: {LeastSquaresSvd, LeastSquaresSvdInto, LeastSquaresSvdInPlace} . And calling from ndarray::Array1::least_squares class.
    • However the rust compiler unable to import it.

Cargo setup

  • The OS environment is running in WSL2 in windows 10
#Cargo.toml

...
[dependencies]
openblas-src = { version = "*", features = ["static"] }
ndarray = "0.12"
ndarray-linalg = { version = "0.12.0", features = ["openblas"] }
ndarray-stats = "0.3"
...
  • code snippets to
// mod.rs 
extern crate ndarray_linalg;
extern crate ndarray;
extern crate openblas_src;
pub mod foo.
...

// foo.rs
use ndarray
use ndarray_linalg::{LeastSquaresSvd, LeastSquaresSvdInto, LeastSquaresSvdInPlace};
let a= array![
            [1., 1., 1.],
            [2., 3., 4.],
            [3., 5., 2.],
            [4., 2., 5.],
            [5., 4., 3.]
        ];
 // solving for a single right-hand 
let b = array![-10., 12., 14., 16., 18.];
// let res = a.least_squares(&b);

// using `least_squares_in_place` which overwrites its arguments
// let mut a_3 = a.clone();
// let mut b_3 = b.clone();
let (m, n) = (a.shape()[0], a.shape()[1]);
let solution = b.slice(s![0..n]).to_owned();
let result = a.least_squares(&b); // unable to find  least_squares 
...
  • The error outputs
  --> keyboard-analyzer/src/models/structural_break_analysis/chow.rs:19:22
   |
19 | use ndarray_linalg::{LeastSquaresSvd, LeastSquaresSvdInto, LeastSquaresSvdInPlace};
 ....

method not found in `ndarray::ArrayBase<models::structural_break_analysis::ndarray::OwnedRepr<{float}>, 
   models::structural_break_analysis::ndarray::Dim<[usize; 2]>>`

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions