forked from mockingbirdnest/Principia
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelementary_functions.hpp
More file actions
119 lines (99 loc) · 3.45 KB
/
elementary_functions.hpp
File metadata and controls
119 lines (99 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#pragma once
#include "quantities/dimensions.hpp"
#include "quantities/named_quantities.hpp"
#include "quantities/quantities.hpp"
namespace principia {
namespace numerics {
namespace _elementary_functions {
namespace internal {
using namespace principia::quantities::_dimensions;
using namespace principia::quantities::_named_quantities;
using namespace principia::quantities::_quantities;
// Equivalent to `std::fma(x, y, z)`.
template<typename Q1, typename Q2>
Product<Q1, Q2> FusedMultiplyAdd(Q1 const& x,
Q2 const& y,
Product<Q1, Q2> const& z);
template<typename Q1, typename Q2>
Product<Q1, Q2> FusedMultiplySubtract(Q1 const& x,
Q2 const& y,
Product<Q1, Q2> const& z);
template<typename Q1, typename Q2>
Product<Q1, Q2> FusedNegatedMultiplyAdd(Q1 const& x,
Q2 const& y,
Product<Q1, Q2> const& z);
template<typename Q1, typename Q2>
Product<Q1, Q2> FusedNegatedMultiplySubtract(Q1 const& x,
Q2 const& y,
Product<Q1, Q2> const& z);
// Equivalent to `std::abs(x)`.
template<typename Q>
Q Abs(Q const& quantity);
// Returns a value between zero and `modulus`.
template<typename Q>
Q Mod(Q const& argument, Q const& modulus);
// Equivalent to `std::sqrt(x)`.
template<typename Q>
SquareRoot<Q> Sqrt(Q const& x);
// Equivalent to `std::cbrt(x)`.
template<typename Q>
CubeRoot<Q> Cbrt(Q const& x);
// Not equivalent to `std::nextafter(x)`; follows IEEE 754:2008 conventions
// instead of C++ ones. In particular, `NextUp(-0.0) == NextUp(+0.0)`.
template<typename Q>
constexpr Q NextUp(Q const& x);
template<typename Q>
constexpr Q NextDown(Q const& x);
double Sin(Angle const& α);
double Cos(Angle const& α);
double Tan(Angle const& α);
Angle ArcSin(double x);
Angle ArcCos(double x);
Angle ArcTan(double x);
Angle ArcTan(double y, double x);
template<typename D>
Angle ArcTan(Quantity<D> const& y, Quantity<D> const& x);
// We consider hyperbolic functions as dealing with quotients of arc length to
// curvature radius in the hyperbolic plane, which are angles. This explains the
// use of "arc" for inverse functions.
double Sinh(Angle const& α);
double Cosh(Angle const& α);
double Tanh(Angle const& α);
Angle ArcSinh(double x);
Angle ArcCosh(double x);
Angle ArcTanh(double x);
// Returns the element of {α + 2nπ | n ∈ ℤ} which is closest to
// `previous_angle`.
Angle UnwindFrom(Angle const& previous_angle, Angle const& α);
template<dimensionless Q>
Q Round(Q const& x);
} // namespace internal
using internal::Abs;
using internal::ArcCos;
using internal::ArcCosh;
using internal::ArcSin;
using internal::ArcSinh;
using internal::ArcTan;
using internal::ArcTanh;
using internal::Cbrt;
using internal::Cos;
using internal::Cosh;
using internal::FusedMultiplyAdd;
using internal::FusedMultiplySubtract;
using internal::FusedNegatedMultiplyAdd;
using internal::FusedNegatedMultiplySubtract;
using internal::Mod;
using internal::NextDown;
using internal::NextUp;
using internal::Pow;
using internal::Round;
using internal::Sin;
using internal::Sinh;
using internal::Sqrt;
using internal::Tan;
using internal::Tanh;
using internal::UnwindFrom;
} // namespace _elementary_functions
} // namespace numerics
} // namespace principia
#include "numerics/elementary_functions_body.hpp"