/* nag_normal_scores_var (g01dcc) Example Program. * * Copyright 2001 Numerical Algorithms Group. * * Mark 7, 2001. */ #include #include #include #include int main(void) { /* Scalars */ double errest, etol, exp1, exp2, sumssq; Integer exit_status, i, ifail, j, k, n, vec_elem; NagError fail; /* Arrays */ double *pp=0, *vec=0; Vprintf("g01dcc Example Program Results\n"); INIT_FAIL(fail); etol = 1e-4; exit_status = 0; n = 6; /* Allocate memory */ if ( !(pp = NAG_ALLOC(n, double)) || !(vec = NAG_ALLOC(n*(n+1)/2, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } g01dac(n, pp, etol, &errest, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from g01dac.\n%s\n", fail.message); exit_status = 1; goto END; } exp1 = pp[5]; exp2 = pp[4]; sumssq = 0.0; for (i = 1; i <= 6; ++i) sumssq += pp[i - 1] * pp[i - 1]; ifail = 0; g01dcc(n, exp1, exp2, sumssq, vec, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from g01dac.\n%s\n", fail.message); exit_status = 1; goto END; } Vprintf("\nSample size = %2ld\n\n", n); Vprintf("Variance-covariance matrix\n"); k = 1; for (j = 1; j <= n; ++j) { vec_elem = 1; for (i = k; i <= k + j - 1; ++i) { Vprintf("%8.4f%s", vec[i - 1], vec_elem%6 == 0 ?"\n":" "); vec_elem++; } Vprintf("\n"); k += j; } END: if (pp) NAG_FREE(pp); if (vec) NAG_FREE(vec); return exit_status; }