Debian Codegraph @

src/num/libm.rs

raw symbols SCIP
1 use super::*;
2
3 impl Trigonometry for f32 {
4 #[inline]
5 fn sin(self) -> Self {
6 ::libm::sinf(self)
7 }
8
9 #[inline]
10 fn cos(self) -> Self {
11 ::libm::cosf(self)
12 }
13
14 #[inline]
15 fn sin_cos(self) -> (Self, Self) {
16 ::libm::sincosf(self)
17 }
18
19 #[inline]
20 fn tan(self) -> Self {
21 ::libm::tanf(self)
22 }
23
24 #[inline]
25 fn asin(self) -> Self {
26 ::libm::asinf(self)
27 }
28
29 #[inline]
30 fn acos(self) -> Self {
31 ::libm::acosf(self)
32 }
33
34 #[inline]
35 fn atan(self) -> Self {
36 ::libm::atanf(self)
37 }
38
39 #[inline]
40 fn atan2(self, other: Self) -> Self {
41 ::libm::atan2f(self, other)
42 }
43 }
44
45 impl Trigonometry for f64 {
46 #[inline]
47 fn sin(self) -> Self {
48 ::libm::sin(self)
49 }
50
51 #[inline]
52 fn cos(self) -> Self {
53 ::libm::cos(self)
54 }
55
56 #[inline]
57 fn sin_cos(self) -> (Self, Self) {
58 ::libm::sincos(self)
59 }
60
61 #[inline]
62 fn tan(self) -> Self {
63 ::libm::tan(self)
64 }
65
66 #[inline]
67 fn asin(self) -> Self {
68 ::libm::asin(self)
69 }
70
71 #[inline]
72 fn acos(self) -> Self {
73 ::libm::acos(self)
74 }
75
76 #[inline]
77 fn atan(self) -> Self {
78 ::libm::atan(self)
79 }
80
81 #[inline]
82 fn atan2(self, other: Self) -> Self {
83 ::libm::atan2(self, other)
84 }
85 }
86
87 impl Abs for f32 {
88 #[inline]
89 fn abs(self) -> Self {
90 ::libm::fabsf(self)
91 }
92 }
93
94 impl Abs for f64 {
95 #[inline]
96 fn abs(self) -> Self {
97 ::libm::fabs(self)
98 }
99 }
100
101 impl Sqrt for f32 {
102 #[inline]
103 fn sqrt(self) -> Self {
104 ::libm::sqrtf(self)
105 }
106 }
107
108 impl Sqrt for f64 {
109 #[inline]
110 fn sqrt(self) -> Self {
111 ::libm::sqrt(self)
112 }
113 }
114
115 impl Cbrt for f32 {
116 #[inline]
117 fn cbrt(self) -> Self {
118 ::libm::cbrtf(self)
119 }
120 }
121
122 impl Cbrt for f64 {
123 #[inline]
124 fn cbrt(self) -> Self {
125 ::libm::cbrt(self)
126 }
127 }
128
129 impl Powf for f32 {
130 #[inline]
131 fn powf(self, exp: Self) -> Self {
132 ::libm::powf(self, exp)
133 }
134 }
135
136 impl Powf for f64 {
137 #[inline]
138 fn powf(self, exp: Self) -> Self {
139 ::libm::pow(self, exp)
140 }
141 }
142
143 impl Powi for f32 {
144 #[inline]
145 fn powi(mut self, mut exp: i32) -> Self {
146 if exp < 0 {
147 exp = exp.wrapping_neg();
148 self = self.recip();
149 }
150
151 Powu::powu(self, exp as u32)
152 }
153 }
154
155 impl Powi for f64 {
156 #[inline]
157 fn powi(mut self, mut exp: i32) -> Self {
158 if exp < 0 {
159 exp = exp.wrapping_neg();
160 self = self.recip();
161 }
162
163 Powu::powu(self, exp as u32)
164 }
165 }
166
167 impl Recip for f32 {
168 #[inline]
169 fn recip(self) -> Self {
170 1.0 / self
171 }
172 }
173
174 impl Recip for f64 {
175 #[inline]
176 fn recip(self) -> Self {
177 1.0 / self
178 }
179 }
180
181 impl Exp for f32 {
182 #[inline]
183 fn exp(self) -> Self {
184 ::libm::expf(self)
185 }
186 }
187
188 impl Exp for f64 {
189 #[inline]
190 fn exp(self) -> Self {
191 ::libm::exp(self)
192 }
193 }
194
195 impl Hypot for f32 {
196 #[inline]
197 fn hypot(self, other: Self) -> Self {
198 ::libm::hypotf(self, other)
199 }
200 }
201
202 impl Hypot for f64 {
203 #[inline]
204 fn hypot(self, other: Self) -> Self {
205 ::libm::hypot(self, other)
206 }
207 }
208
209 impl Round for f32 {
210 #[inline]
211 fn round(self) -> Self {
212 ::libm::roundf(self)
213 }
214
215 #[inline]
216 fn floor(self) -> Self {
217 ::libm::floorf(self)
218 }
219
220 #[inline]
221 fn ceil(self) -> Self {
222 ::libm::ceilf(self)
223 }
224 }
225
226 impl Round for f64 {
227 #[inline]
228 fn round(self) -> Self {
229 ::libm::round(self)
230 }
231
232 #[inline]
233 fn floor(self) -> Self {
234 ::libm::floor(self)
235 }
236
237 #[inline]
238 fn ceil(self) -> Self {
239 ::libm::ceil(self)
240 }
241 }
242
243 impl MulAdd for f32 {
244 #[inline]
245 fn mul_add(self, m: Self, a: Self) -> Self {
246 ::libm::fmaf(self, m, a)
247 }
248 }
249
250 impl MulAdd for f64 {
251 #[inline]
252 fn mul_add(self, m: Self, a: Self) -> Self {
253 ::libm::fma(self, m, a)
254 }
255 }
256
257 impl Signum for f32 {
258 #[inline]
259 fn signum(self) -> Self {
260 if self.is_nan() {
261 Self::NAN
262 } else {
263 ::libm::copysignf(1.0, self)
264 }
265 }
266 }
267
268 impl Signum for f64 {
269 #[inline]
270 fn signum(self) -> Self {
271 if self.is_nan() {
272 Self::NAN
273 } else {
274 ::libm::copysign(1.0, self)
275 }
276 }
277 }
278
279 impl Ln for f32 {
280 #[inline]
281 fn ln(self) -> Self {
282 ::libm::logf(self)
283 }
284 }
285
286 impl Ln for f64 {
287 #[inline]
288 fn ln(self) -> Self {
289 ::libm::log(self)
290 }
291 }