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

Wrong answer in nc::linalg::inv #132

Closed
tatianyi opened this issue Feb 5, 2022 · 3 comments
Closed

Wrong answer in nc::linalg::inv #132

tatianyi opened this issue Feb 5, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@tatianyi
Copy link

tatianyi commented Feb 5, 2022

Describe the bug
The wrong result is obtained when calculating the inverse matrix.

To Reproduce
Steps to reproduce the behavior:

  1. Let m be a 2*2 specific matrix: nc::NdArray<int> m = { {0, 1}, {2, 3} };
  2. Let n be the inverse matrix of m: auto n = nc::linalg::inv(m);
  3. Output the matrix n: std::cout << n << std::endl;
  4. See error

Expected behavior
The correct answer of n should be: [ [-1.5, 0.5], [1, 0] ]

Screenshots
wa

The cause of the problem should be here:
bug
where t=0 (the first element in the matrix m)

Additional context
Test platform: Microsoft Visual Studio Community 2022 (x64) 17.0.5 Debug x64
defined the macro "NUMCPP_NO_USE_BOOST" at the very beginning.
ac
This problem does not recur in NumPy.

@dpilger26 dpilger26 self-assigned this Mar 7, 2022
@dpilger26 dpilger26 added the bug Something isn't working label Mar 7, 2022
@jpalves
Copy link

jpalves commented Jun 25, 2022

It's because pivoting is not implemented correctly, I have made my own inv and replace, take a look. https://github.com/jpalves/NumCpp-Base/blob/main/include/NumCpp/Linalg/inv.hpp

@dpilger26
Copy link
Owner

Fixed in Version 2.8.0 release. Thank you @jpalves.

@jpalves
Copy link

jpalves commented Jul 28, 2022

You are welcome dpilger26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants