Merge pull request #808 from lovell/prefer-sqrt-to-pow-0.5

Prefer ~10x faster sqrt instead of pow when y=0.5
This commit is contained in:
John Cupitt 2017-11-17 22:11:23 +00:00 committed by GitHub
commit cd898c52de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -139,7 +139,9 @@ vips_math2_build( VipsObject *object )
\
/* Division by zero! Difficult to report tho' \
*/ \
(Y) = (left == 0.0 && right < 0.0) ? 0.0 : pow( left, right ); \
(Y) = (right == 0.5) \
? sqrt( left ) \
: (left == 0.0 && right < 0.0) ? 0.0 : pow( left, right ); \
}
#define WOP( Y, X, E ) POW( Y, E, X )