/* nag_rand_bb_inc_init (g05xcc) 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, double t0, double tend, Integer ntimes, double intime[], Integer d, double start[], double bb[], double bd[], 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)*d + I-1] Integer exit_status = 0; NagError fail; /* Scalars */ double t0, tend; Integer a, d, pdb, pdc, pdz, nmove, npaths, ntimes, i ; /* Arrays */ double *bb = 0, *c = 0, *intime = 0, *rcommb = 0, *start = 0, *term = 0, *times = 0, *zb = 0, *rcommd = 0, *zd = 0, *diff = 0, *bd = 0; Integer *move = 0; INIT_FAIL(fail); /* Parameters which determine the bridge */ ntimes = 10; t0 = 0.0; npaths = 2; a = 0; nmove = 0; d = 2; pdz = npaths; pdb = npaths; pdc = d; /* Allocate memory */ if ( !( intime = NAG_ALLOC((ntimes), double)) || !( times = NAG_ALLOC((ntimes), double)) || !( rcommb = NAG_ALLOC((12 * (ntimes + 1)), double)) || !( rcommd = NAG_ALLOC((12 * (ntimes + 1)), double)) || !( start = NAG_ALLOC(d, double)) || !( term = NAG_ALLOC(d, double)) || !( diff = NAG_ALLOC(d, double)) || !( c = NAG_ALLOC(pdc * d, double)) || !( zb = NAG_ALLOC(pdz * d * (ntimes+1-a), double)) || !( zd = NAG_ALLOC(pdz * d * (ntimes+1-a), double)) || !( bb = NAG_ALLOC(pdb * d * (ntimes+1), double)) || !( bd = NAG_ALLOC(pdb * d * (ntimes+1), 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