/* nag_pde_bs_1d_means (d03nec) Example Program. * * Copyright 2001 Numerical Algorithms Group. * * Mark 7, 2001. */ #include #include #include #include #include #include #define F(I,J) f[ns*((J)-1)+(I)-1] #define THETA(I,J) theta[ns*((J)-1)+(I)-1] #define DELTA(I,J) delta[ns*((J)-1)+(I)-1] #define GAMMA(I,J) gamma[ns*((J)-1)+(I)-1] #define LAMBDA(I,J) lambda[ns*((J)-1)+(I)-1] #define RHO(I,J) rho[ns*((J)-1)+(I)-1] int main(void) { double ds, dt, tmat, x; Integer i, igreek, j, ns, nt, ntd, exit_status; double *delta, *f, *gamma, *lambda, q[3], ra[3], *rho, *s, siga[3], *t, *theta, *td, *rd, *sigd, smin, smax, tmin, tmax; Boolean gprnt[5]={TRUE, TRUE, TRUE, TRUE, TRUE}, tdpar[3]; const char *gname[5]={"Theta", "Delta", "Gamma", "Lambda", "Rho"}; NagError fail; /* Skip heading in data file */ Vscanf("%*[^\n] "); exit_status = 0; /* Read problem parameters */ Vscanf("%lf", &x); Vscanf("%lf", &tmat); Vscanf("%ld%ld", &ns, &nt); Vscanf("%lf%lf", &smin, &smax); Vscanf("%lf%lf", &tmin, &tmax); Vscanf("%ld", &ntd); /* Allocate memory */ if ( !(s = NAG_ALLOC(ns, double)) || !(t = NAG_ALLOC(nt, double)) || !(f = NAG_ALLOC(ns*nt, double)) || !(theta = NAG_ALLOC(ns*nt, double)) || !(delta = NAG_ALLOC(ns*nt, double)) || !(gamma = NAG_ALLOC(ns*nt, double)) || !(lambda = NAG_ALLOC(ns*nt, double)) || !(rho = NAG_ALLOC(ns*nt, double)) || !(td = NAG_ALLOC(ntd, double)) || !(rd = NAG_ALLOC(ntd, double)) || !(sigd = NAG_ALLOC(ntd, double)) ) { Vprintf("Allocation failure\n"); exit_status = 1; goto END; } /* Read discrete times and data values for r and sigma */ for (i=0; i