Hi,
recently we had to use tanh (hyperbolic tangent) and found that it's not in the image. So we rolled our own, but I remembered that we have FloatMathPlugin which has tanh. I tried it and it worked (the primitive):
Float >> #tanh
| exp2self | <primitive: 'primitiveTanH' module: 'FloatMathPlugin'> ^((exp2self := (self + self) exp) - 1.0) / (exp2self + 1.0)
Shouldn't we add all the functions of FloatMathPlugin to Float and the primitives to existing methods?
(Adding the primitive to #cos gave 2.2x speedup.)
Levente
Levente Uzonyi wrote:
recently we had to use tanh (hyperbolic tangent) and found that it's not in the image. So we rolled our own, but I remembered that we have FloatMathPlugin which has tanh. I tried it and it worked (the primitive):
Float >> #tanh
| exp2self | <primitive: 'primitiveTanH' module: 'FloatMathPlugin'> ^((exp2self := (self + self) exp) - 1.0) / (exp2self + 1.0)
Shouldn't we add all the functions of FloatMathPlugin to Float and the primitives to existing methods?
Could do. I'll point out though that these primitives are designed to produce bit-identical results (based on fdlibm) and not for speed. But certainly, where it actually improves speed we should probably take advantage of it.
Cheers, - Andreas
squeak-dev@lists.squeakfoundation.org