Skip to content

Commit fe1d0f8

Browse files
committed
Refactor: Move Precise parameter to first position in function signatures
- Change parameter order to Precise<Args...>, V for consistency - Update include paths from sincos/ to trig/ - Fix constant types and naming conventions (kException -> kExceptions)
1 parent afbf0c8 commit fe1d0f8

1 file changed

Lines changed: 13 additions & 16 deletions

File tree

npsr/trig/inl.h

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
#include "npsr/common.h"
2+
#include "npsr/trig/large-inl.h"
3+
#include "npsr/trig/small-inl.h"
24

3-
#include "npsr/sincos/large-inl.h"
4-
#include "npsr/sincos/small-inl.h"
5-
6-
// clang-format off
7-
#if defined(NPSR_TRIG_INL_H_) == defined(HWY_TARGET_TOGGLE) // NOLINT
5+
#if defined(NPSR_TRIG_INL_H_) == defined(HWY_TARGET_TOGGLE) // NOLINT
86
#ifdef NPSR_TRIG_INL_H_
97
#undef NPSR_TRIG_INL_H_
108
#else
@@ -14,48 +12,47 @@
1412
HWY_BEFORE_NAMESPACE();
1513

1614
namespace npsr::HWY_NAMESPACE::sincos {
17-
template <bool IS_COS, typename V, typename Prec>
15+
template <bool IS_COS, typename Prec, typename V>
1816
HWY_API V SinCos(Prec &prec, V x) {
1917
using namespace hwy::HWY_NAMESPACE;
2018
constexpr bool kIsSingle = std::is_same_v<TFromV<V>, float>;
2119
const DFromV<V> d;
2220
V ret;
2321
if constexpr (Prec::kLowAccuracy) {
2422
ret = SmallArgLow<IS_COS>(x);
25-
}
26-
else {
23+
} else {
2724
ret = SmallArg<IS_COS>(x);
2825
}
2926
if constexpr (Prec::kLargeArgument) {
3027
// Identify inputs requiring extended precision (very large arguments)
31-
auto has_large_arg = Gt(Abs(x), Set(d, kIsSingle ? 10000.0 : 16777216.0));
28+
auto has_large_arg = Gt(Abs(x), Set(d, kIsSingle ? 10000.0f : 16777216.0));
3229
if (HWY_UNLIKELY(!AllFalse(d, has_large_arg))) {
3330
// Use extended precision algorithm for large arguments
3431
ret = IfThenElse(has_large_arg, LargeArg<IS_COS>(x), ret);
3532
}
3633
}
37-
if constexpr (Prec::kSpecialCases || Prec::kException) {
34+
if constexpr (Prec::kSpecialCases || Prec::kExceptions) {
3835
auto is_finite = IsFinite(x);
3936
ret = IfThenElse(is_finite, ret, NaN(d));
40-
if constexpr (Prec::kException) {
37+
if constexpr (Prec::kExceptions) {
4138
prec.Raise(!AllFalse(d, IsInf(x)) ? FPExceptions::kInvalid : 0);
4239
}
4340
}
4441
return ret;
4542
}
46-
} // namespace npsr::HWY_NAMESPACE::sincos
43+
} // namespace npsr::HWY_NAMESPACE::sincos
4744

4845
namespace npsr::HWY_NAMESPACE {
49-
template <typename V, typename Prec>
46+
template <typename Prec, typename V>
5047
HWY_API V Sin(Prec &prec, V x) {
5148
return sincos::SinCos<false>(prec, x);
5249
}
53-
template <typename V, typename Prec>
50+
template <typename Prec, typename V>
5451
HWY_API V Cos(Prec &prec, V x) {
5552
return sincos::SinCos<true>(prec, x);
5653
}
57-
} // namespace npsr::HWY_NAMESPACE
54+
} // namespace npsr::HWY_NAMESPACE
5855

5956
HWY_AFTER_NAMESPACE();
6057

61-
#endif // NPSR_TRIG_INL_H_
58+
#endif // NPSR_TRIG_INL_H_

0 commit comments

Comments
 (0)