/* nag_resgn_mult_linear_add_var (g02dec) Example Program. * * Copyright 1991 Numerical Algorithms Group. * * Mark 2, 1991. * Mark 8 revised, 2004. */ #include #include #include #include #define X(I,J) x[(I)*tdx + J] #define Q(I,J) q[(I)*tdq + J] int main(void) { Nag_Boolean svd; Integer exit_status=0, i, indx, ip, ipmax, j, m, n, rank, tdq, tdx; NagError fail; Nag_IncludeMean mean; char meanc, weight; double *b=0, *cov=0, df, *p=0, *q=0, rss, rsst, *se=0, tol, *wt=0, *wtptr; double *x=0, *xe=0; INIT_FAIL(fail); Vprintf("nag_regsn_mult_linear_add_var (g02dec) Example Program Results\n"); /* Skip heading in data file */ Vscanf("%*[^\n]"); Vscanf("%ld %ld %c %c", &n, &m, &weight, &meanc); ipmax = 5; if (n>=1 && m>=1) { if ( !( wt = NAG_ALLOC(n, double)) || !( x = NAG_ALLOC((n)*(m), double)) || !( xe = NAG_ALLOC(n, double)) || !( b = NAG_ALLOC(ipmax, double)) || !( cov = NAG_ALLOC(ipmax*(ipmax+1)/2, double)) || !( p = NAG_ALLOC(ipmax*(ipmax+2), double)) || !( se = NAG_ALLOC(ipmax, double)) || !( q = NAG_ALLOC((n)*(ipmax+1), double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } tdx = m; tdq = ipmax+1; } 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; else wtptr = (double *)0; if (wtptr) { for (i=0; i0) { for (i=0; i