-
Notifications
You must be signed in to change notification settings - Fork 191
linalg eig
: generalized eigenvalue problem
#909
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
16 commits
Select commit
Hold shift + click to select a range
03c4e2c
add `GGEV` error handling
perazz 9bed102
template GEEV/GGEV procedures
perazz 09bf7bc
lift `xdp` restriction
perazz 9d86d45
fix templated interface
perazz 4888e21
generalize error handling
perazz bcdfa31
scale generalized eigenvalues
perazz 1c1a33f
document `eig`
perazz 7d49905
document `eigvals`
perazz f344f07
add examples
perazz cbb6c46
add generalized tests
perazz 15e8fde
Update doc/specs/stdlib_linalg.md
perazz f33998c
Update doc/specs/stdlib_linalg.md
perazz a9ced45
specify backend usage
perazz 870425b
`eigvals` has a stable API
perazz 6830652
example cleanup
perazz 565e8d7
Merge branch 'fortran-lang:master' into generalized_eig
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 @@ | ||
! Eigendecomposition of a real square matrix for the generalized eigenproblem | ||
program example_eig_generalized | ||
use stdlib_linalg, only: eig, eye | ||
implicit none | ||
|
||
integer :: i | ||
real, allocatable :: A(:,:), B(:,:) | ||
complex, allocatable :: lambda(:), vectors(:,:) | ||
|
||
! Matrices for the generalized eigenproblem: A * v = lambda * B * v | ||
! NB Fortran is column-major -> transpose input | ||
A = transpose(reshape([ [2, 2, 4], & | ||
[1, 3, 5], & | ||
[2, 3, 4] ], [3,3])) | ||
|
||
B = eye(3) | ||
|
||
! Allocate eigenvalues and right eigenvectors | ||
allocate(lambda(3), vectors(3,3)) | ||
|
||
! Get eigenvalues and right eigenvectors for the generalized problem | ||
call eig(A, B, lambda, right=vectors) | ||
|
||
do i = 1, 3 | ||
print *, 'Eigenvalue ', i, ': ', lambda(i) | ||
print *, 'Eigenvector ', i, ': ', vectors(:,i) | ||
end do | ||
|
||
end program example_eig_generalized | ||
|
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,26 @@ | ||
! Eigenvalues of a general real/complex matrix for the generalized eigenproblem | ||
program example_eigvals_generalized | ||
use stdlib_linalg, only: eigvals, eye | ||
implicit none | ||
|
||
real, allocatable :: A(:,:), B(:,:), lambda(:) | ||
complex, allocatable :: cA(:,:), cB(:,:), clambda(:) | ||
|
||
! NB Fortran is column-major -> transpose input | ||
A = transpose(reshape([ [2, 8, 4], & | ||
[1, 3, 5], & | ||
[9, 5,-2] ], [3,3])) | ||
|
||
B = eye(3) | ||
|
||
! Real generalized eigenproblem | ||
lambda = eigvals(A, B) | ||
print *, 'Real generalized matrix eigenvalues: ', lambda | ||
|
||
! Complex generalized eigenproblem | ||
cA = cmplx(A, -2*A) | ||
cB = cmplx(B, 0.5*B) | ||
clambda = eigvals(cA, cB) | ||
print *, 'Complex generalized matrix eigenvalues: ', clambda | ||
|
||
end program example_eigvals_generalized |
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.