Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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. hereOdin/core/math/linalg/general.odin
Line 633 in ad99d20
Because of this, I wanted to keep changes in these operations as minimal as possible. My approach was to rename
adjugate
tocofactor
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.