34 template <
typename IntT, detail::enable_if_
integer_t<IntT> = 0>
39 template <
typename OtherFP>
40 constexpr s8x8(
const OtherFP& other,
77 static_cast<u16
>(
mValue) +
static_cast<u16
>(b.mValue)));
82 static_cast<u16
>(
mValue) -
static_cast<u16
>(b.mValue)));
87 static_cast<u16
>(0) -
static_cast<u16
>(
mValue)));
116 return from_raw(a.mValue % b.mValue);
133 return from_raw(
x.mValue < 0 ? -
x.mValue :
x.mValue);
137 return x.mValue > 0 ? 1 : (
x.mValue < 0 ? -1 : 0);
141 return a + (b - a) *
t;
145 return x < lo ? lo : (
x > hi ? hi :
x);
153 constexpr s8x8 zero(0.0f);
154 constexpr s8x8 one(1.0f);
155 constexpr s8x8 two(2.0f);
156 constexpr s8x8 three(3.0f);
157 s8x8 t =
clamp((
x - edge0) / (edge1 - edge0), zero, one);
158 return t *
t * (three - two *
t);
164 constexpr s8x8 one(1.0f);
165 constexpr s8x8 pi_over_2(1.5707963f);
166 bool neg =
x.mValue < 0;
178 constexpr s8x8 pi(3.1415926f);
179 constexpr s8x8 pi_over_2(1.5707963f);
180 if (
x.mValue == 0 &&
y.mValue == 0)
return s8x8();
181 if (
x.mValue == 0)
return y.mValue > 0 ? pi_over_2 : -pi_over_2;
182 if (
y.mValue == 0)
return x.mValue > 0 ?
s8x8() : pi;
191 if (
x.mValue < 0) a = pi - a;
192 if (
y.mValue < 0) a = -a;
197 constexpr s8x8 one(1.0f);
202 constexpr s8x8 one(1.0f);
218 if (base.mValue <= 0)
return s8x8();
219 constexpr s8x8 one(1.0f);
220 if (
exp.mValue == 0)
return one;
221 if (base == one)
return one;
224 constexpr i16 kOneRaw =
static_cast<i16
>(
SCALE);
225 if (base.mValue >=
static_cast<i16
>(kOneRaw - 2) &&
226 base.mValue <= kOneRaw) {
313 : (v & 0x00000002u) ? r + 1
322 u32 val =
static_cast<u32
>(
x.mValue);
327 t =
static_cast<i32
>(
330 t =
static_cast<i32
>(
335 constexpr int IFRAC = 16;
336 constexpr i32 c0 = 94528;
337 constexpr i32 c1 = -45814;
338 constexpr i32 c2 = 23821;
339 constexpr i32 c3 = -6986;
341 i32 t16 =
static_cast<i32
>(
t) << (IFRAC -
FRAC_BITS);
344 acc = c2 +
static_cast<i32
>((
static_cast<i64>(acc) * t16) >> IFRAC);
345 acc = c1 +
static_cast<i32
>((
static_cast<i64>(acc) * t16) >> IFRAC);
346 acc = c0 +
static_cast<i32
>((
static_cast<i64>(acc) * t16) >> IFRAC);
347 i32 frac_part =
static_cast<i32
>((
static_cast<i64>(acc) * t16) >> IFRAC);
349 i16 frac8 =
static_cast<i16
>(frac_part >> (IFRAC -
FRAC_BITS));
359 s8x8 fr =
x - fl_val;
365 int_pow =
static_cast<i32
>(
SCALE) << n;
367 int_pow =
static_cast<i32
>(
SCALE) >> (-n);
371 constexpr int IFRAC = 16;
372 constexpr i32 d0 = 45427;
373 constexpr i32 d1 = 15775;
374 constexpr i32 d2 = 3497;
375 constexpr i32 d3 = 836;
380 acc = d2 +
static_cast<i32
>((
static_cast<i64>(acc) * fr16) >> IFRAC);
381 acc = d1 +
static_cast<i32
>((
static_cast<i64>(acc) * fr16) >> IFRAC);
382 acc = d0 +
static_cast<i32
>((
static_cast<i64>(acc) * fr16) >> IFRAC);
383 constexpr i32 one16 =
static_cast<i32
>(1) << IFRAC;
384 i32 frac_pow16 = one16 +
static_cast<i32
>((
static_cast<i64>(acc) * fr16) >> IFRAC);
386 i32 frac_pow8 = frac_pow16 >> (IFRAC -
FRAC_BITS);
396 return static_cast<u32
>(
404 constexpr s8x8 c0(0.9998779297f);
405 constexpr s8x8 c1(-0.3269348145f);
406 constexpr s8x8 c2(0.1594085693f);
407 constexpr s8x8 c3(-0.0472106934f);
409 return t * (c0 + t2 * (c1 + t2 * (c2 + t2 * c3)));
static constexpr FASTLED_FORCE_INLINE s8x8 clamp(s8x8 x, s8x8 lo, s8x8 hi) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s8x8 ceil(s8x8 x) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x8 ceil() const FL_NOEXCEPT
static FASTLED_FORCE_INLINE s8x8 atan(s8x8 x) FL_NOEXCEPT
static constexpr int _highest_bit_step(u32 v, int r) FL_NOEXCEPT
static constexpr i32 RAD_TO_24
static FASTLED_FORCE_INLINE s8x8 smoothstep(s8x8 edge0, s8x8 edge1, s8x8 x) FL_NOEXCEPT
static FASTLED_FORCE_INLINE s8x8 acos(s8x8 x) FL_NOEXCEPT
constexpr bool operator!=(s8x8 b) const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x8 operator+(s8x8 b) const FL_NOEXCEPT
static FASTLED_FORCE_INLINE s8x8 asin(s8x8 x) FL_NOEXCEPT
constexpr float to_float() const FL_NOEXCEPT
constexpr s8x8() FL_NOEXCEPT=default
constexpr FASTLED_FORCE_INLINE int sign() const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s8x8 fract(s8x8 x) FL_NOEXCEPT
static FASTLED_FORCE_INLINE s8x8 sin(s8x8 angle) FL_NOEXCEPT
constexpr bool operator>(s8x8 b) const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s8x8 sqrt(s8x8 x) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s8x8 abs(s8x8 x) FL_NOEXCEPT
static FASTLED_FORCE_INLINE s8x8 atan2(s8x8 y, s8x8 x) FL_NOEXCEPT
FASTLED_FORCE_INLINE s8x8 atan() const FL_NOEXCEPT
constexpr s8x8(i16 raw, RawTag) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s8x8 rsqrt(s8x8 x) FL_NOEXCEPT
constexpr bool operator<(s8x8 b) const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x8 floor() const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s8x8 lerp(s8x8 a, s8x8 b, s8x8 t) FL_NOEXCEPT
constexpr i16 to_int() const FL_NOEXCEPT
FASTLED_FORCE_INLINE s8x8 acos() const FL_NOEXCEPT
static constexpr int FRAC_BITS
constexpr FASTLED_FORCE_INLINE s8x8 rsqrt() const FL_NOEXCEPT
constexpr bool operator==(s8x8 b) const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x8 fract() const FL_NOEXCEPT
FASTLED_FORCE_INLINE s8x8 sin() const FL_NOEXCEPT
constexpr i16 raw() const FL_NOEXCEPT
constexpr bool operator>=(s8x8 b) const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x8 operator-(s8x8 b) const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE u32 angle_to_a24(s8x8 angle) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE int highest_bit(u32 v) FL_NOEXCEPT
static FASTLED_FORCE_INLINE void sincos(s8x8 angle, s8x8 &out_sin, s8x8 &out_cos) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x8 abs() const FL_NOEXCEPT
static FASTLED_FORCE_INLINE s8x8 atan_unit(s8x8 t) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s8x8 mod(s8x8 a, s8x8 b) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x8 sqrt() const FL_NOEXCEPT
constexpr s8x8(const OtherFP &other, typename fl::enable_if<(OtherFP::INT_BITS<=INT_BITS) &&(OtherFP::FRAC_BITS<=FRAC_BITS) &&(OtherFP::INT_BITS !=INT_BITS||OtherFP::FRAC_BITS !=FRAC_BITS), int >::type=0) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x8 operator/(s8x8 b) const FL_NOEXCEPT
friend constexpr s8x8 operator*(i16 scalar, s8x8 fp) FL_NOEXCEPT
static FASTLED_FORCE_INLINE s8x8 log2_fp(s8x8 x) FL_NOEXCEPT
constexpr bool operator<=(s8x8 b) const FL_NOEXCEPT
static FASTLED_FORCE_INLINE s8x8 pow(s8x8 base, s8x8 exp) FL_NOEXCEPT
FASTLED_FORCE_INLINE s8x8 cos() const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x8 operator>>(int shift) const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s8x8 from_raw(i16 raw) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x8 operator*(i16 scalar) const FL_NOEXCEPT
static constexpr int INT_BITS
constexpr FASTLED_FORCE_INLINE s8x8 operator*(s8x8 b) const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE int sign(s8x8 x) FL_NOEXCEPT
static FASTLED_FORCE_INLINE s8x8 exp2_fp(s8x8 x) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s8x8 floor(s8x8 x) FL_NOEXCEPT
FASTLED_FORCE_INLINE s8x8 asin() const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x8 operator-() const FL_NOEXCEPT
constexpr s8x8(IntT n) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s8x8 step(s8x8 edge, s8x8 x) FL_NOEXCEPT
static FASTLED_FORCE_INLINE s8x8 cos(s8x8 angle) FL_NOEXCEPT
static constexpr i32 SCALE
#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