This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Define 3-argument overloads of std::hypot for C++17 (P0030R1)


On Tue, 27 Sep 2016, Jonathan Wakely wrote:

This adds the new 3D std::hypot() functions. This implementation seems
to be faster than the naïve sqrt(x*x + y*y + z*z) implementation, or
hypot(hypot(x, y), z), and should be a bit more accurate at very large
or very small values due to reducing the arguments by the largest one.
Improvements welcome though, as this is not my forte.

I understand the claims about accuracy, but the one about speed seems very surprising to me. Was your test specifically with denormals on not-so-recent hardware, or specifically when sqrt does a library call for errno? Otherwise, I have a hard time believing that 3 multiplications and 2 additions can be slower than 4 multiplications, 2 additions, plus a bunch of tests and divisions.

--
Marc Glisse


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]