/* nag_mv_canon_var (g03acc) Example Program. * * Copyright 1998 Numerical Algorithms Group. * * Mark 5, 1998. * */ #include #include #include #include #define NMAX 9 #define MMAX 3 #define TDE 6 int main(void) { double e[MMAX][6]; double x[NMAX][MMAX]; double wt[NMAX]; double cvm[MMAX][MMAX], tol, cvx[MMAX][MMAX]; Integer i, j, m, n; Integer ng; Integer nx; Integer ing[NMAX], nig[MMAX], ncv; Integer irx, isx[2*MMAX]; Integer tdx=MMAX, tdc=MMAX, tde=TDE; char wtchar[2]; Nag_Weightstype weight; Vprintf("g03acc Example Program Results\n\n"); /* Skip heading in data file */ Vscanf("%*[^\n]"); Vscanf("%ld",&n); Vscanf("%ld",&m); Vscanf("%ld",&nx); Vscanf("%ld",&ng); Vscanf("%s",wtchar); if (n <= NMAX && m <= MMAX) { if (*wtchar == 'W' || *wtchar == 'V') { for (i = 0; i < n; ++i) { for (j = 0; j < m; ++j) Vscanf("%lf",&x[i][j]); Vscanf("%lf",&wt[i]); Vscanf("%ld",&ing[i]); } if (*wtchar == 'W') weight = Nag_Weightsfreq; else weight = Nag_Weightsvar; } else { for (i = 0; i < n; ++i) { for (j = 0; j < m; ++j) Vscanf("%lf",&x[i][j]); Vscanf("%ld",&ing[i]); } weight = Nag_NoWeights; } for (j = 0; j < m; ++j) Vscanf("%ld",&isx[j]); tol = 1e-6; g03acc(weight, n, m, &x[0][0], tdx, isx, nx, ing, ng, wt, nig, &cvm[0][0], tdc, &e[0][0], tde, &ncv, &cvx[0][0], tdc, tol, &irx, NAGERR_DEFAULT); Vprintf("%s%2ld\n\n","Rank of x = ",irx); 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 < nx; ++i) { for (j = 0; j < ncv; ++j) Vprintf("%9.4f",cvx[i][j]); Vprintf("\n"); } Vprintf("\nCanonical variate means\n"); for (i = 0; i < ng; ++i) { for (j = 0; j < ncv; ++j) Vprintf("%9.4f",cvm[i][j]); Vprintf("\n"); } return EXIT_SUCCESS; } else { Vprintf("Incorrect input value of n or m.\n"); return EXIT_FAILURE; } }