MCPcopy Create free account
hub / github.com/FastLED/FastLED / pow

Method pow

src/fl/math/fixed_point/base.h:234–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232 }
233
234 static FASTLED_FORCE_INLINE Derived pow(Derived base, Derived exp) {
235 if (base.mValue <= 0) return Derived();
236 constexpr Derived one(1.0f);
237 if (exp.mValue == 0) return one;
238 if (base == one) return one;
239 // Snap base values within ~2 ULPs of 1.0 to exactly 1.0 to dodge the
240 // log2(1+t) minimax polynomial's upper-endpoint residual (off by
241 // 0.000443 at t=1, which amplifies via exp2 to ~50-100 LSB at u16
242 // scale). See #2969.
243 constexpr raw_type kNearOneEpsilon = static_cast<raw_type>(2);
244 constexpr raw_type kOneRaw = static_cast<raw_type>(Derived::SCALE);
245 if (base.mValue >= static_cast<raw_type>(kOneRaw - kNearOneEpsilon) &&
246 base.mValue <= kOneRaw) {
247 return one;
248 }
249 return exp2_fp(exp * log2_fp(base));
250 }
251
252 // ---- Member function versions (operate on *this) -----------------------
253

Callers

nothing calls this directly

Calls 3

exp2_fpFunction · 0.85
log2_fpFunction · 0.85
DerivedClass · 0.50

Tested by

no test coverage detected