/* nag_rngs_orthog_matrix(g05qac) Example Program. * * Copyright 2001 Numerical Algorithms Group. * * Mark 7, 2001. */ #include #include #include #include int main(void) { /* Scalars */ Integer i, igen, j, m, n; Integer exit_status=0; Integer pda; NagError fail; Nag_OrderType order; /* Arrays */ double *a=0; Integer iseed[4]; #ifdef NAG_COLUMN_MAJOR #define A(I,J) a[(J-1)*pda + I - 1] order = Nag_ColMajor; #else #define A(I,J) a[(I-1)*pda + J - 1] order = Nag_RowMajor; #endif INIT_FAIL(fail); Vprintf("g05qac Example Program Results\n\n"); m = 4; n = 4; /* Allocate memory */ if ( !(a = NAG_ALLOC(m * n, double)) ) { Vprintf("Allocation failure\n"); exit_status = -1; goto END; } #ifdef NAG_COLUMN_MAJOR pda = m; #else pda = n; #endif /* igen identifies the stream. */ igen = 1; /* Initialise the seed to a repeatable sequence */ iseed[0] = 1762543; iseed[1] = 9324783; iseed[2] = 423446; iseed[3] = 742355; g05kbc(&igen, iseed); g05qac(order, Nag_RightSide, Nag_InitializeI, m, n, a, pda, igen, iseed, &fail); if (fail.code != NE_NOERROR) { Vprintf("Error from g05qac.\n%s\n", fail.message); exit_status = 1; goto END; } for (i = 1; i <= 4; ++i) { Vprintf("%1s", ""); for (j = 1; j <= 4; ++j) { Vprintf("%9.3f", A(i,j)); Vprintf("%s", j%4 == 0 || j == 4 ?"\n":" "); } } END: if (a) NAG_FREE(a); return exit_status; }