/* nag_tsa_diff (g13aac) Example Program. * * Copyright 2002 Numerical Algorithms Group. * * Mark 7, 2002. */ #include #include #include #include int main(void) { /* Scalars */ Integer exit_status, i, d, ds, s, nx, nxd; NagError fail; /* Arrays */ double *x = 0, *xd = 0; INIT_FAIL(fail); exit_status = 0; Vprintf("g13aac Example Program Results\n"); /* Skip heading in data file */ Vscanf("%*[^\n] "); Vscanf("%ld%ld%ld%ld%*[^\n] ", &nx, &d, &ds, &s); if (nx > 0) { /* Allocate memory */ if ( !(x = NAG_ALLOC(nx, double)) || !(xd = NAG_ALLOC(nx, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } for (i = 1; i <= nx; ++i) Vscanf("%lf", &x[i-1]); Vscanf("%*[^\n] "); Vprintf("\n"); Vprintf("Non-seasonal differencing of order %ld " "and seasonal differencing\nof order %ld " "with seasonality %ld are applied\n", d, ds, s); g13aac(x, nx, d, ds, s, xd, &nxd, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from g13aac.\n%s\n", fail.message); exit_status = 1; goto END; } Vprintf("\n"); Vprintf("The output array holds %2ld values, of which the " "first %2ld are differenced values\n\n", nx, nxd); for (i = 1; i <= nx; ++i) { Vprintf("%10.1f", xd[i-1]); if (i % 5 == 0 || i == nx) Vprintf("\n"); } } END: if (x) NAG_FREE(x); if (xd) NAG_FREE(xd); return exit_status; }