Closed yurivict closed 7 years ago
Thank you! The continuous integration builds on Travis are currently failing for reasons unrelated to your PR. Let's wait until @uekstrom and/or other developers can have a say.
The "correct" way would be to figure out what numeric type (T=double etc) libtaylor uses, and do cbrt(T(2)) to get the cube root with the right precision. But I support this commit because it is consistent with other constants in the code, which are in double precision.
Thanks Ulf for weighing in. I have two questions:
It is not so easy to do cleanly, see how to extend numeric_limits in c++ with your own numeric type. Using double is almost always the right choice.
Ulf
On Tue, 13 Jun 2017 at 18:47, Roberto Di Remigio notifications@github.com wrote:
Thanks Ulf for weighing in. I have two questions:
- Should all similar instances in XCFun be tracked down and corrected in a similar way?
- Just out of curiosity, is there a way to implement the correct approach?
— You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub https://github.com/dftlibs/xcfun/pull/27#issuecomment-308178251, or mute the thread https://github.com/notifications/unsubscribe-auth/AMeumXa9OWvysz_yUusP4ahLvtaIh6DRks5sDr0GgaJpZM4N4uTS .
Would a construct using std::is_same
do the trick? It's C++11 though...
It's not immediate clear to me how the code would look. The problem is that the return value of sqrt(x) is based on the type of x, not on the type assigned to. We have the same problem with constants such as pi. C solved this nicely in the "C world" by using doubles, but I don't know if there is a general solution in C++. The QD high precision library struggles with this issues as well. Of course anything is possible if you accept ugly code, but the formulas a difficult enough to read as it is. C++11 is no problem, I wish I had time to rewrite the whole library in more modern C++.
This resolves https://github.com/dftlibs/xcfun/issues/22