-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmath.hpp
More file actions
79 lines (70 loc) · 2.76 KB
/
Copy pathmath.hpp
File metadata and controls
79 lines (70 loc) · 2.76 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
/****************************************************************************
* Copyright (c) xsimd-algorithm contributors *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/
#ifndef XSIMD_ALGORITHM_MATH_HPP
#define XSIMD_ALGORITHM_MATH_HPP
#include <xsimd/xsimd.hpp>
#include "./map.hpp"
namespace xsimd::algo
{
template <
xsimd::alignment_options align = xsimd::alignment_options{},
typename Arch = xsimd::default_arch,
typename T>
void sqrt(std::span<T const> in, std::span<T> out)
{
constexpr map_options opts = { .unroll_factor = 4, .pure = true };
return xsimd::map_unary<align, opts, Arch>(
in, out, [](auto x)
{ return sqrt(x); });
}
template <
xsimd::alignment_options align = xsimd::alignment_options{},
typename Arch = xsimd::default_arch,
typename T>
void abs(std::span<T const> in, std::span<T> out)
{
constexpr map_options opts = { .unroll_factor = 4, .pure = true };
return xsimd::map_unary<align, opts, Arch>(
in, out, [](auto x)
{ return abs(x); });
}
template <
xsimd::alignment_options align = xsimd::alignment_options{},
typename Arch = xsimd::default_arch,
typename T>
void exp(std::span<T const> in, std::span<T> out)
{
constexpr map_options opts = { .unroll_factor = 4, .pure = true };
return xsimd::map_unary<align, opts, Arch>(
in, out, [](auto x)
{ return exp(x); });
}
template <
xsimd::alignment_options align = xsimd::alignment_options{},
typename Arch = xsimd::default_arch,
typename T>
void add(std::span<T const> lhs, std::span<T const> rhs, std::span<T> out)
{
constexpr map_options opts = { .unroll_factor = 4, .pure = true };
return xsimd::map_binary<align, opts, Arch>(
lhs, rhs, out, [](auto x, auto y)
{ return x + y; });
}
template <
xsimd::alignment_options align = xsimd::alignment_options{},
typename Arch = xsimd::default_arch,
typename T>
void multiply(std::span<T const> lhs, std::span<T const> rhs, std::span<T> out)
{
constexpr map_options opts = { .unroll_factor = 4, .pure = true };
return xsimd::map_binary<align, opts, Arch>(
lhs, rhs, out, [](auto x, auto y)
{ return x * y; });
}
}
#endif