33 template <
typename IntT, detail::enable_if_
integer_t<IntT> = 0>
39 template <
typename OtherFP>
40 constexpr u16x16(
const OtherFP& other,
65#if defined(__riscv) && (__riscv_xlen == 32)
70 asm(
"mul %0, %2, %3\n\t"
72 :
"=&r"(lo),
"=&r"(hi)
74 return from_raw((lo >> 16) | (hi << 16));
143 return a < b ? a : b;
147 return a > b ? a : b;
151 return x < lo ? lo : (
x > hi ? hi :
x);
154#if defined(__riscv) && (__riscv_xlen == 32)
159 return a + (b - a) *
t;
167 constexpr u16x16 zero(0.0f);
168 constexpr u16x16 one(1.0f);
169 constexpr u16x16 two(2.0f);
170 constexpr u16x16 three(3.0f);
172 return t *
t * (three - two *
t);
187 constexpr u16x16 one(1.0f);
188 if (
exp.mValue == 0)
return one;
189 if (base == one)
return one;
190 if (base.mValue == 0)
return u16x16();
193 constexpr u32 kOneRaw =
static_cast<u32
>(
SCALE);
194 if (base.mValue >= (kOneRaw - 2u) && base.mValue <= kOneRaw) {
213 : (v & 0x00000002u) ? r + 1
224 if (msb < 0)
return u16x16();
236 constexpr int IFRAC = 24;
237 constexpr u64 c0 = 24189248ULL;
238 constexpr u64 c1 = 5049984ULL;
244 u64 acc = c0 + ((c1 * t24) >> IFRAC);
245 u64 frac_part = (acc * t24) >> IFRAC;
248 u32 frac16 =
static_cast<u32
>(frac_part >> (IFRAC -
FRAC_BITS));
262 u32 int_pow = (
SCALE) << n;
266 constexpr int IFRAC = 24;
267 constexpr u64 d0 = 11629376ULL;
268 constexpr u64 d1 = 4038400ULL;
269 constexpr u64 d2 = 895232ULL;
270 constexpr u64 d3 = 214016ULL;
277 acc = d2 + ((acc * fr24) >> IFRAC);
278 acc = d1 + ((acc * fr24) >> IFRAC);
279 acc = d0 + ((acc * fr24) >> IFRAC);
280 constexpr u64 one24 = 1ULL << IFRAC;
281 u64 frac_pow24 = one24 + ((acc * fr24) >> IFRAC);
284 u32 frac_pow16 =
static_cast<u32
>(frac_pow24 >> (IFRAC -
FRAC_BITS));
static constexpr FASTLED_FORCE_INLINE u16x16 mod(u16x16 a, u16x16 b) FL_NOEXCEPT
static FASTLED_FORCE_INLINE u16x16 smoothstep(u16x16 edge0, u16x16 edge1, u16x16 x) FL_NOEXCEPT
constexpr u16x16(u32 raw, RawTag) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE u16x16 operator/(u16x16 b) const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE u16x16 sqrt(u16x16 x) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE u16x16 floor(u16x16 x) FL_NOEXCEPT
static constexpr int INT_BITS
constexpr u32 raw() const FL_NOEXCEPT
constexpr bool operator==(u16x16 b) const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE int highest_bit(u32 v) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE u16x16 max(u16x16 a, u16x16 b) FL_NOEXCEPT
constexpr bool operator<=(u16x16 b) const FL_NOEXCEPT
static constexpr int _highest_bit_step(u32 v, int r) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE u16x16 operator-(u16x16 b) const FL_NOEXCEPT
constexpr u16x16(IntT n) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE u16x16 operator*(u16x16 b) const FL_NOEXCEPT
static FASTLED_FORCE_INLINE u16x16 exp2_fp(u16x16 x) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE u16x16 step(u16x16 edge, u16x16 x) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE u16x16 operator<<(int shift) const FL_NOEXCEPT
constexpr bool operator<(u16x16 b) const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE u16x16 ceil(u16x16 x) FL_NOEXCEPT
constexpr bool operator>=(u16x16 b) const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE u16x16 min(u16x16 a, u16x16 b) FL_NOEXCEPT
friend constexpr u16x16 operator*(u32 scalar, u16x16 fp) FL_NOEXCEPT
static FASTLED_FORCE_INLINE u16x16 pow(u16x16 base, u16x16 exp) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE u16x16 operator+(u16x16 b) const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE u16x16 lerp(u16x16 a, u16x16 b, u16x16 t) FL_NOEXCEPT
constexpr u16x16(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 float to_float() const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE u16x16 fract(u16x16 x) FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE u16x16 operator*(u32 scalar) const FL_NOEXCEPT
static FASTLED_FORCE_INLINE u16x16 log2_fp(u16x16 x) FL_NOEXCEPT
constexpr u16x16() FL_NOEXCEPT=default
constexpr u32 to_int() const FL_NOEXCEPT
constexpr FASTLED_FORCE_INLINE u16x16 operator>>(int shift) const FL_NOEXCEPT
constexpr bool operator>(u16x16 b) const FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE u16x16 from_raw(u32 raw) FL_NOEXCEPT
static constexpr i32 SCALE
constexpr bool operator!=(u16x16 b) const FL_NOEXCEPT
static constexpr int FRAC_BITS
static constexpr FASTLED_FORCE_INLINE u16x16 clamp(u16x16 x, u16x16 lo, u16x16 hi) FL_NOEXCEPT
static constexpr FASTLED_FORCE_INLINE u16x16 rsqrt(u16x16 x) FL_NOEXCEPT
#define constexpr
Declares that it is possible to evaluate a value at compile time, introduced in C++11.
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