|
1 | 1 | #include "npsr/common.h" |
| 2 | +#include "npsr/trig/large-inl.h" |
| 3 | +#include "npsr/trig/small-inl.h" |
2 | 4 |
|
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 |
8 | 6 | #ifdef NPSR_TRIG_INL_H_ |
9 | 7 | #undef NPSR_TRIG_INL_H_ |
10 | 8 | #else |
|
14 | 12 | HWY_BEFORE_NAMESPACE(); |
15 | 13 |
|
16 | 14 | namespace npsr::HWY_NAMESPACE::sincos { |
17 | | -template <bool IS_COS, typename V, typename Prec> |
| 15 | +template <bool IS_COS, typename Prec, typename V> |
18 | 16 | HWY_API V SinCos(Prec &prec, V x) { |
19 | 17 | using namespace hwy::HWY_NAMESPACE; |
20 | 18 | constexpr bool kIsSingle = std::is_same_v<TFromV<V>, float>; |
21 | 19 | const DFromV<V> d; |
22 | 20 | V ret; |
23 | 21 | if constexpr (Prec::kLowAccuracy) { |
24 | 22 | ret = SmallArgLow<IS_COS>(x); |
25 | | - } |
26 | | - else { |
| 23 | + } else { |
27 | 24 | ret = SmallArg<IS_COS>(x); |
28 | 25 | } |
29 | 26 | if constexpr (Prec::kLargeArgument) { |
30 | 27 | // 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)); |
32 | 29 | if (HWY_UNLIKELY(!AllFalse(d, has_large_arg))) { |
33 | 30 | // Use extended precision algorithm for large arguments |
34 | 31 | ret = IfThenElse(has_large_arg, LargeArg<IS_COS>(x), ret); |
35 | 32 | } |
36 | 33 | } |
37 | | - if constexpr (Prec::kSpecialCases || Prec::kException) { |
| 34 | + if constexpr (Prec::kSpecialCases || Prec::kExceptions) { |
38 | 35 | auto is_finite = IsFinite(x); |
39 | 36 | ret = IfThenElse(is_finite, ret, NaN(d)); |
40 | | - if constexpr (Prec::kException) { |
| 37 | + if constexpr (Prec::kExceptions) { |
41 | 38 | prec.Raise(!AllFalse(d, IsInf(x)) ? FPExceptions::kInvalid : 0); |
42 | 39 | } |
43 | 40 | } |
44 | 41 | return ret; |
45 | 42 | } |
46 | | -} // namespace npsr::HWY_NAMESPACE::sincos |
| 43 | +} // namespace npsr::HWY_NAMESPACE::sincos |
47 | 44 |
|
48 | 45 | namespace npsr::HWY_NAMESPACE { |
49 | | -template <typename V, typename Prec> |
| 46 | +template <typename Prec, typename V> |
50 | 47 | HWY_API V Sin(Prec &prec, V x) { |
51 | 48 | return sincos::SinCos<false>(prec, x); |
52 | 49 | } |
53 | | -template <typename V, typename Prec> |
| 50 | +template <typename Prec, typename V> |
54 | 51 | HWY_API V Cos(Prec &prec, V x) { |
55 | 52 | return sincos::SinCos<true>(prec, x); |
56 | 53 | } |
57 | | -} // namespace npsr::HWY_NAMESPACE |
| 54 | +} // namespace npsr::HWY_NAMESPACE |
58 | 55 |
|
59 | 56 | HWY_AFTER_NAMESPACE(); |
60 | 57 |
|
61 | | -#endif // NPSR_TRIG_INL_H_ |
| 58 | +#endif // NPSR_TRIG_INL_H_ |
0 commit comments