/* nag_return_multi_normal (g05ezc) Example Program. * * Copyright 1991 Numerical Algorithms Group. * * Mark 2, 1991. * * Mark 3 revised, 1994. */ #include #include #include #include #include #define N 2 #define TDC N int main(int argc, char *argv[]) { FILE *fpout; Integer exit_status = 0; Integer i, j; double a[N], c[N][TDC], z[N]; double *r; double eps = 0.01; NagError fail; INIT_FAIL(fail); /* Check for command-line IO options */ fpout = nag_example_file_io(argc, argv, "-results", NULL); fprintf(fpout, "nag_return_multi_normal (g05ezc) Example Program Results\n"); a[0] = 1.0; a[1] = 2.0; c[0][0] = 2.0; c[1][1] = 3.0; c[0][1] = 1.0; c[1][0] = 1.0; /* nag_random_init_repeatable (g05cbc). * Initialize random number generating functions to give * repeatable sequence */ nag_random_init_repeatable((Integer) 0); /* nag_ref_vec_multi_normal (g05eac). * Set up reference vector for multivariate Normal * distribution */ nag_ref_vec_multi_normal(a, (Integer) N, &c[0][0], (Integer) TDC, eps, &r, &fail); if (fail.code != NE_NOERROR) { fprintf(fpout, "Error from nag_return_multi_normal (g05ezc) %s\n", fail.message); exit_status = 1; goto END; } for (i = 1; i <= 5; i++) { /* nag_return_multi_normal (g05ezc). * Pseudo-random multivariate Normal vector from reference * vector */ nag_return_multi_normal(z, r); for (j = 0; j < (Integer) N; j++) fprintf(fpout, "%10.4f", z[j]); fprintf(fpout, "\n"); } END: if (fpout != stdout) fclose(fpout); if (r) NAG_FREE(r); return exit_status; }