34 template <
typename IntT, detail::enable_if_
integer_t<IntT> = 0>
39 template <
typename OtherFP>
40 constexpr s8x24(
const OtherFP& other,
77 static_cast<u32
>(
mValue) +
static_cast<u32
>(b.mValue)));
82 static_cast<u32
>(
mValue) -
static_cast<u32
>(b.mValue)));
115 return from_raw(a.mValue % b.mValue);
132 return from_raw(
x.mValue < 0 ? -
x.mValue :
x.mValue);
136 return x.mValue > 0 ? 1 : (
x.mValue < 0 ? -1 : 0);
140 return a + (b - a) *
t;
144 return x < lo ? lo : (
x > hi ? hi :
x);
152 constexpr s8x24 zero(0.0f);
153 constexpr s8x24 one(1.0f);
154 constexpr s8x24 two(2.0f);
155 constexpr s8x24 three(3.0f);
156 s8x24 t =
clamp((
x - edge0) / (edge1 - edge0), zero, one);
157 return t *
t * (three - two *
t);
163 constexpr s8x24 one(1.0f);
164 constexpr s8x24 pi_over_2(1.5707963f);
165 bool neg =
x.mValue < 0;
177 constexpr s8x24 pi(3.1415926f);
178 constexpr s8x24 pi_over_2(1.5707963f);
179 if (
x.mValue == 0 &&
y.mValue == 0)
return s8x24();
180 if (
x.mValue == 0)
return y.mValue > 0 ? pi_over_2 : -pi_over_2;
181 if (
y.mValue == 0)
return x.mValue > 0 ?
s8x24() : pi;
190 if (
x.mValue < 0) a = pi - a;
191 if (
y.mValue < 0) a = -a;
196 constexpr s8x24 one(1.0f);
201 constexpr s8x24 one(1.0f);
217 if (base.mValue <= 0)
return s8x24();
218 constexpr s8x24 one(1.0f);
219 if (
exp.mValue == 0)
return one;
220 if (base == one)
return one;
223 constexpr i32 kOneRaw =
static_cast<i32
>(
SCALE);
224 if (base.mValue >= (kOneRaw - 2) && base.mValue <= kOneRaw) {
311 : (v & 0x00000002u) ? r + 1
320 u32 val =
static_cast<u32
>(
x.mValue);
325 t =
static_cast<i32
>(
328 t =
static_cast<i32
>(
333 constexpr int IFRAC = 24;
334 constexpr i64 c0 = 24189248LL;
335 constexpr i64 c1 = -11728384LL;
336 constexpr i64 c2 = 6098176LL;
337 constexpr i64 c3 = -1788416LL;
342 acc = c2 + ((acc * t24) >> IFRAC);
343 acc = c1 + ((acc * t24) >> IFRAC);
344 acc = c0 + ((acc * t24) >> IFRAC);
345 i64 frac_part = (acc * t24) >> IFRAC;
346 i32 frac24 =
static_cast<i32
>(frac_part);
347 return from_raw(
static_cast<i32
>(
static_cast<u32
>(int_part) <<
FRAC_BITS) + frac24);
361 int_pow =
static_cast<i32
>(
SCALE) << n;
363 int_pow =
static_cast<i32
>(
SCALE) >> (-n);
367 constexpr int IFRAC = 24;
368 constexpr i64 d0 = 11629376LL;
369 constexpr i64 d1 = 4038400LL;
370 constexpr i64 d2 = 895232LL;
371 constexpr i64 d3 = 214016LL;
376 acc = d2 + ((acc * fr24) >> IFRAC);
377 acc = d1 + ((acc * fr24) >> IFRAC);
378 acc = d0 + ((acc * fr24) >> IFRAC);
379 constexpr i64 one24 = 1LL << IFRAC;
380 i64 frac_pow24 = one24 + ((acc * fr24) >> IFRAC);
391 return static_cast<u32
>(
399 constexpr s8x24 c0(0.9998779297f);
400 constexpr s8x24 c1(-0.3269348145f);
401 constexpr s8x24 c2(0.1594085693f);
402 constexpr s8x24 c3(-0.0472106934f);
404 return t * (c0 + t2 * (c1 + t2 * (c2 + t2 * c3)));
constexpr bool operator==(s8x24 b) const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x24 floor() const FL_NOEXCEPT
constexpr i32 to_int() const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s8x24 mod(s8x24 a, s8x24 b) FL_NOEXCEPT
FASTLED_FORCE_INLINE s8x24 cos() const FL_NOEXCEPT
static constexpr int _highest_bit_step(u32 v, int r) FL_NOEXCEPT
static constexpr i32 SCALE
static constexpr int INT_BITS
static FASTLED_FORCE_INLINE s8x24 asin(s8x24 x) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x24 rsqrt() const FL_NOEXCEPT
constexpr s8x24(i32 raw, RawTag) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x24 operator/(s8x24 b) const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s8x24 sqrt(s8x24 x) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x24 abs() const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s8x24 from_raw(i32 raw) FL_NOEXCEPT
FASTLED_FORCE_INLINE s8x24 acos() const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x24 sqrt() const FL_NOEXCEPT
constexpr float to_float() const FL_NOEXCEPT
constexpr s8x24() FL_NOEXCEPT=default
static FASTLED_FORCE_INLINE s8x24 pow(s8x24 base, s8x24 exp) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x24 ceil() const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE int sign() const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x24 operator+(s8x24 b) const FL_NOEXCEPT
static FASTLED_FORCE_INLINE s8x24 cos(s8x24 angle) FL_NOEXCEPT
static FASTLED_FORCE_INLINE s8x24 acos(s8x24 x) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s8x24 step(s8x24 edge, s8x24 x) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s8x24 abs(s8x24 x) FL_NOEXCEPT
static FASTLED_FORCE_INLINE s8x24 smoothstep(s8x24 edge0, s8x24 edge1, s8x24 x) FL_NOEXCEPT
static FASTLED_FORCE_INLINE s8x24 atan_unit(s8x24 t) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE int sign(s8x24 x) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x24 fract() const FL_NOEXCEPT
static FASTLED_FORCE_INLINE s8x24 atan2(s8x24 y, s8x24 x) FL_NOEXCEPT
constexpr bool operator>(s8x24 b) const FL_NOEXCEPT
FASTLED_FORCE_INLINE s8x24 atan() const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s8x24 lerp(s8x24 a, s8x24 b, s8x24 t) FL_NOEXCEPT
constexpr bool operator>=(s8x24 b) const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s8x24 clamp(s8x24 x, s8x24 lo, s8x24 hi) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x24 operator>>(int shift) const FL_NOEXCEPT
FASTLED_FORCE_INLINE s8x24 sin() const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x24 operator-(s8x24 b) const FL_NOEXCEPT
constexpr s8x24(IntT n) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x24 operator-() const FL_NOEXCEPT
static constexpr i32 RAD_TO_24
static constexpr int FRAC_BITS
constexpr bool operator<(s8x24 b) const FL_NOEXCEPT
static FASTLED_FORCE_INLINE s8x24 sin(s8x24 angle) FL_NOEXCEPT
static FASTLED_FORCE_INLINE s8x24 exp2_fp(s8x24 x) FL_NOEXCEPT
static FASTLED_FORCE_INLINE s8x24 atan(s8x24 x) FL_NOEXCEPT
constexpr s8x24(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
static constexpr FASTLED_FORCE_INLINE int highest_bit(u32 v) FL_NOEXCEPT
static FASTLED_FORCE_INLINE s8x24 log2_fp(s8x24 x) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s8x24 floor(s8x24 x) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s8x24 fract(s8x24 x) FL_NOEXCEPT
constexpr bool operator<=(s8x24 b) const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE u32 angle_to_a24(s8x24 angle) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s8x24 rsqrt(s8x24 x) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE s8x24 ceil(s8x24 x) FL_NOEXCEPT
FASTLED_FORCE_INLINE s8x24 asin() const FL_NOEXCEPT
friend constexpr s8x24 operator*(i32 scalar, s8x24 fp) FL_NOEXCEPT
static FASTLED_FORCE_INLINE void sincos(s8x24 angle, s8x24 &out_sin, s8x24 &out_cos) FL_NOEXCEPT
constexpr i32 raw() const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x24 operator*(i32 scalar) const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE s8x24 operator*(s8x24 b) const FL_NOEXCEPT
constexpr bool operator!=(s8x24 b) const 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 u32 isqrt64(u64 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