static inline v4sf vfastlog2 (v4sf x) { union { v4sf f; v4si i; } vx = { x }; union { v4si i; v4sf f; } mx; mx.i = (vx.i & v4sil (0x007FFFFF)) | v4sil (0x3f000000); v4sf y = v4si_to_v4sf (vx.i); y *= v4sfl (1.1920928955078125e-7f); const v4sf c_124_22551499 = v4sfl (124.22551499f); const v4sf c_1_498030302 = v4sfl (1.498030302f); const v4sf c_1_725877999 = v4sfl (1.72587999f); const v4sf c_0_3520087068 = v4sfl (0.3520887068f); return y - c_124_22551499 - c_1_498030302 * mx.f - c_1_725877999 / (c_0_3520087068 + mx.f); }
int main (int argc, char *argv[]) { char buf[4096]; (void) argc; float x; for (x = -50; x > -1000; x -= 100) { assert (fastexp (x) >= 0); assert (fasterexp (x) >= 0); #ifdef __SSE2__ v4sf vx = v4sfl (x); assert (v4sf_index (vfastexp (vx), 0) >= 0); assert (v4sf_index (vfasterexp (vx), 0) >= 0); #endif } srand48 (69); strncpy (buf, argv[0], sizeof (buf) - 5); strncat (buf, ".out", 5); fclose (stderr); stderr = fopen (buf, "w"); test_fastexp (); test_fasterexp (); test_vfastexp (); test_vfasterexp (); time_fastexp (); time_fasterexp (); time_vfastexp (); time_vfasterexp (); return 0; }
static inline v4sf vfastlog (v4sf x) { const v4sf c_0_69314718 = v4sfl (0.69314718f); return c_0_69314718 * vfastlog2 (x); }