/* 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; printf("nag_tsa_mean_range (g13auc) Example Program Results\n"); /* Skip heading in data file */ scanf("%*[^\n] "); scanf("%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))) { printf("Allocation failure\n"); exit_status = -1; goto END; } for (i = 1; i <= n; ++i) scanf("%lf", &z[i-1]); scanf("%*[^\n] "); printf("\n"); /* nag_tsa_mean_range (g13auc). * Computes quantities needed for range-mean or standard * deviation-mean plot */ nag_tsa_mean_range(n, z, m, Nag_UseRange, range, mean, &fail); if (fail.code != NE_NOERROR) { printf("Error from nag_tsa_mean_range (g13auc).\n%s\n", fail.message); exit_status = 1; goto END; } printf(" Range Mean\n"); for (i = 1; i <= ngrps; i++) printf("%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; }