34 template <
typename IntT, detail::enable_if_
integer_t<IntT> = 0>
40 template <
typename OtherFP>
41 constexpr u16x16(
const OtherFP& other,
66#if defined(__riscv) && (__riscv_xlen == 32)
71 asm(
"mul %0, %2, %3\n\t"
73 :
"=&r"(lo),
"=&r"(hi)
75 return from_raw((lo >> 16) | (hi << 16));
85#if FL_FIXED_POINT_NARROW_DIVIDE
152 return a < b ? a : b;
156 return a > b ? a : b;
160 return x < lo ? lo : (
x > hi ? hi :
x);
163#if defined(__riscv) && (__riscv_xlen == 32)
168 return a + (b - a) *
t;
176 constexpr u16x16 zero(0.0f);
177 constexpr u16x16 one(1.0f);
178 constexpr u16x16 two(2.0f);
179 constexpr u16x16 three(3.0f);
181 return t *
t * (three - two *
t);
196 constexpr u16x16 one(1.0f);
197 if (
exp.mValue == 0)
return one;
198 if (base == one)
return one;
199 if (base.mValue == 0)
return u16x16();
202 constexpr u32 kOneRaw =
static_cast<u32
>(
SCALE);
203 if (base.mValue >= (kOneRaw - 2u) && base.mValue <= kOneRaw) {
222 : (v & 0x00000002u) ? r + 1
233 if (msb < 0)
return u16x16();
245 constexpr int IFRAC = 24;
246 constexpr u64 c0 = 24189248ULL;
247 constexpr u64 c1 = 5049984ULL;
253 u64 acc = c0 + ((c1 * t24) >> IFRAC);
254 u64 frac_part = (acc * t24) >> IFRAC;
257 u32 frac16 =
static_cast<u32
>(frac_part >> (IFRAC -
FRAC_BITS));
271 u32 int_pow = (
SCALE) << n;
275 constexpr int IFRAC = 24;
276 constexpr u64 d0 = 11629376ULL;
277 constexpr u64 d1 = 4038400ULL;
278 constexpr u64 d2 = 895232ULL;
279 constexpr u64 d3 = 214016ULL;
286 acc = d2 + ((acc * fr24) >> IFRAC);
287 acc = d1 + ((acc * fr24) >> IFRAC);
288 acc = d0 + ((acc * fr24) >> IFRAC);
289 constexpr u64 one24 = 1ULL << IFRAC;
290 u64 frac_pow24 = one24 + ((acc * fr24) >> IFRAC);
293 u32 frac_pow16 =
static_cast<u32
>(frac_pow24 >> (IFRAC -
FRAC_BITS));
static FASTLED_FORCE_INLINE u16x16 exp2_fp(u16x16 x) FL_NO_EXCEPT
static constexpr FASTLED_FORCE_INLINE u16x16 step(u16x16 edge, u16x16 x) FL_NO_EXCEPT
constexpr u16x16(u32 raw, RawTag) FL_NO_EXCEPT
constexpr u32 raw() const FL_NO_EXCEPT
static constexpr int INT_BITS
static constexpr FASTLED_FORCE_INLINE u16x16 max(u16x16 a, u16x16 b) FL_NO_EXCEPT
constexpr u16x16(IntT n) FL_NO_EXCEPT
constexpr bool operator==(u16x16 b) const FL_NO_EXCEPT
static constexpr FASTLED_FORCE_INLINE u16x16 min(u16x16 a, u16x16 b) FL_NO_EXCEPT
static constexpr FASTLED_FORCE_INLINE u16x16 lerp(u16x16 a, u16x16 b, u16x16 t) FL_NO_EXCEPT
constexpr FASTLED_FORCE_INLINE u16x16 operator<<(int shift) const FL_NO_EXCEPT
constexpr FASTLED_FORCE_INLINE u16x16 operator>>(int shift) const FL_NO_EXCEPT
constexpr FASTLED_FORCE_INLINE u16x16 operator/(u16x16 b) const FL_NO_EXCEPT
constexpr bool operator<(u16x16 b) const FL_NO_EXCEPT
static FASTLED_FORCE_INLINE u16x16 pow(u16x16 base, u16x16 exp) FL_NO_EXCEPT
static constexpr FASTLED_FORCE_INLINE u16x16 fract(u16x16 x) FL_NO_EXCEPT
static constexpr FASTLED_FORCE_INLINE u16x16 from_raw(u32 raw) FL_NO_EXCEPT
constexpr FASTLED_FORCE_INLINE u16x16 operator+(u16x16 b) const FL_NO_EXCEPT
constexpr float to_float() const FL_NO_EXCEPT
static constexpr FASTLED_FORCE_INLINE u16x16 clamp(u16x16 x, u16x16 lo, u16x16 hi) FL_NO_EXCEPT
constexpr FASTLED_FORCE_INLINE u16x16 operator*(u16x16 b) const FL_NO_EXCEPT
constexpr bool operator<=(u16x16 b) const FL_NO_EXCEPT
constexpr u32 to_int() const FL_NO_EXCEPT
constexpr FASTLED_FORCE_INLINE u16x16 operator*(u32 scalar) const FL_NO_EXCEPT
static constexpr FASTLED_FORCE_INLINE u16x16 mod(u16x16 a, u16x16 b) FL_NO_EXCEPT
static constexpr int _highest_bit_step(u32 v, int r) FL_NO_EXCEPT
constexpr bool operator!=(u16x16 b) const FL_NO_EXCEPT
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_NO_EXCEPT
constexpr FASTLED_FORCE_INLINE u16x16 operator-(u16x16 b) const FL_NO_EXCEPT
static constexpr FASTLED_FORCE_INLINE u16x16 ceil(u16x16 x) FL_NO_EXCEPT
constexpr u16x16() FL_NO_EXCEPT=default
friend constexpr u16x16 operator*(u32 scalar, u16x16 fp) FL_NO_EXCEPT
constexpr bool operator>=(u16x16 b) const FL_NO_EXCEPT
static constexpr FASTLED_FORCE_INLINE u16x16 sqrt(u16x16 x) FL_NO_EXCEPT
static FASTLED_FORCE_INLINE u16x16 smoothstep(u16x16 edge0, u16x16 edge1, u16x16 x) FL_NO_EXCEPT
static constexpr FASTLED_FORCE_INLINE u16x16 floor(u16x16 x) FL_NO_EXCEPT
static constexpr FASTLED_FORCE_INLINE int highest_bit(u32 v) FL_NO_EXCEPT
constexpr bool operator>(u16x16 b) const FL_NO_EXCEPT
static constexpr FASTLED_FORCE_INLINE u16x16 rsqrt(u16x16 x) FL_NO_EXCEPT
static constexpr i32 SCALE
static constexpr int FRAC_BITS
static FASTLED_FORCE_INLINE u16x16 log2_fp(u16x16 x) FL_NO_EXCEPT
#define FL_OPTIMIZATION_LEVEL_O3_BEGIN
#define FASTLED_FORCE_INLINE
#define FL_OPTIMIZATION_LEVEL_O3_END
#define constexpr
Declares that it is possible to evaluate a value at compile time, introduced in C++11.
FL_FIXED_POINT_DIVIDE_INLINE u32 divide64By32(u32 hi, u32 lo, u32 divisor) FL_NO_EXCEPT
(hi:lo) / divisor, for a quotient that fits 32 bits.
u8 u8 fract8 blur_amount FL_NO_EXCEPT
FL_OPTIMIZE_FUNCTION constexpr u32 isqrt64(u64 x) FL_NO_EXCEPT
expected< T, E > result
Alias for expected (Rust-style naming)
enable_if< is_fixed_point< T >::value, T >::type exp(T x) FL_NO_EXCEPT
Base definition for an LED controller.
A 64/32 -> 32 division built from 32-bit divides.