ndarray icon indicating copy to clipboard operation
ndarray copied to clipboard

solve() seems missing in 0.16

Open PegasusPlusUS opened this issue 1 year ago • 0 comments
trafficstars

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]>>

PegasusPlusUS avatar Oct 22 '24 07:10 PegasusPlusUS