/* nag_tsa_mean_range (g13auc) Example Program. * * Copyright 2002 Numerical Algorithms Group. * * Mark 7, 2002. */ #include #include #include #include int main(void) { /* Scalars */ Integer exit_status, i, ngrps, m, n; /* Arrays */ double *mean = 0, *range = 0, *z = 0; NagError fail; INIT_FAIL(fail); exit_status = 0; Vprintf("g13auc Example Program Results\n"); /* Skip heading in data file */ Vscanf("%*[^\n] "); Vscanf("%ld%ld%*[^\n] ", &n, &m); if (n >= m && m >= 1) { ngrps = n / m; /* Allocate arrays */ if ( !(mean = NAG_ALLOC(ngrps, double)) || !(range = NAG_ALLOC(ngrps, double)) || !(z = NAG_ALLOC(n, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } for (i = 1; i <= n; ++i) Vscanf("%lf", &z[i-1]); Vscanf("%*[^\n] "); Vprintf("\n"); g13auc(n, z, m, Nag_UseRange, range, mean, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from g13auc.\n%s\n", fail.message); exit_status = 1; goto END; } Vprintf(" Range Mean\n"); for (i = 1; i <= ngrps; i++) Vprintf("%8.3f %8.3f\n", range[i-1], mean[i-1]); } END: if (mean) NAG_FREE(mean); if (range) NAG_FREE(range); if (z) NAG_FREE(z); return exit_status; }