Make hyperbolic implementation more generic

This commit factorize hyperbolic functions optmizations by moving
similar code for scalar and SIMD into a generic implementation.