log (natural) - fast approximate version Uses IEEE 754 bit extraction + minimax quadratic. ~1.5% max relative error. ~5-10x faster than standard logf on embedded targets.
| 404 | // Uses IEEE 754 bit extraction + minimax quadratic. ~1.5% max relative error. |
| 405 | // ~5-10x faster than standard logf on embedded targets. |
| 406 | inline float fast_logf_approx(float x) FL_NOEXCEPT { |
| 407 | union { float f; u32 i; } u; |
| 408 | u.f = x; |
| 409 | i32 e = static_cast<i32>(u.i >> 23) - 127; |
| 410 | u.i = (u.i & 0x007FFFFFu) | 0x3F800000u; |
| 411 | float m = u.f; |
| 412 | float t = m - 1.0f; |
| 413 | float log2m = t * (1.3327635f + t * (-0.3327635f)); |
| 414 | return (static_cast<float>(e) + log2m) * 0.6931471805599453f; |
| 415 | } |
| 416 | |
| 417 | // log (natural) |
| 418 | inline float logf(float value) FL_NOEXCEPT { return log_impl_float(value); } |
no outgoing calls
no test coverage detected