1 // simdfied mathematical functions
2 // Copyright (C) 2009 Tim Blechmann
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; see the file COPYING. If not, write to
16 // the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 // Boston, MA 02111-1307, USA.
24 #include "detail/math.hpp"
25 #include "detail/unroll_helpers.hpp"
26 #include "detail/define_macros.hpp"
28 #if defined(__GNUC__) && defined(NDEBUG)
29 #define always_inline inline __attribute__((always_inline))
31 #define always_inline inline
37 #define DEFINE_UNARY_FUNCTOR(NAME) \
41 template <typename FloatType> \
42 always_inline FloatType operator()(FloatType arg) const \
50 #define DEFINE_UNARY_MATH_FUNCTIONS(NAME) \
51 DEFINE_UNARY_FUNCTOR(NAME) \
52 NOVA_SIMD_DEFINE_UNARY_WRAPPER(NAME, detail::NAME##_)
55 DEFINE_UNARY_MATH_FUNCTIONS(sin
)
56 DEFINE_UNARY_MATH_FUNCTIONS(cos
)
57 DEFINE_UNARY_MATH_FUNCTIONS(tan
)
58 DEFINE_UNARY_MATH_FUNCTIONS(asin
)
59 DEFINE_UNARY_MATH_FUNCTIONS(acos
)
60 DEFINE_UNARY_MATH_FUNCTIONS(atan
)
62 DEFINE_UNARY_MATH_FUNCTIONS(tanh
)
64 DEFINE_UNARY_MATH_FUNCTIONS(log
)
65 DEFINE_UNARY_MATH_FUNCTIONS(log2
)
66 DEFINE_UNARY_MATH_FUNCTIONS(log10
)
67 DEFINE_UNARY_MATH_FUNCTIONS(exp
)
69 DEFINE_UNARY_MATH_FUNCTIONS(signed_sqrt
)
73 #define DEFINE_BINARY_MATH_FUNCTOR(NAME) \
77 template <typename FloatType> \
78 always_inline FloatType operator()(FloatType lhs, FloatType rhs) const \
80 return NAME(lhs, rhs); \
87 DEFINE_BINARY_MATH_FUNCTOR(pow
)
88 DEFINE_BINARY_MATH_FUNCTOR(signed_pow
)
90 NOVA_SIMD_DEFINE_BINARY_WRAPPER(pow
, detail::pow_
)
91 NOVA_SIMD_DEFINE_BINARY_WRAPPER(spow
, detail::signed_pow_
)
95 #undef DEFINE_UNARY_FUNCTOR
96 #undef DEFINE_BINARY_MATH_FUNCTOR
97 #undef DEFINE_UNARY_MATH_FUNCTIONS
98 #undef DEFINE_BINARY_MATH_FUNCTIONS
101 #endif /* SIMD_MATH_HPP */