/* nag_rand_bb (g05xbc) Example Program. * * Copyright 2013 Numerical Algorithms Group. * * Mark 24, 2013. */ #include #include #include #include #include #include int get_z(Nag_OrderType order, Integer ntimes, Integer d, Integer a, Integer npaths, double *z, Integer pdz); void display_results(Nag_OrderType order, Integer npaths, Integer ntimes, Integer d, double *b, Integer pdb); #define CHECK_FAIL(name,fail) if(fail.code != NE_NOERROR) { \ printf("Error from %s.\n%s\n",name,fail.message); \ exit_status = -1; goto END; } int main(void) { /* Scalars */ Integer exit_status = 0; double t0, tend; Integer a, d, pdb, pdc, pdz, nmove, npaths, ntimes, i; /* Arrays */ double *b = 0, *c = 0, *intime = 0, *rcomm = 0, *start = 0, *term = 0, *times = 0, *z = 0; Integer *move = 0; /* Nag Types */ NagError fail; Nag_OrderType order; INIT_FAIL(fail); /* Parameters which determine the bridge. */ ntimes = 10; t0 = 0.0; npaths = 2; /* Create a non-free bridge. */ a = 1; nmove = 0; d = 3; #ifdef NAG_COLUMN_MAJOR order = Nag_ColMajor; pdz = npaths; pdb = npaths; #else order = Nag_RowMajor; pdz = d*(ntimes+1-a); pdb = d*(ntimes+1); #endif pdc = d; #define C(I,J) c[(J-1)*pdc+I-1] /* Allocate memory */ if ( !( intime = NAG_ALLOC((ntimes), double)) || !( times = NAG_ALLOC((ntimes), double)) || !( rcomm = NAG_ALLOC((12*(ntimes+1)), double)) || !( start = NAG_ALLOC(d, double)) || !( term = NAG_ALLOC(d, double)) || !( c = NAG_ALLOC(d*pdc, double)) || !( z = NAG_ALLOC(d*(ntimes+1-a)*npaths, double)) || !( b = NAG_ALLOC(d*(ntimes+1)*npaths, double)) || !( move = NAG_ALLOC(nmove, Integer)) ) { printf("Allocation failure\n"); exit_status = -1; goto END; } /* Fix the time points at which the bridge is required */ for ( i=0; i