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

Fix matrix adjugate #4633

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

spahnke
Copy link
Contributor

@spahnke spahnke commented Dec 28, 2024

Fixes #4584

The adjugate procedure was used in quite a lot of places and especially was used to calculate some inverses and determinants. These were correct before, because the adjugate entries were accessed in a transposed manner on-the-fly. See e.g. here

y[i, j] = a[j, i] / d

Because of this, I wanted to keep changes in these operations as minimal as possible. My approach was to rename adjugate to cofactor because before it calculated basically the cofactor matrix, and then reintroduce the adjugate. I couldn't find any uses outside the linalg package and added regression tests for both the issue and basic regression tests for the inverse and inverse transpose.

Please let me know if you want any changes and double check my math. Please also let me know if there is an easier/builtin way to check "equality" of float matrices.

The 3x3 test matrix is from https://en.wikipedia.org/wiki/Adjugate_matrix#3_%C3%97_3_numeric_matrix, the 2x2 and 4x4 are derived from that. The inverses were calculated by Wolfram Alpha.

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

Successfully merging this pull request may close these issues.

Matrix adjugate operations return transposed result
1 participant