[squeak-dev] Missing mathematical functions in Float

Levente Uzonyi leves at elte.hu
Sat Jan 30 02:28:07 UTC 2010


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



More information about the Squeak-dev mailing list