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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
/*
 * // Copyright 2024 (c) the Radzivon Bartoshyk. All rights reserved.
 * //
 * // Use of this source code is governed by a BSD-style
 * // license that can be found in the LICENSE file.
 */

mod abs;
pub mod acos;
pub mod acosf;
pub mod asin;
pub mod asinf;
pub mod atan;
pub mod atan2;
pub mod atan2f;
pub mod atanf;
pub mod cbrt;
pub mod cbrtf;
pub mod ceil;
pub mod ceilf;
pub mod cos;
pub mod cosf;
pub mod double_precision;
pub mod exp;
pub mod expf;
pub mod floor;
mod fmax;
mod fmaxf;
mod fmin;
mod fminf;
mod generalf;
mod hypot;
mod hypot3;
mod hypot3f;
mod hypot4;
mod hypot4f;
mod hypotf;
mod ln;
mod lnf;
#[cfg(all(
    any(target_arch = "aarch64", target_arch = "arm"),
    target_feature = "neon"
))]
mod neon;
mod pow;
mod powf;
mod sin;
mod sinf;
mod sqrt;
mod sqrtf;
#[cfg(all(
    any(target_arch = "x86_64", target_arch = "x86"),
    target_feature = "sse4.1"
))]
mod sse;
mod tan;
mod tanf;
mod vector;

pub use abs::{eabs, eabsf};
pub use acos::eacos;
pub use acosf::eacosf;
pub use asin::easin;
pub use asinf::easinf;
pub use atan::eatan;
pub use atan2::eatan2;
pub use atan2f::eatan2f;
pub use atanf::eatanf;
pub use cbrt::ecbrt;
pub use cbrtf::ecbrtf;
pub use cos::ecos;
pub use cosf::ecosf;
pub use exp::eexp;
pub use expf::eexpf;
pub use floor::{efloor, efloorf};
pub use fmax::efmax;
pub use fmaxf::efmaxf;
pub use fmin::efmin;
pub use fminf::efminf;
pub use generalf::*;
pub use hypot::ehypot;
pub use hypot3f::ehypot3f;
pub use hypot4::ehypot4;
pub use hypot4f::ehypot4f;
pub use hypotf::ehypotf;
pub use ln::eln;
pub use lnf::elnf;
pub use pow::epow;
pub use powf::epowf;
pub use sin::esin;
pub use sinf::esinf;
pub use sqrt::esqrt;
pub use sqrtf::esqrtf;
pub use tan::etan;
pub use tanf::etanf;

#[cfg(all(
    any(target_arch = "aarch64", target_arch = "arm"),
    target_feature = "neon"
))]
pub use neon::*;

use crate::hypot3::ehypot3;
#[cfg(all(
    any(target_arch = "x86_64", target_arch = "x86"),
    target_feature = "sse4.1"
))]
pub use sse::*;

pub trait Sqrtf {
    /// Computes square root
    fn esqrt(self) -> Self;
}

pub trait Cosine {
    /// Computes cosine
    fn ecos(self) -> Self;
}

impl Cosine for f32 {
    fn ecos(self) -> Self {
        ecosf(self)
    }
}

impl Cosine for f64 {
    fn ecos(self) -> Self {
        ecos(self)
    }
}

pub trait Sine {
    /// Computes sine
    fn esin(self) -> Self;
}

impl Sine for f32 {
    fn esin(self) -> Self {
        esinf(self)
    }
}

impl Sine for f64 {
    fn esin(self) -> Self {
        esin(self)
    }
}

pub trait Exponential {
    /// Computes exponent
    fn eexp(self) -> Self;
}

impl Exponential for f32 {
    fn eexp(self) -> Self {
        eexpf(self)
    }
}

impl Exponential for f64 {
    fn eexp(self) -> Self {
        eexp(self)
    }
}

impl Sqrtf for f32 {
    fn esqrt(self) -> Self {
        esqrtf(self)
    }
}

impl Sqrtf for f64 {
    fn esqrt(self) -> Self {
        esqrt(self)
    }
}

pub trait Roundable {
    /// Rounds value towards infinity
    fn efloor(self) -> Self;
}

impl Roundable for f32 {
    fn efloor(self) -> Self {
        efloorf(self)
    }
}

