def tanh_exponential
stelliferous@0.0.2.0 · math_fp32.bend:103
import stelliferous@0.0.2.0/math_fp32.bend as MathFp32
import Base
103def tanh_exponential(+a: F32,+biased: F32,x: F32) -> F32:
104 +n = (biased - 12582912.0 : F32)
105 +r = (((a * 2.0 : F32) - n * 0.693359375 : F32) - n * F32.neg(0.00021219444005469058) : F32)
106 +q = from_bits((1065353216 - U32.shln(F32.bits(biased),23n) : U32))
107 +t = F32.min(0.75,a)
108 +small = tanh_small(t,(t * t : F32))
109 +large = (1.0 - 2.0 * (q / ((1.0 + q : F32) + (r + tanh_remainder(r) : F32) : F32) : F32) : F32)
110 +mask = (0 - U32.shrn((F32.bits(a) - 1061158912 : U32),31n) : U32)
111 tanh_finish(x,selected(mask,small,large))