/* nag_real_eigensystem_sel(f02ecc) 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 a[NMAX][NMAX]; double wl, wu; Integer i, j, m, n; Integer mest = MMAX; Integer tda=TDA, tdv=TDV; Complex w[NMAX], v[NMAX][MMAX]; Vprintf("f02ecc Example Program Results\n\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",&a[i][j]); Vscanf("%*[^\n]"); /* Compute selected eigenvalues and eigenvectors of A */ f02ecc(Nag_Select_Modulus, n, &a[0][0], tda, wl, wu, mest, &m, w, &v[0][0], tdv, NAGERR_DEFAULT); Vprintf("\n\nEigenvalues\n"); for (i = 0; i < m; ++i) Vprintf("(%7.4f, %7.4f) ", w[i].re, w[i].im); Vprintf("\n"); Vprintf(" Eigenvectors\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; } }