/* nag_mv_canon_corr (g03adc) Example Program. * * Copyright 1998 Numerical Algorithms Group. * * Mark 5, 1998. * */ #include #include #include #include #define NMAX 9 #define IMAX 2 #define MMAX 2*IMAX int main(void) { double e[IMAX][6]; double z[NMAX][MMAX]; double wt[NMAX]; double tol, cvx[IMAX][IMAX], cvy[IMAX][IMAX]; double *wtptr; Integer i, j, m, n; Integer ix, iy; Integer nx, ny; Integer ncv; Integer isz[4]; Integer tdz=MMAX, tde=6, tdc=IMAX; char weight[2]; Vprintf("g03adc Example Program Results\n\n"); /* Skip heading in data file */ Vscanf("%*[^\n]"); Vscanf("%ld",&n); Vscanf("%ld",&m); Vscanf("%ld",&ix); Vscanf("%ld",&iy); Vscanf("%s",weight); if (n <= NMAX && ix <= IMAX && iy <= IMAX) { if (*weight == 'W') { for (i = 0; i < n; ++i) { for (j = 0; j < m; ++j) Vscanf("%lf",&z[i][j]); Vscanf("%lf",&wt[i]); } wtptr = wt; } else { for (i = 0; i < n; ++i) { for (j = 0; j < m; ++j) Vscanf("%lf",&z[i][j]); } wtptr = 0; } for (j = 0; j < m; ++j) Vscanf("%ld",&isz[j]); tol = 1e-6; nx = ix; ny = iy; g03adc(n, m, &z[0][0], tdz, isz, nx, ny, wtptr, &e[0][0], tde, &ncv, &cvx[0][0], tdc, &cvy[0][0], tdc, tol, NAGERR_DEFAULT); Vprintf("\n%s%2ld%s%2ld\n\n","Rank of x = ",nx," Rank of y = ",ny); Vprintf(" Canonical Eigenvalues Percentage Chisq " " DF Sig\n"); Vprintf(" correlations variation\n"); for (i = 0; i < ncv; ++i) { for (j = 0; j < 6; ++j) Vprintf("%12.4f",e[i][j]); Vprintf("\n"); } Vprintf("\nCanonical coefficients for x\n"); for (i = 0; i < ix; ++i) { for (j = 0; j < ncv; ++j) Vprintf("%9.4f",cvx[i][j]); Vprintf("\n"); } Vprintf("\nCanonical coefficients for y\n"); for (i = 0; i < iy; ++i) { for (j = 0; j < ncv; ++j) Vprintf("%9.4f",cvy[i][j]); Vprintf("\n"); } return EXIT_SUCCESS; } else { Vprintf("Incorrect input value of n or ix or iy.\n"); return EXIT_FAILURE; } }