/* nag_regsn_mult_linear_newyvar (g02dgc) Example Program. * * Copyright 1990 Numerical Algorithms Group. * * Mark 2 revised, 1992. * Mark 8 revised, 2004. */ #include #include #include #include #define XM(I,J) xm[(I)*tdxm + J] #define Q(I,J) q[(I)*tdq + J] int main(void) { Nag_Boolean svd; Integer exit_status=0, i, ip, j, m, n, rank, *sx=0, tdq, tdxm; NagError fail; Nag_IncludeMean mean; char meanc, weight; double *b=0, *com_ar=0, *cov=0, df, *h=0, *newy=0, *p=0, *q=0, *res=0, rss; double *se=0, tol, *wt=0, *wtptr, *xm=0, *y=0; INIT_FAIL(fail); Vprintf("nag_regsn_mult_linear_newyvar (g02dgc) Example Program Results\n"); /* Skip heading in data file */ Vscanf("%*[^\n]"); Vscanf("%ld %ld %c %c", &n, &m, &weight, &meanc); if (n>=2 && m>=1) { if ( !( h = NAG_ALLOC(n, double)) || !( newy = NAG_ALLOC(n, double)) || !( res = NAG_ALLOC(n, double)) || !( wt = NAG_ALLOC(n, double)) || !( xm = NAG_ALLOC(n*m, double)) || !( y = NAG_ALLOC(n, double)) || !( sx = NAG_ALLOC(m, Integer)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } tdxm = m; } else { Vprintf("Invalid n or m.\n"); exit_status = 1; return exit_status; } if (meanc=='m') mean = Nag_MeanInclude; else mean = Nag_MeanZero; if (weight=='w') { wtptr = wt; for (i=0; i