Returns only the real eigenvalues and the associated eigenvectors. Wrapper for compute_eigenvalues_and_eigenvectors.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n |
the order of the matrix |
||
real(kind=wp), | intent(in), | dimension(n,n) | :: | a |
contains the real general matrix |
|
real(kind=wp), | intent(out), | dimension(:), allocatable | :: | e |
eigenvalues (size |
|
real(kind=wp), | intent(out), | dimension(:,:), allocatable | :: | v |
eigenvectors (size |
|
integer, | intent(out) | :: | n_results |
number of real eigenvalues |
||
integer, | intent(out) | :: | ierr |
output flag from rg |
subroutine compute_real_eigenvalues_and_normalized_eigenvectors(n, a, e, v, n_results, ierr) use numbers_module implicit none integer,intent(in) :: n !! the order of the matrix `a` real(wp),dimension(n,n),intent(in) :: a !! contains the real general matrix real(wp),dimension(:),allocatable,intent(out) :: e !! eigenvalues (size `n_results`) real(wp),dimension(:,:),allocatable,intent(out) :: v !! eigenvectors (size `n,n_results`) integer,intent(out) :: n_results !! number of real eigenvalues integer,intent(out) :: ierr !! output flag from [[rg]] real(wp),dimension(n,2) :: w !! real and imaginary parts of the eigenvalues real(wp),dimension(n,n) :: z !! real and imaginary parts of the eigenvectors integer :: i !! counter integer :: j !! counter call compute_eigenvalues_and_eigenvectors(n, a, w, z, ierr) if (ierr==0) then n_results = count(w(:,2)==0.0_wp) if (n_results>0) then allocate(e(n_results)) allocate(v(n,n_results)) j = 0 do i = 1, n if (w(i,2)==0.0_wp) then ! real eigenvalue j = j + 1 e(j) = w(i,1) v(:,j) = z(:,i) / norm2(z(:,i)) ! normalized eigenvector end if end do end if else n_results = 0 end if end subroutine compute_real_eigenvalues_and_normalized_eigenvectors