/* nag_rand_bb_init (g05xac) Example Program. * * Copyright 2013 Numerical Algorithms Group. * * Mark 24, 2013. */ #include #include #include #include #include #include int get_z(Integer nelements, double * z); 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 calling %s\n%s\n",name,fail.message); exit_status=-1; goto END; } int main(void) { #define C(I,J) c[(J-1)*pdc + I-1] Integer exit_status = 0; NagError fail; /* Scalars */ 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; INIT_FAIL(fail); /* Parameters which determine the bridge */ ntimes = 10; t0 = 0.0; npaths = 2; a = 0; nmove = 0; d = 3; pdz = d*(ntimes+1-a); pdb = d*(ntimes+1); pdc = d; /* 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(pdc * d, double)) || !( z = NAG_ALLOC(pdz * npaths, double)) || !( b = NAG_ALLOC(pdb * 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