Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:01

0001 #ifndef APPROX_ERF_H
0002 #define APPROX_ERF_H
0003 #include "DataFormats/Math/interface/approx_exp.h"
0004 
0005 constexpr float approx_erf(float x) {
0006   auto xx = std::min(std::abs(x), 5.f);
0007   xx *= xx;
0008   return std::copysign(std::sqrt(1.f - unsafe_expf<4>(-xx * (1.f + 0.2733f / (1.f + 0.147f * xx)))), x);
0009   // return std::sqrt(1.f- std::exp(-x*x*(1.f+0.2733f/(1.f+0.147f*x*x)) ));
0010 }
0011 
0012 #endif