/* nag_mv_discrim (g03dac) Example Program. * * Copyright 1998 Numerical Algorithms Group. * * Mark 5, 1998. * */ #include #include #include #include #define NMAX 21 #define MMAX 2 #define GPMAX 3 int main(void) { double stat; double det[GPMAX], gc[(GPMAX+1)*MMAX*(MMAX+1)/2], gmean[GPMAX][MMAX], wt[NMAX], x[NMAX][MMAX]; double df; double *wtptr = 0; double sig; Integer nvar; Integer i, j, m, n; Integer ing[NMAX], isx[MMAX], nig[GPMAX]; Integer ng; Integer tdgmean=MMAX, tdx= MMAX; char weight[2]; Vprintf("g03dac Example Program Results\n\n"); /* Skip headings in data file */ Vscanf("%*[^\n]"); Vscanf("%ld",&n); Vscanf("%ld",&m); Vscanf("%ld",&nvar); Vscanf("%ld",&ng); Vscanf("%s",weight); if (n <= NMAX && m <= MMAX) { if (*weight == 'W') { for (i = 0; i < n; ++i) { for (j = 0; j < m; ++j) Vscanf("%lf",&x[i][j]); Vscanf("%ld",&ing[i]); Vscanf("%lf",&wt[i]); } wtptr = wt; } else { for (i = 0; i < n; ++i) { for (j = 0; j < m; ++j) Vscanf("%lf",&x[i][j]); Vscanf("%ld",&ing[i]); } } for (j = 0; j < m; ++j) Vscanf("%ld",&isx[j]); g03dac(n, m, &x[0][0], tdx, isx, nvar, ing, ng, wtptr, nig, &gmean[0][0], tdgmean, det, gc, &stat, &df, &sig, NAGERR_DEFAULT); Vprintf("\nGroup means\n\n"); for (i = 0; i < ng; ++i) { for (j = 0; j < nvar; ++j) Vprintf("%10.4f",gmean[i][j]); Vprintf("\n"); } Vprintf("\nLOG of determinants\n\n"); for (j = 0; j < ng; ++j) Vprintf("%10.4f",det[j]); Vprintf("\n\n%s%7.4f\n","stat = ",stat); Vprintf("%s%7.4f\n"," df = ",df); Vprintf("%s%7.4f\n"," sig = ",sig); return EXIT_SUCCESS; } else { Vprintf("Incorrect input value of n or m.\n"); return EXIT_FAILURE; } }