/* nag_complex_eigensystem_sel(f02gcc) Example Program. * * Copyright 1998 Numerical Algorithms Group. * * Mark 5, 1998. * */ #include #include #include #include #define NMAX 8 #define MMAX 3 #define TDA NMAX #define TDV MMAX int main(void) { double wl, wu; Integer i, j, m, n; Integer mest = MMAX; Integer tda, tdv; Complex a[NMAX][NMAX], v[NMAX][MMAX], w[NMAX]; tda = NMAX; tdv = MMAX; Vprintf("f02gcc Example Program Results\n"); /* Skip heading in data file */ Vscanf("%*[^\n]"); Vscanf("%ld%lf%lf%*[^\n] ",&n, &wl, &wu); if (n <= NMAX) { /* Read a from data file */ for (i = 0; i < n; ++i) for (j = 0; j < n; ++j) Vscanf(" ( %lf ,%lf ) ",&a[i][j].re,&a[i][j].im); /* Compute selected eigenvalues and eigenvectors of A */ f02gcc(Nag_Select_Modulus, n, &a[0][0], tda, wl, wu, mest, &m, w, &v[0][0], tdv, NAGERR_DEFAULT); Vprintf("\n\nEigenvalues\n\n"); for (i = 0; i < m; ++i) Vprintf("(%7.4f, %7.4f)%s",w[i].re, w[i].im, (i+1)%2 == 0 ? "\n" : " "); Vprintf("\nEigenvectors\n"); for (i=1; i<=m; i++) Vprintf("%15ld%s", i, i%m == 0 ?"\n" : ""); for (i = 0; i < n; i++) { Vprintf("%ld ", i + 1); for (j = 0; j < m; j++) Vprintf("(%8.4f, %8.4f)%s", v[i][j].re, v[i][j].im, (j + 1)%m == 0 ? "\n":" "); } return EXIT_SUCCESS; } else { Vprintf( "Incorrect input value of n.\n"); return EXIT_FAILURE; } }