Skip to content

Fixed pivot in QR decomposition#17

Merged
jordanmontt merged 6 commits intoPolyMathOrg:masterfrom
DurieuxPol:fix/qr
Apr 13, 2026
Merged

Fixed pivot in QR decomposition#17
jordanmontt merged 6 commits intoPolyMathOrg:masterfrom
DurieuxPol:fix/qr

Conversation

@DurieuxPol
Copy link
Copy Markdown
Contributor

The way pivot was handled didn't make much sense, so I reworked it a bit.
Now if you decompose a matrix m with pivot, you can reconstruct it with the permutation matrix:

m := PMMatrix rows: {
		     { 1. 2. 3 }.
		     { 4. 5. 6 }.
		     { 7. 8. 9 } }.
d := PMQRDecomposition of: m.
d decomposeWithPivot.
m closeTo: d q * d r * d permutationMatrixFromPivot inverse

The last line is equivalent to the equation M * P = Q * R.
I also removed the problematic test because it relied on the incorrect implementation of the pivot, and I added new tests instead.

@DurieuxPol DurieuxPol marked this pull request as draft April 8, 2026 08:30
@DurieuxPol DurieuxPol marked this pull request as ready for review April 8, 2026 08:44
@jordanmontt jordanmontt merged commit 0ea3cf0 into PolyMathOrg:master Apr 13, 2026
2 checks passed
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.

2 participants