30 static_assert(
simd::size() == 4 &&
"The SIMD counter math below assumes simd::size() is 4.");
35 return count & 0xFFFFFFFC;
41 return count & 0xFFFFFFF8;
71 return (
count + 3) >> 2;
89#define JPL_FL_CONSTANT(Name, Val)\
90 JPL_INLINE simd c_##Name() noexcept { return simd(Val);; }
92#define JPL_INT_CONSTANT(Name, Val)\
93 JPL_INLINE simd_mask c_i##Name() noexcept { return simd_mask(static_cast<uint32>(Val)); }
95#define JPL_MASK_CONSTANT(Name, Val)\
96 JPL_INLINE simd_mask c_##Name() noexcept { return simd_mask(static_cast<uint32>(Val)); }
122 return vec.
as_mask() & constant::c_sign_mask();
174 simd y = cephes::c_log_p0();
175 y =
fma(
y,
x, cephes::c_log_p1());
176 y =
fma(
y,
x, cephes::c_log_p2());
177 y =
fma(
y,
x, cephes::c_log_p3());
178 y =
fma(
y,
x, cephes::c_log_p4());
179 y =
fma(
y,
x, cephes::c_log_p5());
180 y =
fma(
y,
x, cephes::c_log_p6());
181 y =
fma(
y,
x, cephes::c_log_p7());
182 y =
fma(
y,
x, cephes::c_log_p8());
195 x =
max(
x, constant::c_min_norm_pos().as_simd());
204 x &= constant::c_inv_mant_mask().as_simd();
213 const simd mask = (
x < cephes::c_SQRTHF()).as_simd();
222 x =
fma(
e, cephes::c_log_q2(),
x +
y);
243 return log(
vec) * constant::c_inv_ln10();
249 return log(
vec) * constant::c_inv_ln2();
279 simd y = cephes::c_exp_p0();
280 y =
fma(
y,
x, cephes::c_exp_p1());
281 y =
fma(
y,
x, cephes::c_exp_p2());
282 y =
fma(
y,
x, cephes::c_exp_p3());
283 y =
fma(
y,
x, cephes::c_exp_p4());
284 y =
fma(
y,
x, cephes::c_exp_p5());
292 return ((n.
to_mask() + constant::c_i0x7f()) << 23).as_simd();
300 x =
clamp(
x, constant::c_exp_lo(), constant::c_exp_hi());
308 x -=
fma(n, cephes::c_exp_C1(), n * cephes::c_exp_C2());
327 x =
fma(
r, cephes::c_exp_C1(),
r * cephes::c_exp_C2());
349 simd u = (
m << 23).as_simd();
353 u = ((
exp.adds(0x7f)) << 23).as_simd();
652 r =
fma(
n_f, tangent::c_minus_DP2(),
r);
653 r =
fma(
n_f, tangent::c_minus_DP3(),
r);
671 simd y = +0.4197454825e-1f;
672 y =
fma(
y,
x2, +0.2424046025e-1f);
673 y =
fma(
y,
x2, +0.4547423869e-1f);
674 y =
fma(
y,
x2, +0.7495029271e-1f);
675 y =
fma(
y,
x2, +0.1666677296e+0f);
714 return constant::c_half_pi ()-
asin(
in);
740 namespace arctangent2
745 const simd a1(0.99997726f);
746 const simd a3(-0.33262347f);
747 const simd a5(0.19354346f);
748 const simd a7(-0.11643287f);
749 const simd a9(0.05265332f);
812#undef JPL_FL_CONSTANT
813#undef JPL_INT_CONSTANT
814#undef JPL_MASK_CONSTANT
#define JPL_INT_CONSTANT(Name, Val)
Definition SIMDMath.h:92
#define JPL_FL_CONSTANT(Name, Val)
Declare some SIMD constants.
Definition SIMDMath.h:89
#define JPL_MASK_CONSTANT(Name, Val)
Definition SIMDMath.h:95
JPL_INLINE constexpr T Sqrt(T x) noexcept
Definition Math.h:269
JPL_INLINE std::pair< T, T > SinCos(T value) noexcept
Definition Math.h:164
simd polynomial(simd x)
Definition SIMDMath.h:742
JPL_INLINE simd polynomial(const simd &x, const simd &x2)
Definition SIMDMath.h:669
JPL_INLINE simd polynomial(const simd &x) noexcept
Definition SIMDMath.h:276
JPL_INLINE simd build2pown(const simd &n)
Definition SIMDMath.h:290
JPL_INLINE simd polynomial(const simd &x) noexcept
Definition SIMDMath.h:172
JPL_INLINE simd mulsign(const simd &x, const simd &y) noexcept
Definition SIMDMath.h:360
JPL_INLINE simd sign(const simd &x) noexcept
Definition SIMDMath.h:366
JPL_INLINE void polynomials(const simd &x, simd &outTaylorCos, simd &outTaylorSin) noexcept
Definition SIMDMath.h:466
JPL_INLINE simd polynomial(simd x)
Definition SIMDMath.h:628
Definition AcousticMaterial.h:36
simd exp(simd x) noexcept
Exponent for 4-wide 32-bit float vector.
Definition SIMDMath.h:298
JPL_INLINE simd clamp(const simd &value, const simd &minV, const simd &maxV) noexcept
Element-wise clamp.
Definition SIMD.h:1838
simd asin(const simd &in)
Definition SIMDMath.h:683
JPL_INLINE constexpr auto GetNumSIMDOps(std::unsigned_integral auto count) noexcept
Get number of SIMD operations that can fit into the count
Definition SIMDMath.h:51
JPL_INLINE simd_mask clamps(const simd_mask &value, const simd_mask &minV, const simd_mask &maxV) noexcept
Element-wise clamp, signed.
Definition SIMD.h:2116
JPL_INLINE constexpr auto GetSIMDTailDouble(std::unsigned_integral auto count) noexcept
Get the remaining tail from count that won't fill 8-wide simd vector.
Definition SIMDMath.h:63
JPL_INLINE constexpr auto GetNumSIMDOpsDouble(std::unsigned_integral auto count) noexcept
Get number of 8-wide simd operations that can fit into the count
Definition SIMDMath.h:57
JPL_INLINE constexpr auto FloorToSIMDSize(std::unsigned_integral auto count) noexcept
Floor count to 4-wide simd vector.
Definition SIMDMath.h:33
JPL_INLINE constexpr auto GetSIMDTail(std::unsigned_integral auto count) noexcept
Get the remaining tail from count that won't fill a simd vector.
Definition SIMDMath.h:45
simd atan2(const simd &y, const simd &x)
Definition SIMDMath.h:767
simd acos(const simd &in)
Definition SIMDMath.h:710
JPL_INLINE simd log2(const simd &vec) noexcept
log2 for 4-wide 32-bit float vector
Definition SIMDMath.h:247
JPL_INLINE simd_mask isinf(const simd &vec) noexcept
Determines if the given floating-point number num is a positive or negative infinity.
Definition SIMDMath.h:126
JPL_INLINE constexpr auto GetDiv2Tail(std::unsigned_integral auto count) noexcept
Definition SIMDMath.h:81
JPL_INLINE simd trunc(const simd &vec) noexcept
Computes the nearest integer not greater in magnitude than vec.
Definition SIMDMath.h:138
JPL_INLINE constexpr auto RoundUpToSIMD(std::unsigned_integral auto count) noexcept
Round count up to the next simd width.
Definition SIMDMath.h:69
JPL_INLINE simd ldexp(simd arg, simd_mask exp) noexcept
Multiplies a floating-point value arg by the number 2 raised to the exp power.
Definition SIMDMath.h:338
JPL_INLINE simd_mask isnan(const simd &vec) noexcept
Determines if the given floating point number vec is a not-a-number(NaN) value.
Definition SIMDMath.h:132
JPL_INLINE simd_mask signbit(const simd &vec) noexcept
Equivalent to std::signbit but for 4-wide 32-bit float vector.
Definition SIMDMath.h:120
JPL_INLINE simd round(const simd &vec) noexcept
Element-wise round to nearest integer value.
Definition SIMD.h:1930
simd cos(simd x) noexcept
Definition SIMDMath.h:579
JPL_INLINE simd floor(const simd &vec) noexcept
Element-wise floor.
Definition SIMD.h:1861
JPL_INLINE simd max(const simd &a, const simd &b) noexcept
Element-wise max.
Definition SIMD.h:1799
JPL_INLINE simd fma(const simd &mul1, const simd &mul2, const simd &addV) noexcept
Element-wise fused multiply-add.
Definition SIMD.h:1843
simd log(simd x) noexcept
Definition SIMDMath.h:191
simd pow(const simd &x, const simd &y) noexcept
Definition SIMDMath.h:372
JPL_INLINE simd min(const simd &a, const simd &b) noexcept
Element-wise min.
Definition SIMD.h:1813
JPL_INLINE simd log10(const simd &vec) noexcept
log10 for 4-wide 32-bit float vector
Definition SIMDMath.h:241
JPL_INLINE constexpr auto FloorToDiv2(std::unsigned_integral auto count) noexcept
Floor count to divisible by 2.
Definition SIMDMath.h:75
JPL_INLINE simd abs(const simd &vec) noexcept
Definition SIMD.h:1827
JPL_INLINE constexpr auto FloorToSIMDSizeDouble(std::unsigned_integral auto count) noexcept
Floor count to 8-wide simd vector.
Definition SIMDMath.h:39
simd sin(simd x) noexcept
Definition SIMDMath.h:540
JPL_INLINE simd exp2(simd x) noexcept
Definition SIMDMath.h:319
simd tan(simd x) noexcept
Definition SIMDMath.h:643
JPL_INLINE simd_mask ashr() const noexcept
Definition SIMD.h:1562
JPL_INLINE simd as_simd() const noexcept
Reinterpret simd_mask as a simd (doesn't change the bits)
Definition SIMD.h:1627
static JPL_INLINE simd_mask zero() noexcept
Definition SIMD.h:1121
JPL_INLINE simd to_simd() const noexcept
Convert each component from an int to a float.
Definition SIMD.h:1610
static JPL_INLINE simd_mask replicate(int value) noexcept
Definition SIMD.h:1106
Minimal 4-wide 32-bit float vector implementation for SIMD.
Definition SIMD.h:60
static JPL_INLINE simd c_0() noexcept
Frequently used constants.
Definition SIMD.h:456
static JPL_INLINE simd c_1() noexcept
Definition SIMD.h:461
JPL_INLINE simd_mask to_mask() const noexcept
Convert each component from a float to an int.
Definition SIMD.h:987
JPL_INLINE simd_mask as_mask() const noexcept
Reinterpret simd as a simd_mask (doesn't change the bits)
Definition SIMD.h:1023
static JPL_INLINE simd c_0p5() noexcept
Definition SIMD.h:466
static JPL_INLINE simd reciprocal(const simd &vec) noexcept
Reciprocal vector (1 / value) for each of the components.
Definition SIMD.h:1058
static JPL_INLINE simd zero() noexcept
Vector with all zeros.
Definition SIMD.h:541
static JPL_INLINE simd inf() noexcept
Definition SIMD.h:557
static JPL_INLINE simd select(const simd_mask &mask, const simd &a, const simd &b) noexcept
Component-wise select, returns 'a' if mask is true, 'b' otherwise.
Definition SIMD.h:1034
static JPL_INLINE simd nan() noexcept
Vector with all NaN's.
Definition SIMD.h:552
static constexpr std::size_t size() noexcept
Get number of element of the vector.
Definition SIMD.h:97