Skip to content

Unexpected output when using linalg.inv with OpenBLAS backend #123

@glynos

Description

@glynos

When I run the following code:

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

#[test]
fn inv_test() {
    let a: Array2<f64> = array!([1.0, 2.0], [3.0, 4.0]);
    let a_inv = a.inv().unwrap();
    assert!(a_inv.all_close(&array!([-2.0, 1.0], [1.5, -0.5]), 1e-5));
}

it produces the following output (running the command cargo test --features=openblas:

thread 'tests::inv_test' panicked at 'assertion failed: a_inv.all_close(&array!([ - 2.0 , 1.0 ] , [ 1.5 , - 0.5 ]), 1e-5)', src/main.rs:355:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

The value of a_inv is vec![2, -1, -0.5, 0.5]

I would expect the value to be the same as the example using the equivalent using numpy:

>>> from numpy.linalg import inv
>>> a = np.array([[1., 2.], [3., 4.]])
>>> ainv = inv(np.matrix(a))
>>> ainv
matrix([[-2. ,  1. ],
        [ 1.5, -0.5]])

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug issue, or bug fix changehelp wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions