34 template <
typename IntT, detail::enable_if_
integer_t<IntT> = 0>
66 static_cast<u16
>(
mValue) +
static_cast<u16
>(b.mValue)));
71 static_cast<u16
>(
mValue) -
static_cast<u16
>(b.mValue)));
76 static_cast<u16
>(0) -
static_cast<u16
>(
mValue)));
105 return from_raw(a.mValue % b.mValue);
122 return from_raw(
x.mValue < 0 ? -
x.mValue :
x.mValue);
126 return x.mValue > 0 ? 1 : (
x.mValue < 0 ? -1 : 0);
130 return a + (b - a) *
t;
134 return x < lo ? lo : (
x > hi ? hi :
x);
142 constexpr s12x4 zero(0.0f);
143 constexpr s12x4 one(1.0f);
144 constexpr s12x4 two(2.0f);
145 constexpr s12x4 three(3.0f);
146 s12x4 t =
clamp((
x - edge0) / (edge1 - edge0), zero, one);
147 return t *
t * (three - two *
t);
153 constexpr s12x4 one(1.0f);
154 constexpr s12x4 pi_over_2(1.5707963f);
155 bool neg =
x.mValue < 0;
167 constexpr s12x4 pi(3.1415926f);
168 constexpr s12x4 pi_over_2(1.5707963f);
169 if (
x.mValue == 0 &&
y.mValue == 0)
return s12x4();
170 if (
x.mValue == 0)
return y.mValue > 0 ? pi_over_2 : -pi_over_2;
171 if (
y.mValue == 0)
return x.mValue > 0 ?
s12x4() : pi;
180 if (
x.mValue < 0) a = pi - a;
181 if (
y.mValue < 0) a = -a;
186 constexpr s12x4 one(1.0f);
191 constexpr s12x4 one(1.0f);
207 if (base.mValue <= 0)
return s12x4();
208 constexpr s12x4 one(1.0f);
209 if (
exp.mValue == 0)
return one;
210 if (base == one)
return one;
213 constexpr i16 kOneRaw =
static_cast<i16
>(
SCALE);
214 if (base.mValue >=
static_cast<i16
>(kOneRaw - 2) &&
215 base.mValue <= kOneRaw) {
302 : (v & 0x00000002u) ? r + 1
311 u32 val =
static_cast<u32
>(
x.mValue);
316 t =
static_cast<i32
>(
319 t =
static_cast<i32
>(
324 constexpr int IFRAC = 12;
325 constexpr i32 c0 = 5907;
326 constexpr i32 c1 = -2864;
327 constexpr i32 c2 = 1489;
328 constexpr i32 c3 = -437;
330 i32 t12 =
static_cast<i32
>(
t) << (IFRAC -
FRAC_BITS);
333 acc = c2 + ((acc * t12) >> IFRAC);
334 acc = c1 + ((acc * t12) >> IFRAC);
335 acc = c0 + ((acc * t12) >> IFRAC);
336 i32 frac_part = (acc * t12) >> IFRAC;
338 i16 frac4 =
static_cast<i16
>(frac_part >> (IFRAC -
FRAC_BITS));
339 return from_raw(
static_cast<i16
>((
static_cast<i32
>(
static_cast<u32
>(int_part) <<
FRAC_BITS)) + frac4));
353 int_pow =
static_cast<i32
>(
SCALE) << n;
355 int_pow =
static_cast<i32
>(
SCALE) >> (-n);
359 constexpr int IFRAC = 12;
360 constexpr i32 d0 = 2839;
361 constexpr i32 d1 = 986;
362 constexpr i32 d2 = 219;
363 constexpr i32 d3 = 52;
368 acc = d2 + ((acc * fr12) >> IFRAC);
369 acc = d1 + ((acc * fr12) >> IFRAC);
370 acc = d0 + ((acc * fr12) >> IFRAC);
371 constexpr i32 one12 = 1 << IFRAC;
372 i32 frac_pow12 = one12 + ((acc * fr12) >> IFRAC);
374 i32 frac_pow4 = frac_pow12 >> (IFRAC -
FRAC_BITS);
384 return static_cast<u32
>(
392 constexpr s12x4 c0(0.9998779297f);
393 constexpr s12x4 c1(-0.3269348145f);
394 constexpr s12x4 c2(0.1594085693f);
395 constexpr s12x4 c3(-0.0472106934f);
397 return t * (c0 + t2 * (c1 + t2 * (c2 + t2 * c3)));
constexpr FASTLED_FORCE_INLINE s12x4 sqrt() const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s12x4 rsqrt(s12x4 x) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s12x4 step(s12x4 edge, s12x4 x) FL_NOEXCEPT
constexpr i16 raw() const FL_NOEXCEPT
constexpr bool operator>(s12x4 b) const FL_NOEXCEPT
static constexpr int FRAC_BITS
constexpr bool operator<(s12x4 b) const FL_NOEXCEPT
constexpr i16 to_int() const FL_NOEXCEPT
static FASTLED_FORCE_INLINE s12x4 smoothstep(s12x4 edge0, s12x4 edge1, s12x4 x) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s12x4 ceil(s12x4 x) FL_NOEXCEPT
static FASTLED_FORCE_INLINE s12x4 atan2(s12x4 y, s12x4 x) FL_NOEXCEPT
static FASTLED_FORCE_INLINE void sincos(s12x4 angle, s12x4 &out_sin, s12x4 &out_cos) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s12x4 floor(s12x4 x) FL_NOEXCEPT
constexpr bool operator>=(s12x4 b) const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s12x4 abs() const FL_NOEXCEPT
friend constexpr s12x4 operator*(i16 scalar, s12x4 fp) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE int highest_bit(u32 v) FL_NOEXCEPT
static constexpr int INT_BITS
FASTLED_FORCE_INLINE s12x4 acos() const FL_NOEXCEPT
FASTLED_FORCE_INLINE s12x4 cos() const FL_NOEXCEPT
static FASTLED_FORCE_INLINE s12x4 atan_unit(s12x4 t) FL_NOEXCEPT
static constexpr i32 RAD_TO_24
constexpr bool operator<=(s12x4 b) const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s12x4 floor() const FL_NOEXCEPT
constexpr s12x4(i16 raw, RawTag) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE int sign() const FL_NOEXCEPT
FASTLED_FORCE_INLINE s12x4 asin() const FL_NOEXCEPT
FASTLED_FORCE_INLINE s12x4 atan() const FL_NOEXCEPT
constexpr float to_float() const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s12x4 operator*(s12x4 b) const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s12x4 sqrt(s12x4 x) FL_NOEXCEPT
static FASTLED_FORCE_INLINE s12x4 pow(s12x4 base, s12x4 exp) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s12x4 ceil() const FL_NOEXCEPT
FASTLED_FORCE_INLINE s12x4 sin() const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s12x4 operator-(s12x4 b) const FL_NOEXCEPT
static FASTLED_FORCE_INLINE s12x4 acos(s12x4 x) FL_NOEXCEPT
constexpr s12x4(IntT n) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s12x4 operator>>(int shift) const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE u32 angle_to_a24(s12x4 angle) FL_NOEXCEPT
static FASTLED_FORCE_INLINE s12x4 atan(s12x4 x) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s12x4 operator-() const FL_NOEXCEPT
static FASTLED_FORCE_INLINE s12x4 cos(s12x4 angle) FL_NOEXCEPT
constexpr bool operator!=(s12x4 b) const FL_NOEXCEPT
static FASTLED_FORCE_INLINE s12x4 sin(s12x4 angle) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s12x4 fract() const FL_NOEXCEPT
static FASTLED_FORCE_INLINE s12x4 exp2_fp(s12x4 x) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s12x4 lerp(s12x4 a, s12x4 b, s12x4 t) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s12x4 mod(s12x4 a, s12x4 b) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s12x4 operator/(s12x4 b) const FL_NOEXCEPT
static FASTLED_FORCE_INLINE s12x4 asin(s12x4 x) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s12x4 clamp(s12x4 x, s12x4 lo, s12x4 hi) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE int sign(s12x4 x) FL_NOEXCEPT
static constexpr i32 SCALE
static constexpr FASTLED_FORCE_INLINE s12x4 fract(s12x4 x) FL_NOEXCEPT
constexpr s12x4() FL_NOEXCEPT=default
constexpr bool operator==(s12x4 b) const FL_NOEXCEPT
static FASTLED_FORCE_INLINE s12x4 log2_fp(s12x4 x) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s12x4 operator+(s12x4 b) const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s12x4 operator*(i16 scalar) const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s12x4 rsqrt() const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s12x4 abs(s12x4 x) FL_NOEXCEPT
static constexpr int _highest_bit_step(u32 v, int r) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s12x4 from_raw(i16 raw) FL_NOEXCEPT
#define constexpr
Declares that it is possible to evaluate a value at compile time, introduced in C++11.
FASTLED_FORCE_INLINE i32 cos32(u32 angle) FL_NOEXCEPT
FASTLED_FORCE_INLINE i32 sin32(u32 angle) FL_NOEXCEPT
expected< T, E > result
Alias for expected (Rust-style naming)
enable_if< is_fixed_point< T >::value, T >::type exp(T x) FL_NOEXCEPT
FL_OPTIMIZE_FUNCTION constexpr u16 isqrt32(u32 x) FL_NOEXCEPT
Base definition for an LED controller.
#define FL_OPTIMIZATION_LEVEL_O3_BEGIN
#define FASTLED_FORCE_INLINE
#define FL_OPTIMIZATION_LEVEL_O3_END