mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [
git repo
]
sign.hpp
Go to the documentation of this file.
1
/** \file sign.hpp
2
* \brief Declares and defines the sign function.
3
* \ingroup gen_math_files
4
* \author Jared R. Males (jaredmales@gmail.com)
5
*
6
*/
7
8
9
#ifndef mx_sign_hpp
10
#define mx_sign_hpp
11
12
#include <type_traits>
13
14
#ifdef MX_INCLUDE_BOOST
15
#include <boost/math/special_functions/sign.hpp>
16
#endif
17
18
namespace
mx
19
{
20
namespace
math
21
{
22
namespace
func
23
{
24
25
/// The sign function.
26
/**
27
* \ingroup functions
28
*/
29
template
<
typename
T>
30
T
sign
( T x
/**< [in] the argument */
)
31
{
32
#ifdef MX_INCLUDE_BOOST
33
return
boost::math::sign<T>(x);
34
#else
35
static_assert(std::is_fundamental<T>::value || !std::is_fundamental<T>::value,
"sign<T> not specialized for type T, and MX_INCLUDE_BOOST is not defined, so I can't just use boost."
);
36
return
0;
37
#endif
38
}
39
40
template
<>
41
float
sign<float>(
float
x);
42
43
template
<>
44
double
sign<double>(
double
x);
45
46
template
<>
47
long
double
sign<long double>(
long
double
x);
48
49
}
50
}
51
}
52
53
#endif
//mx_sign_hpp
mx::math::func::sign
T sign(T x)
The sign function.
Definition:
sign.hpp:30
mx
The mxlib c++ namespace.
Definition:
mxError.hpp:107
math
func
sign.hpp
Generated on Sun Nov 26 2023 10:58:11 for mxlib by
1.9.1