#include using namespace std; #define NLAYERS_BCAL 10 double BCAL_tavg(double geometric_mean, int layer) { double tw_par[NLAYERS_BCAL][7] ={ {-459.766, 395.09, -109.524, 4.07107, 3.27126, -0.570532, 0.0289241}, // layer 1 {-166.434, 159.853, -49.2921, 2.99389, 1.2468, -0.240305, 0.0125993}, // layer 2 {-5308.4, 6622.19, -3395.04, 916.852, -137.711, 10.9177, -0.3572}, // layer 3 {-364.24, 299.521, -78.2711, 1.33324, 2.75256, -0.453378, 0.0226098}, // layer 4 {-535.03, 291.228, -7.85333, -14.0913, -0.558188, 0.866452, -0.084593}, // layer 5 {-567.193, 497.169, -134.606, 0.373489, 5.88215, -0.979443, 0.0501939}, // layer 6 {-976.009, 506.107, -5.20957, -24.8803, -1.49409, 1.57834, -0.147959}, // 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]))))); }