# include # include # include # include # include "eigs.h" /******************************************************************************/ double complex *eigs ( int n, double *A ) /******************************************************************************/ /* Purpose: eigs() computes the eigenvalues of a real matrix in general storage. Discussion: The computation is done by calling the lapack() function dgeev() Licensing: This code is distributed under the MIT license. Modified: 06 June 2024 Author: John Burkardt */ { int i; int info; char jobvl; char jobvr; double complex *lambda; int lda = n; int ldvl = 1; int ldvr = 1; int lwork; double *vl; double *vr; double *wi; double *work; double *wr; jobvl = 'N'; jobvr = 'N'; lda = n; wr = ( double * ) malloc ( n * sizeof ( double ) ); wi = ( double * ) malloc ( n * sizeof ( double ) ); vl = NULL; ldvl = 1; vr = NULL; ldvr = 1; work = ( double * ) malloc ( 3 * n * sizeof ( double ) ); lwork = 3 * n; dgeev_ ( &jobvl, &jobvr, &n, A, &lda, wr, wi, vl, &ldvl, vr, &ldvr, work, &lwork, &info ); lambda = ( double complex * ) malloc ( n * sizeof ( double complex ) ); for ( i = 0; i < n; i++ ) { lambda[i] = wr[i] + wi[i] * I; } free ( wi ); free ( work ); free ( wr ); return lambda; }