subroutine eigs ( n, A, lambda ) c*****************************************************************************80 c cc eigs() computes the eigenvalues of a real matrix. c c Licensing: c c This code is distributed under the MIT license. c c Modified: c c 06 June 2024 c c Author: c c John Burkardt c c Input: c c integer n: the order of the matrix. c c real A(n,n): the matrix. c c Output: c c complex lambda(n): the eigenvalues. c implicit none integer n double precision A(n,n) double precision, allocatable :: A2(:,:) integer info character jobvl character jobvr double complex lambda(n) integer lda integer ldvl integer ldvr integer lwork double precision vl(0) double precision vr(0) double precision wi(n) double precision, allocatable :: work(:) double precision wr(n) lwork = 3 * n allocate ( work(1:lwork) ) c c Make a copy of A, since dgeev() will modify the matrix during processing. c allocate ( A2(1:n,1:n) ) A2(1:n,1:n) = A(1:n,1:n) c c Do not compute left or right eigenvectorsc c ldvl and ldvr should be 0, but dgeev will reject these as illegal. c We set them to 1, which doesn't matter because they aren't usedc c jobvl = 'N' jobvr = 'N' lda = n ldvl = 1 ldvr = 1 call dgeev ( jobvl, jobvr, n, A2, lda, wr, wi, vl, ldvl, vr, & ldvr, work, lwork, info ) if ( info /= 0 ) then write ( *, '(a)' ) '' write ( *, '(a)' ) 'eigs(): Fatal errorc' write ( *, '(a,i8)' ) ' dgeev() error flag INFO = ', info end if c c Combine wr and wi into the complex values lambda. c lambda = dcmplx ( wr, wi ) c c Release memory. c deallocate ( A2 ) deallocate ( work ) return end