sleef icon indicating copy to clipboard operation
sleef copied to clipboard

Range of `xexpf` to clamp to 0 and inf in scalar vs simd

Open aconz2 opened this issue 9 months ago • 2 comments

I noticed that the scalar and simd xexpf versions seem to use slightly different constants to clamp to 0 or inf. In scalar, it is -104 and 104, but simd uses -104 and 100. Is this intentional?

Scalar https://github.com/shibatch/sleef/blob/553311487213f3c2b578a103435383ab2837cd73/src/libm/sleefsp.c#L1174-L1175

SIMD https://github.com/shibatch/sleef/blob/553311487213f3c2b578a103435383ab2837cd73/src/libm/sleefsimdsp.c#L2047-L2048

It isn't really making a difference to me as I can guarantee the inputs will be inside that range, so mainly a curiosity question. Thanks for making this project, it is really nice.

aconz2 avatar Mar 21 '25 14:03 aconz2

Thank you for pointing out. I will fix it.

shibatch avatar Mar 21 '25 15:03 shibatch

This does not need to be fixed, because the value of expf becomes infinity at around 88.8. This clamping is only for preventing the results of internal computation from overflowing.

shibatch avatar Mar 22 '25 02:03 shibatch