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
use super::fallback;
use super::{SimdApproximations, SimdGeneric};
macro_rules! simd_approx_impl {
($data_type:ident,
$regf:ident) => {
impl SimdApproximations<$data_type> for fallback::$regf {
fn ln_approx(self) -> Self {
self.iter_over_vector(|x: $data_type| x.ln())
}
fn exp_approx(self) -> Self {
self.iter_over_vector(|x: $data_type| x.exp())
}
fn sin_approx(self) -> Self {
self.iter_over_vector(|x: $data_type| x.sin())
}
fn cos_approx(self) -> Self {
self.iter_over_vector(|x: $data_type| x.cos())
}
fn sin_cos_approx(self, is_sin: bool) -> Self {
if is_sin {
self.sin_approx()
} else {
self.cos_approx()
}
}
}
};
}
simd_approx_impl!(f32, f32x4);
simd_approx_impl!(f64, f64x2);