Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

solve() seems missing in 0.16 #1444

Closed
PegasusPlusUS opened this issue Oct 22, 2024 · 3 comments
Closed

solve() seems missing in 0.16 #1444

PegasusPlusUS opened this issue Oct 22, 2024 · 3 comments

Comments

@PegasusPlusUS
Copy link

PegasusPlusUS commented Oct 22, 2024

My simple program main.rs try to resolve linear equations:

use ndarray::prelude::*;
use ndarray_linalg::*;

fn main() {
    let a: Array2<f64> = array![[3.0, 2.0], [1.0, 2.0]];
    let b: Array1<f64> = array![5.0, 5.0];
    let x = a.solve(&b).unwrap();  // Solve the system A * x = B
    println!("Solution: {:?}", x);
}

It works when I use ndarray 0.15 and ndarry_linalg 0.15:

[package]
name = "solve"
version = "0.1.0"
edition = "2021"

[dependencies]
ndarray = "0.15"  # Or whichever version you're using
ndarray-linalg = { version = "0.15", features = ["openblas-system"] }
pkg-config = "0.3"

When I try to use recent ndarray version 0.16, main.rs can't compile:
error[E0599]: no method named solve found for struct ArrayBase in the current scope
--> src/main.rs:7:15
|
7 | let x = a.solve(&b).unwrap(); // Solve the system A * x = B
| ^^^^^ method not found in ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>

@akern40
Copy link
Collaborator

akern40 commented Oct 23, 2024

Unfortunately this is a version mismatch between ndarray and ndarray-linalg; you cannot use ndarray version 0.16 with ndarray-linag until linalg bumps its dependencies. See this issue on ndarray-linalg for more, and this issue on the maintainership discussion there.

@akern40 akern40 closed this as completed Oct 23, 2024
@PegasusPlusUS
Copy link
Author

Thanks for answering. Before committing this issue, I also tried using both "0.16" version of ndarray_linalg and ndarray together, the same compiler error, so I guess there's some interface changing that break old examples (ChatGPT told me the simple solve sample)

@akern40
Copy link
Collaborator

akern40 commented Oct 23, 2024

Ya it's because of the minor version change between 0.15 and 0.16, I believe. You can read more here about Rust's dependency resolution between versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants