#include using namespace std; #define NLAYERS_BCAL 10 double BCAL_tdiff(double geometric_mean, int layer) { double tw_par[NLAYERS_BCAL][7] ={ {54.7858, -30.1543, 4.73011, 0.0923279, -0.0789792, 0.00514771, -3.22595e-05}, // layer 1 {-1232.58, 1476.13, -721.447, 184.716, -26.1834, 1.95105, -0.0597667}, // layer 2 {-2341.59, 1947.88, -480.606, -19.6095, 27.4221, -4.32381, 0.220259}, // layer 3 {0, 0, 0, 0, 0, 0, 0}, // layer 4 {0, 0, 0, 0, 0, 0, 0}, // layer 5 {0, 0, 0, 0, 0, 0, 0}, // layer 6 {0, 0, 0, 0, 0, 0, 0}, // layer 7 {0, 0, 0, 0, 0, 0, 0}, // layer 8 {0, 0, 0, 0, 0, 0, 0}, // layer 9 {0, 0, 0, 0, 0, 0, 0} // layer 10 }; layer = layer<1 ? 1:layer>NLAYERS_BCAL ? NLAYERS_BCAL:layer; double *p = tw_par[layer-1]; double x = log(geometric_mean); return p[0]+x*(p[1]+x*(p[2]+x*(p[3]+x*(p[4]+x*(p[5]+x*p[6]))))); }