/* nag_tsa_cross_spectrum_bivar(g13cec) Example Program. * * Copyright 1996 Numerical Algorithms Group. * * Mark 4, 1996. * */ #include #include #include #include #include #define L 80 #define KC 8*L #define NGMAX KC #define NXYMAX 300 int main(void) { double stats[4]; double x[KC], y[KC]; double pxy; double pw; double ca[NGMAX], calw[NGMAX], caup[NGMAX], sc[NGMAX], sclw[NGMAX], scup[NGMAX]; double t; double *xg, *yg; Complex *xyg; Integer i, j, ng, is; Integer mw; Integer nxy; Integer kc=KC, l=L; Vprintf("g13cec Example Program Results\n"); /* Skip heading in data file */ Vscanf("%*[^\n] "); Vscanf("%ld ", &nxy); if (nxy > 0 && nxy <= NXYMAX) { for (i = 1; i <= nxy; ++i) Vscanf("%lf ", &x[i - 1]); for (i = 1; i <= nxy; ++i) Vscanf("%lf ", &y[i - 1]); /* Set parameters for call to g13cbc and g13cdc * with mean correction and 10 percent taper */ pxy = 0.1; /* Window shape parameter and zero covariance at lag 16 */ pw = 0.5; mw = 16; /* Alignment shift of 3 */ is = 3; /* Obtain univariate spectrum for the x and the y series */ g13cbc(nxy, Nag_Mean, pxy, mw, pw, l, kc, Nag_Unlogged, x, &xg, &ng, stats, NAGERR_DEFAULT); g13cbc(nxy, Nag_Mean, pxy, mw, pw, l, kc, Nag_Unlogged, y, &yg, &ng, stats, NAGERR_DEFAULT); /* Obtain cross spectrum of the bivariate series */ g13cdc(nxy, Nag_Mean, pxy, mw, is, pw, l, kc, x, y, &xyg, &ng, NAGERR_DEFAULT); g13cec(xg, yg, xyg, ng, stats, ca, calw, caup, &t, sc, sclw, scup, NAGERR_DEFAULT); Vprintf("\n"); Vprintf(" Cross amplitude spectrum\n\n"); Vprintf(" Lower Upper\n"); Vprintf(" Value bound bound\n\n"); for (j = 1; j <= ng; ++j) Vprintf(" %5ld%10.4f%10.4f%10.4f\n", j - 1, ca[j - 1], calw[j - 1], caup[j - 1]); Vprintf("\n"); Vprintf(" Squared coherency test statistic =%12.4f\n\n", t); Vprintf(" Squared coherency\n\n"); Vprintf(" Lower Upper\n"); Vprintf(" Value bound bound\n\n"); for (j = 1; j <= ng; ++j) Vprintf(" %5ld%10.4f%10.4f%10.4f\n", j - 1, sc[j - 1], sclw[j - 1], scup[j - 1]); } NAG_FREE(xg); NAG_FREE(yg); NAG_FREE(xyg); return EXIT_SUCCESS; }