/* nag_rand_bb_make_bridge_order (g05xec) 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 calling %s\n%s\n",name,fail.message); exit_status=-1; goto END; } int main(void) { Integer exit_status = 0; NagError fail; /* Scalars */ double t0, tend; Integer a, d, pdb, pdc, pdz, nmove, npaths, ntimes, i ; Nag_OrderType order; /* 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 = 3; /* We modify the first 3 points in the construction order */ 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(pdc * d, 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