-
Notifications
You must be signed in to change notification settings - Fork 191
linalg: Schur decomposition #892
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 all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
0222737
implement Schur
perazz 04d843f
handle `*GEES` output
perazz 908cab1
process `*GEES` tasks
perazz dc81688
workspace query `schur_space`
perazz 81e5583
schur: simplify interface, do not allocate where possible
perazz 95a4900
`overwrite_a` option
perazz ead68dd
fix, export interface
perazz 0551a66
add examples
perazz 14f771b
fix: only return eigenvalues if present
perazz 80a1df1
add tests
perazz 99ca106
documentation
perazz ec3c6c3
docs: `Z` is an optional argument
perazz 0ee05fc
make storage `intent(out)`
perazz 19e2ede
Update doc/specs/stdlib_linalg.md
perazz 21fa91f
tidy up complex example
perazz 7d8ca7d
tidy up eigenvalues example
perazz d594573
tidy up schur real example
perazz 8caa4dc
remove `goto`s
perazz 170ed54
fix interface
perazz e5c1d73
Merge branch 'linalg_schur' of github.com:perazz/stdlib into linalg_s…
perazz 9a3ba2c
Merge branch 'fortran-lang:master' into linalg_schur
perazz daf7a5e
schur: `real` eigenvalues option
perazz 589d94d
test `real` eigenvalue option
perazz 46a7ec2
document `real` eigenvalues case
perazz a1522ce
Merge branch 'fortran-lang:master' into linalg_schur
perazz d5e4019
style fix
perazz f9a31cd
`storage`: make `intent(inout)`
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,30 @@ | ||
! This example demonstrates the Schur decomposition for a complex-valued matrix. | ||
program example_schur_complex | ||
use stdlib_linalg, only: schur | ||
use stdlib_linalg_constants, only: dp | ||
implicit none | ||
|
||
integer, parameter :: n = 3 | ||
complex(dp), dimension(n,n) :: A, T, Z | ||
|
||
! Initialize a complex-valued square matrix | ||
A = reshape([ (1, 2), (3,-1), (4, 1), & | ||
(0,-1), (2, 0), (1,-2), & | ||
(2, 3), (1, 1), (0,-1) ], shape=[n,n]) | ||
|
||
! Compute the Schur decomposition: A = Z T Z^H | ||
call schur(A, T, Z) | ||
|
||
! Output results | ||
print *, "Original Matrix A:" | ||
print *, A | ||
print *, "Schur Form Matrix T:" | ||
print *, T | ||
print *, "Unitary Matrix Z:" | ||
print *, Z | ||
|
||
! Test factorization: Z*T*Z^H = A | ||
print *, "Max error in reconstruction:", maxval(abs(matmul(Z, matmul(T, conjg(transpose(Z)))) - A)) | ||
|
||
end program example_schur_complex | ||
|
||
perazz marked this conversation as resolved.
Show resolved
Hide resolved
|
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,32 @@ | ||
! This example includes eigenvalue computation in addition to | ||
! the Schur decomposition for a randomly generated matrix. | ||
program example_schur_eigenvalues | ||
use stdlib_linalg, only: schur | ||
use stdlib_linalg_constants, only: dp | ||
implicit none | ||
|
||
integer, parameter :: n = 5 | ||
real(dp), dimension(n,n) :: A, T, Z | ||
complex(dp), dimension(n) :: eigenvalues | ||
|
||
! Create a random real-valued square matrix | ||
call random_number(A) | ||
|
||
! Compute the Schur decomposition and eigenvalues | ||
call schur(A, T, Z, eigenvalues) | ||
|
||
! Output results | ||
print *, "Random Matrix A:" | ||
print *, A | ||
print *, "Schur Form Matrix T:" | ||
print *, T | ||
print *, "Orthogonal Matrix Z:" | ||
print *, Z | ||
print *, "Eigenvalues:" | ||
print *, eigenvalues | ||
|
||
! Test factorization: Z*T*Z^T = A | ||
print *, "Max error in reconstruction:", maxval(abs(matmul(Z, matmul(T, transpose(Z))) - A)) | ||
|
||
end program example_schur_eigenvalues | ||
|
||
perazz marked this conversation as resolved.
Show resolved
Hide resolved
|
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,29 @@ | ||
! This example computes the Schur decomposition of a real-valued square matrix. | ||
program example_schur_real | ||
use stdlib_linalg, only: schur | ||
use stdlib_linalg_constants, only: dp | ||
implicit none | ||
integer, parameter :: n = 3 | ||
real(dp), dimension(n,n) :: A, T, Z | ||
|
||
! Initialize a real-valued square matrix | ||
A = reshape([ 0, 2, 2, & | ||
0, 1, 2, & | ||
1, 0, 1], shape=[n,n]) | ||
|
||
! Compute the Schur decomposition: A = Z T Z^T | ||
call schur(A, T, Z) | ||
|
||
! Output results | ||
print *, "Original Matrix A:" | ||
print *, A | ||
print *, "Schur Form Matrix T:" | ||
print *, T | ||
print *, "Orthogonal Matrix Z:" | ||
print *, Z | ||
|
||
! Test factorization: Z*T*Z^T = A | ||
print *, "Max error in reconstruction:", maxval(abs(matmul(Z, matmul(T, transpose(Z))) - A)) | ||
|
||
end program example_schur_real | ||
|
||
perazz marked this conversation as resolved.
Show resolved
Hide resolved
|
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.