xref: /freebsd/contrib/llvm-project/libcxx/include/__math/gamma.h (revision 5b56413d04e608379c9a306373554a8e4d321bc0)
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef _LIBCPP___MATH_GAMMA_H
10 #define _LIBCPP___MATH_GAMMA_H
11 
12 #include <__config>
13 #include <__type_traits/enable_if.h>
14 #include <__type_traits/is_integral.h>
15 
16 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17 #  pragma GCC system_header
18 #endif
19 
20 _LIBCPP_BEGIN_NAMESPACE_STD
21 
22 namespace __math {
23 
24 // lgamma
25 
26 inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __x) _NOEXCEPT { return __builtin_lgammaf(__x); }
27 
28 template <class = int>
29 _LIBCPP_HIDE_FROM_ABI double lgamma(double __x) _NOEXCEPT {
30   return __builtin_lgamma(__x);
31 }
32 
33 inline _LIBCPP_HIDE_FROM_ABI long double lgamma(long double __x) _NOEXCEPT { return __builtin_lgammal(__x); }
34 
35 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
36 inline _LIBCPP_HIDE_FROM_ABI double lgamma(_A1 __x) _NOEXCEPT {
37   return __builtin_lgamma((double)__x);
38 }
39 
40 // nan
41 
42 // tgamma
43 
44 inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT { return __builtin_tgammaf(__x); }
45 
46 template <class = int>
47 _LIBCPP_HIDE_FROM_ABI double tgamma(double __x) _NOEXCEPT {
48   return __builtin_tgamma(__x);
49 }
50 
51 inline _LIBCPP_HIDE_FROM_ABI long double tgamma(long double __x) _NOEXCEPT { return __builtin_tgammal(__x); }
52 
53 template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
54 inline _LIBCPP_HIDE_FROM_ABI double tgamma(_A1 __x) _NOEXCEPT {
55   return __builtin_tgamma((double)__x);
56 }
57 
58 } // namespace __math
59 
60 _LIBCPP_END_NAMESPACE_STD
61 
62 #endif // _LIBCPP___MATH_GAMMA_H
63