impl Roundable for f64 {
    fn efloor(self) -> Self {
        efloor(self)
    }
}

pub trait Signed {
    /// Modulo operation
    fn eabs(self) -> Self;
}

impl Signed for f32 {
    fn eabs(self) -> Self {
        eabsf(self)
    }
}

impl Signed for f64 {
    fn eabs(self) -> Self {
        eabs(self)
    }
}

pub trait Logarithmic {
    /// Computes natural logarithm for value
    fn eln(self) -> Self;
}

impl Logarithmic for f32 {
    fn eln(self) -> Self {
        elnf(self)
    }
}

impl Logarithmic for f64 {
    fn eln(self) -> Self {
        eln(self)
    }
}

pub trait Tangent {
    /// Computes tan for value
    fn etan(self) -> Self;
}

impl Tangent for f32 {
    fn etan(self) -> Self {
        etanf(self)
    }
}

impl Tangent for f64 {
    fn etan(self) -> Self {
        etan(self)
    }
}

pub trait Power {
    /// Computes power for given value and power
    fn epow(self, n: Self) -> Self;
}

impl Power for f32 {
    fn epow(self, n: Self) -> Self {
        epowf(self, n)
    }
}

impl Power for f64 {
    fn epow(self, n: Self) -> Self {
        epow(self, n)
    }
}

pub trait ArcTan {
    /// Computes arc tangent
    fn eatan(self) -> Self;
}

impl ArcTan for f32 {
    fn eatan(self) -> Self {
        eatanf(self)
    }
}

impl ArcTan for f64 {
    fn eatan(self) -> Self {
        eatan(self)
    }
}

pub trait ArcSin {
    /// Computes arc sine
    fn easin(self) -> Self;
}

impl ArcSin for f32 {
    fn easin(self) -> Self {
        easinf(self)
    }
}

impl ArcSin for f64 {
    fn easin(self) -> Self {
        easin(self)
    }
}

pub trait ArcCos {
    /// Computes arc cosine
    fn eacos(self) -> Self;
}

impl ArcCos for f32 {
    fn eacos(self) -> Self {
        eacosf(self)
    }
}

impl ArcCos for f64 {
    fn eacos(self) -> Self {
        eacos(self)
    }
}

pub trait ArcTan2 {
    fn eatan2(self, x: Self) -> Self;
}

impl ArcTan2 for f32 {
    fn eatan2(self, x: f32) -> Self {
        eatan2f(self, x)
    }
}

impl ArcTan2 for f64 {
    fn eatan2(self, x: Self) -> Self {
        eatan2(self, x)
    }
}

pub trait CubeRoot {
    /// Computes cube root
    fn ecbrt(self) -> Self;
}

impl CubeRoot for f32 {
    fn ecbrt(self) -> Self {
        ecbrtf(self)
    }
}

impl CubeRoot for f64 {
    fn ecbrt(self) -> Self {
        ecbrt(self)
    }
}

pub trait Euclidean3DDistance {
    /// Computes euclidean 3D distance
    fn hypot3(self, y: Self, z: Self) -> Self;
}

impl Euclidean3DDistance for f32 {
    fn hypot3(self, y: Self, z: Self) -> Self {
        ehypot3f(self, y, z)
    }
}

impl Euclidean3DDistance for f64 {
    fn hypot3(self, y: Self, z: Self) -> Self {
        ehypot3(self, y, z)
    }
}

pub trait Euclidean2DDistance {
    /// Computes euclidean 2D distance
    fn ehypot(self, y: Self) -> Self;
}

impl Euclidean2DDistance for f32 {
    fn ehypot(self, y: Self) -> Self {
        ehypotf(self, y)
    }
}

impl Euclidean2DDistance for f64 {
    fn ehypot(self, y: Self) -> Self {
        ehypot(self, y)
    }
}

pub trait Euclidean4DDistance {
    /// Computes euclidean 4D distance
    fn hypot4(self, y: Self, z: Self, w: Self) -> Self;
}

impl Euclidean4DDistance for f32 {
    fn hypot4(self, y: Self, z: Self, w: Self) -> Self {
        ehypot4f(self, y, z, w)
    }
}

impl Euclidean4DDistance for f64 {
    fn hypot4(self, y: Self, z: Self, w: Self) -> Self {
        ehypot4(self, y, z, w)
    }
}