/* nag_corr_cov (g02bxc) Example Program. * * Copyright 1992 Numerical Algorithms Group. * * Mark 3, 1992. * Mark 8 revised, 2004. */ #include #include #include #include #define X(I,J) x[(I)*tdx + J] #define R(I,J) r[(I)*tdr + J] #define V(I,J) v[(I)*tdv + J] int main(void) { Integer exit_status=0, i, j, m, n, tdr, tdv, tdx, test; NagError fail; char w; double *r=0, *std=0, sw, *v=0, *wmean=0, *wt=0, *wtptr, *x=0; INIT_FAIL(fail); Vprintf("nag_corr_cov (g02bxc) Example Program Results\n"); /* Skip heading in data file */ Vscanf("%*[^\n]"); test = 0; while ((scanf("%ld%ld %c",&m,&n, &w) != EOF)) { if (m>=1 && n>=1) { if ( !( x = NAG_ALLOC(n*m, double)) || !( r = NAG_ALLOC(m*m, double)) || !( v = NAG_ALLOC(m*m, double)) || !( wt = NAG_ALLOC(n, double)) || !( wmean = NAG_ALLOC(m, double)) || !( std = NAG_ALLOC(m, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } tdx = m; tdr = m; tdv = m; } else { Vprintf("Invalid m or n.\n"); exit_status = 1; return exit_status; } for(i=0; i