-
Notifications
You must be signed in to change notification settings - Fork 191
linalg: Matrix Inverse #828
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
Merged
Merged
Changes from 29 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
f39bf52
add source file
perazz c0da712
working implementation
perazz 92b1ac5
reorganize as `submodule`
perazz e9a3f5b
add tests
perazz b233156
option for pre-allocated pivot indices
perazz dc0127b
add examples
perazz 75a5a23
document `.inv.A`
perazz bf0dfd3
document `invert`
perazz db90b37
document `inv`
perazz 6a1c397
typo
perazz e10e4c4
test for singular matrix; activate `complex` matrix tests
perazz db714bb
Merge branch 'master' into matrix_inverse
perazz 5f320f9
subroutine version, non in-place
perazz 47ee61a
test subroutine version, non in-place
perazz e2159bc
`.inv.` operator: `error stop` on issues
perazz b23c811
Merge branch 'master' into matrix_inverse
perazz 8b138f7
add non-in-place subroutine example
perazz 513d77b
rename example programs
perazz 5d7d7ba
Update doc/specs/stdlib_linalg.md
perazz 63006d2
Update doc/specs/stdlib_linalg.md
perazz 41f502e
Update doc/specs/stdlib_linalg.md
perazz 860cbb0
Update doc/specs/stdlib_linalg.md
perazz 80a7742
new test: random SPD matrix (real, complex)
perazz 3c0bcdb
Update doc/specs/stdlib_linalg.md
perazz 505f30a
lwork: overflow-safer evaluation
perazz d0af9be
`operator(.inv.)`: return `NaN`s on exceptions
perazz 40062c4
Merge branch 'matrix_inverse' of github.com:perazz/stdlib into matrix…
perazz 406e170
typo: set complex NaN
perazz 3e7c82e
lstsq: explain singular values better
perazz a292e9d
Update stdlib_linalg.md
perazz 8b52b1a
Merge branch 'master' into matrix_inverse
perazz 7386d2d
Update src/stdlib_linalg.fypp
perazz 35efbe8
Merge branch 'fortran-lang:master' into matrix_inverse
perazz bb3f7e4
remove `xdp` restriction
perazz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
! Matrix inversion example: function interface | ||
program example_inverse_function | ||
use stdlib_linalg_constants, only: dp | ||
use stdlib_linalg, only: inv,eye | ||
implicit none | ||
|
||
real(dp) :: A(2,2), Am1(2,2) | ||
|
||
! Input matrix (NB Fortran is column major! input columns then transpose) | ||
A = transpose(reshape( [4, 3, & | ||
3, 2], [2,2] )) | ||
|
||
! Invert matrix | ||
Am1 = inv(A) | ||
|
||
print *, ' |',Am1(1,:),'|' ! | -2 3 | | ||
print *, ' inv(A)= |',Am1(2,:),'|' ! | 3 -4 | | ||
|
||
! Final check | ||
print *, 'CHECK passed? ',matmul(A,Am1)==eye(2) | ||
|
||
end program example_inverse_function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
! Matrix inversion example: in-place inversion | ||
program example_inverse_inplace | ||
use stdlib_linalg_constants, only: dp | ||
use stdlib_linalg, only: invert,eye | ||
implicit none | ||
|
||
real(dp) :: A(2,2), Am1(2,2) | ||
|
||
! Input matrix (NB Fortran is column major! input columns then transpose) | ||
A = transpose(reshape( [4, 3, & | ||
3, 2], [2,2] )) | ||
Am1 = A | ||
|
||
! Invert matrix | ||
call invert(Am1) | ||
|
||
print *, ' |',Am1(1,:),'|' ! | -2 3 | | ||
print *, ' inv(A)= |',Am1(2,:),'|' ! | 3 -4 | | ||
|
||
! Final check | ||
print *, 'CHECK passed? ',matmul(A,Am1)==eye(2) | ||
|
||
end program example_inverse_inplace |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
! Matrix inversion example: operator interface | ||
program example_inverse_operator | ||
use stdlib_linalg_constants, only: dp | ||
use stdlib_linalg, only: operator(.inv.),eye | ||
implicit none | ||
|
||
real(dp) :: A(2,2), Am1(2,2) | ||
|
||
! Input matrix (NB Fortran is column major! input columns then transpose) | ||
A = transpose(reshape( [4, 3, & | ||
3, 2], [2,2] )) | ||
|
||
! Invert matrix | ||
Am1 = .inv.A | ||
|
||
print *, ' |',Am1(1,:),'|' ! | -2 3 | | ||
print *, ' inv(A)= |',Am1(2,:),'|' ! | 3 -4 | | ||
|
||
! Final check | ||
print *, 'CHECK passed? ',matmul(A,Am1)==eye(2) | ||
|
||
end program example_inverse_operator |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
! Matrix inversion example: subroutine interface | ||
program example_inverse_subroutine | ||
use stdlib_linalg_constants, only: dp | ||
use stdlib_linalg, only: invert,eye | ||
implicit none | ||
|
||
real(dp) :: A(2,2), Am1(2,2) | ||
|
||
! Input matrix (NB Fortran is column major! input columns then transpose) | ||
A = transpose(reshape( [4, 3, & | ||
3, 2], [2,2] )) | ||
|
||
! Invert matrix | ||
call invert(A,Am1) | ||
|
||
print *, ' |',Am1(1,:),'|' ! | -2 3 | | ||
print *, ' inv(A)= |',Am1(2,:),'|' ! | 3 -4 | | ||
|
||
! Final check | ||
print *, 'CHECK passed? ',matmul(A,Am1)==eye(2) | ||
|
||
end program example_inverse_subroutine |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.