#include using namespace std; #define NLAYERS_BCAL 10 double BCAL_tdiff(double geometric_mean, int layer) { double tw_par[NLAYERS_BCAL][7] ={ {-523.661, 580.584, -262.655, 62.1095, -8.10291, 0.553576, -0.0154922}, // layer 1 {-2007.92, 2194.7, -990.803, 236.362, -31.4115, 2.20418, -0.0637876}, // layer 2 {-27.2736, 17.488, -0.492699, -0.912715, -0.0475612, 0.0550325, -0.00487664}, // layer 3 {-9699.07, 8543.23, -2235.52, -94.4309, 142.392, -23.7997, 1.28335}, // 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]))))); }