Vectorized erf returns NaN at ±inf instead of ±1
## Description Eigen's vectorized `erf` implementation returns NaN at ±inf instead of ±1. The mathematical definition is: - erf(+inf) = +1 - erf(-inf) = -1 Both `std::erf` and MPFR return the correct values. ## How to reproduce ```cpp #include <Eigen/Core> #include <iostream> #include <cmath> int main() { Eigen::ArrayXd x(2); x << -std::numeric_limits<double>::infinity(), std::numeric_limits<double>::infinity(); Eigen::ArrayXd y = x.erf(); std::cout << "Eigen erf(-inf) = " << y(0) << " (expected -1)\n"; std::cout << "Eigen erf(+inf) = " << y(1) << " (expected +1)\n"; std::cout << "std::erf(-inf) = " << std::erf(-INFINITY) << "\n"; std::cout << "std::erf(+inf) = " << std::erf(INFINITY) << "\n"; } ``` Output: ``` Eigen erf(-inf) = -nan (expected -1) Eigen erf(+inf) = nan (expected +1) ``` ## Context Found using the ULP accuracy measurement tool (`test/ulp_accuracy.cpp`, MR !2153). When testing `erf` in double precision over the full range, ~24.6% of sampled values (those beyond the erf saturation threshold) show as overflow errors because of the NaN propagation from ±inf inputs. The same bug likely affects float as well (the vectorized implementation is shared).
issue