/* nag_rngs_exp_mix(g05lqc) Example Program. * * Copyright 2001 Numerical Algorithms Group. * * Mark 7, 2001. */ #include #include #include #include int main(void) { /* Scalars */ Integer igen, j, m, nmix; Integer exit_status=0; NagError fail; /* Arrays */ double *a=0, *wgt=0, *x=0; Integer iseed[4]; INIT_FAIL(fail); Vprintf("g05lqc Example Program Results\n\n"); m = 5; nmix = 3; /* Allocate memory */ if ( !(a = NAG_ALLOC(nmix, double)) || !(wgt = NAG_ALLOC(nmix, double)) || !(x = NAG_ALLOC(m, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } /* Initialise the seed to a repeatable sequence */ iseed[0] = 1762543; iseed[1] = 9324783; iseed[2] = 42344; iseed[3] = 742355; /* igen identifies the stream. */ igen = 1; g05kbc(&igen, iseed); a[0] = 1.0; a[1] = 5.0; a[2] = 2.0; wgt[0] = 0.5; wgt[1] = 0.3; wgt[2] = 0.2; g05lqc(nmix, a, wgt, m, x, igen, iseed, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from g05lqc.\n%s\n", fail.message); exit_status = 1; goto END; } for (j = 0; j < m; ++j) { Vprintf("%10.4f\n", x[j]); } END: if (a) NAG_FREE(a); if (wgt) NAG_FREE(wgt); if (x) NAG_FREE(x); return exit_status; }