Thrill
0.1
sgn.hpp
Go to the documentation of this file.
1
/*******************************************************************************
2
* tlx/math/sgn.hpp
3
*
4
* sgn() return the signum (-1, 0, +1) of a value.
5
*
6
* Part of tlx - http://panthema.net/tlx
7
*
8
* Copyright (C) 2018 Timo Bingmann <
[email protected]
>
9
*
10
* All rights reserved. Published under the Boost Software License, Version 1.0
11
******************************************************************************/
12
13
#ifndef TLX_MATH_SGN_HEADER
14
#define TLX_MATH_SGN_HEADER
15
16
namespace
tlx
{
17
18
//! \addtogroup tlx_math
19
//! \{
20
21
/******************************************************************************/
22
//! sgn() - signum
23
24
//! return the signum (-1, 0, +1) of a value.
25
template
<
typename
T>
26
int
sgn
(
const
T
& val) {
27
// from https://stackoverflow.com/questions/1903954
28
return
(
T
(0) < val) - (val <
T
(0));
29
}
30
31
//! \}
32
33
}
// namespace tlx
34
35
#endif // !TLX_MATH_SGN_HEADER
36
37
/******************************************************************************/
T
double T
Definition:
logistic_regression.cpp:34
tlx
Definition:
exclusive_scan.hpp:17
tlx::sgn
int sgn(const T &val)
sgn() - signum
Definition:
sgn.hpp:26
extlib
tlx
tlx
math
sgn.hpp
Generated on Mon Apr 6 2020 09:17:55 for Thrill by
1.8.13