Compute the eigenvalues and, optionally, the eigenvectors of a real general matrix.
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(n,2) | :: | w |
real and imaginary parts of the eigenvalues |
|
real(kind=wp), | intent(out), | dimension(n,n) | :: | z |
real and imaginary parts of the eigenvectors |
|
integer, | intent(out) | :: | ierr |
output flag from rg |
subroutine compute_eigenvalues_and_eigenvectors(n, a, w, z, 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(n,2),intent(out) :: w !! real and imaginary parts of the eigenvalues real(wp),dimension(n,n),intent(out) :: z !! real and imaginary parts of the eigenvectors integer,intent(out) :: ierr !! output flag from [[rg]] integer,parameter :: matz = 1 !! tells [[rg]] to compute eigenvalues and eigenvectors integer :: i !! counter real(wp),dimension(n,n) :: a_tmp !! copy of [[a]] matrix real(wp),dimension(n) :: fv1 !! work array for [[rg]] integer,dimension(n) :: iv1 !! work array for [[rg]] real(wp),dimension(n) :: wr !! real part of the eigenvalues real(wp),dimension(n) :: wi !! imaginary part of the eigenvalues ! temp arrays: a_tmp = a wr = zero wi = zero ! call the general routine: call rg(n, n, a_tmp, wr, wi, matz, z, iv1, fv1, ierr) ! pack outputs: do i=1,n w(i,1) = wr(i) w(i,2) = wi(i) end do end subroutine compute_eigenvalues_and_eigenvectors