File: ccmath.qbk

package info (click to toggle)
scipy 1.16.0-1exp7
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 234,820 kB
  • sloc: cpp: 503,145; python: 344,611; ansic: 195,638; javascript: 89,566; fortran: 56,210; cs: 3,081; f90: 1,150; sh: 848; makefile: 785; pascal: 284; csh: 135; lisp: 134; xml: 56; perl: 51
file content (203 lines) | stat: -rw-r--r-- 7,165 bytes parent folder | download | duplicates (9)
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
[/
Copyright (c) 2021 - 2022 Matt Borland
Use, modification and distribution are subject to the
Boost Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
]

[section:ccmath Constexpr CMath]

[heading Description]

`Constexpr` implementations of the functionality found in `<cmath>` and `<cstdlib>` [@https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0533r9.pdf proposed for C++23].
In a `constexpr` context the functions will use an implementation defined in boost.
If the context is not `constexpr` the functionality will be directly from the STL implementation of `<cmath>` used by the compiler.
All functions that take an `Integer` type and return a `double` simply cast the `Integer` argument to a `double`.
All of the following functions require C++17 or greater.

[heading Synopsis]

``
    #include <boost/math/ccmath/ccmath.hpp>
``
    namespace boost::math::ccmath {

        template <typename T>
        inline constexpr bool isinf(T x);

        template <typename T>
        inline constexpr bool isnan(T x);

        template <typename Real>
        inline constexpr Real sqrt(Real x);

        template <typename Integer>
        inline constexpr double sqrt(Integer x);

        template <typename T>
        inline constexpr T abs(T x);

        template <typename T, std::enable_if_t<std::is_unsigned_v<T>, bool> = true>
        inline constexpr int abs(T x);

        template <typename T>
        inline constexpr T fabs(T x);

        template <typename T>
        inline constexpr bool isfinite(T x);

        template <typename T>
        inline constexpr bool isnormal(T x);

        template <typename T>
        inline constexpr int fpclassify(T x);

        template <typename Real>
        inline constexpr Real frexp(Real arg, int* exp);

        template <typename Integer>
        inline constexpr double frexp(Integer arg, int* exp);

        template <typename Real>
        inline constexpr Real ldexp(Real arg, int exp);

        template <typename Integer>
        inline constexpr double ldexp(Integer arg, int exp);

        template <typename Integer>
        struct div_t {Integer quot; Integer rem;};

        template <typename Integer>
        inline constexpr div_t<Integer> div(Integer x, Integer y);

        template <typename Real>
        inline constexpr Real logb(Real arg);

        template <typename Integer>
        inline constexpr double logb(Integer arg);

        template <typename T>
        inline constexpr int ilogb(T arg);

        template <typename Real>
        inline constexpr Real scalbn(Real x, int exp) noexcept

        template <typename Integer>
        inline constexpr double scalbn(Integer x, int exp) noexcept

        template <typename Real>
        inline constexpr Real scalbln(Real x, long exp) noexcept

        template <typename Integer>
        inline constexpr double scalbln(Integer x, long exp) noexcept

        template <typename Real>
        inline constexpr Real floor(Real arg) noexcept

        template <typename Integer>
        inline constexpr double floor(Integer arg) noexcept

        template <typename Real>
        inline constexpr Real ceil(Real arg) noexcept

        template <typename Integer>
        inline constexpr double ceil(Integer arg) noexcept

        template <typename Real>
        inline constexpr Real trunc(Real arg) noexcept

        template <typename Integer>
        inline constexpr double trunc(Integer arg) noexcept

        template <typename Real>
        inline constexpr Real modf(Real x, Real* iptr) noexcept

        template <typename Real>
        inline constexpr Real round(Real arg) noexcept

        template <typename Integer>
        inline constexpr double round(Integer arg) noexcept

        template <typename T>
        inline constexpr long lround(T arg)

        template <typename T>
        inline constexpr long long llround(T arg)

        template <typename Real>
        inline constexpr Real fmod(Real x, Real y) noexcept

        template <typename Arithmetic1, typename Arithmetic2>
        inline constexpr Promoted fmod(Arithmetic1 x, Arithmetic2 y) noexcept
        The Promoted return type will have at least double prescision, but be up to the highest precision argument.
        
        template <typename Real>
        inline constexpr Real remainder(Real x, Real y) noexcept

        template <typename Arithmetic1, typename Arithmetic2>
        inline constexpr Promoted remainder(Arithmetic1 x, Arithmetic2 y) noexcept

        template <typename Real>
        inline constexpr Real copysign(Real mag, Real sgn) noexcept

        template <typename Arithmetic1, typename Arithmetic2>
        inline constexpr Promoted copysign(Arithmetic1 mag, Arithmetic2 sgn) noexcept

        template <typename Real>
        inline constexpr Real hypot(Real x, Real y) noexcept

        template <typename Arithmetic1, typename Arithmetic2>
        inline constexpr Promoted hypot(Arithmetic1 x, Arithmetic2 y) noexcept

        template <typename Real>
        inline constexpr Real fdim(Real x, Real y) noexcept

        template <typename Arithmetic1, typename Arithmetic2>
        inline constexpr Promoted fdim(Arithmetic1 x, Arithmetic2 y) noexcept

        template <typename Real>
        inline constexpr Real fmax(Real x, Real y) noexcept

        template <typename Arithmetic1, typename Arithmetic2>
        inline constexpr Promoted fmax(Arithmetic1 x, Arithmetic2 y) noexcept

        template <typename Real>
        inline constexpr Real fmin(Real x, Real y) noexcept

        template <typename Arithmetic1, typename Arithmetic2>
        inline constexpr Promoted fmin(Arithmetic1 x, Arithmetic2 y) noexcept

        template <typename Arithmetic1, typename Arithmetic2 = Arithmetic1>
        inline constexpr bool isgreater(Arithmetic1 x, Arithmetic2 y) noexcept

        template <typename Arithmetic1, typename Arithmetic2 = Arithmetic1>
        inline constexpr bool isgreaterequal(Arithmetic1 x, Arithmetic2 y) noexcept

        template <typename Arithmetic1, typename Arithmetic2 = Arithmetic1>
        inline constexpr bool isless(Arithmetic1 x, Arithmetic2 y) noexcept

        template <typename Arithmetic1, typename Arithmetic2 = Arithmetic1>
        inline constexpr bool islessequal(Arithmetic1 x, Arithmetic2 y) noexcept

        template <typename T>
        inline constexpr bool isunordered(T x, T y) noexcept

        template <typename Real>
        inline constexpr Real fma(Real x, Real y, Real z) noexcept
        Requires compiling with fma flag

        template <typename Arithmetic1, typename Arithmetic2, typename Arithmetic3>
        inline constexpr Promoted fma(Arithmetic1 x, Arithmetic2 y, Arithmetic3 z) noexcept

        template <typename Arithmetic1, typename Arithmetic2>
        constexpr Promoted nextafter(Arithmetic1 from, Arithmetic2 to)

        template <typename T>
        constexpr Promoted nexttoward(T from, long double to)

        template <typename T>
        constexpr bool signbit(T arg)

    } // Namespaces

[endsect] [/section:ccmath Constexpr CMath]