Registered Member
|
Hi,
Is it possible to use approximate division or sqrt for EIgen vector elements ? Thanx Laurent |
Moderator
|
for division, yes if you compile with -ffast-math, but that's the compiler which is doing the job (tested with gccc and clang):
For a1 = a1/a2, Eigen calls _mm_div_ps(a1,a2) and the compiler generates:
For a1 = a2.sqrt(), by default Eigen already generates fast code (unless you define EIGEN_FAST_MATH=0)
|
Registered Member
|
Thank you very much for this detailed answer.
I wonder about the interest of having a separate .fast_div() method in order to control precisely where you want approximate math and where you want to maintain IEEE compliant operations... |
Moderator
|
yes, adding fast* methods (fastRSqrt, fastSqrt, fastCos, fastSin, etc.) is an easy way to go, but it does not scale well and clutter the API. This question should be addressed on a more general level. Perhaps, we could take inspiration from boost::math's policies: http://www.boost.org/doc/libs/1_60_0/li ... orial.html
This is also related to bug http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1159. |
Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]