Added std::assoc_laguerre and std::laguerre from C++17, 29.9.5 Mathematical special functions [sf.cmath].
Resubmitted parts of Added implementations of five Mathematical Special Functions added in C++17
Notes:
- The algorithm is the same one that is used in boost and libstdc++. Just like boost (but unlike gcc-8.3.1), I use double internally for the float implementation and long double for the double implementation. This is kind of a last resort to achieve sufficiently accurate results ... considering the large number of floating-point operations involved for large n. Otherwise, we'd get less than 1% accuracy for float even in the range n<128 targeted by the standard. That's the case in libstdc++ (with gcc-8.3.1) . (Confirmed that by comparing the results for float and long double).
- I haven't included a comparison with Visual Studio 2017 this time. It turns out, they simply use boost-1.66 internally and export the implementations in msvcp140_2.dll (which is exclusively for sf.cmath functions) to hide the boost headers. Interestingly, the special functions in boost have a lot of (partly surprising) dependencies across boost: lexical_cast, smart_ptr, preprocessor, concept_check, array, container, etc.
- The implementation is inline just like libstdc++ but unlike Visual Studio 2017. The latter thus runs into AVX-SSE transition penalties: on my system, the dll being loaded (msvcp140_2.dll) is compiled without AVX and uses SSE instructions (floating-point operations usually do that). The inline implementation avoids that problem completely.
Related revisions: