#include using namespace std; #define NLAYERS_BCAL 10 double BCAL_tdiff(double geometric_mean, int layer) { double tw_par[NLAYERS_BCAL][7] ={ {11.0672, -12.0531, 3.25046, -0.102684, -0.0674759, 0.00888003, -0.000323306}, // layer 1 {-110.005, 41.2519, 1.01664, -1.3829, -0.119074, 0.0615181, -0.00427167}, // layer 2 {521.934, -280.307, 5.35516, 13.9033, 0.733818, -0.900863, 0.0873093}, // 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]))))); }