tlx
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
abs_diff.hpp
Go to the documentation of this file.
1
/*******************************************************************************
2
* tlx/math/abs_diff.hpp
3
*
4
* Part of tlx - http://panthema.net/tlx
5
*
6
* Copyright (C) 2017 Timo Bingmann <tb@panthema.net>
7
*
8
* All rights reserved. Published under the Boost Software License, Version 1.0
9
******************************************************************************/
10
11
#ifndef TLX_MATH_ABS_DIFF_HEADER
12
#define TLX_MATH_ABS_DIFF_HEADER
13
14
namespace
tlx
{
15
16
//! \addtogroup tlx_math
17
//! \{
18
19
/******************************************************************************/
20
// abs_diff() - calculate absolute difference
21
22
//! absolute difference, which also works for unsigned types
23
template
<
typename
T>
24
T
abs_diff
(
const
T& a,
const
T& b) {
25
return
a > b ? a - b : b - a;
26
}
27
28
//! \}
29
30
}
// namespace tlx
31
32
#endif // !TLX_MATH_ABS_DIFF_HEADER
33
34
/******************************************************************************/
tlx
Definition:
exclusive_scan.hpp:17
tlx::abs_diff
T abs_diff(const T &a, const T &b)
absolute difference, which also works for unsigned types
Definition:
abs_diff.hpp:24
tlx
math
abs_diff.hpp
Generated on Sat Oct 2 2021 20:29:00 for tlx by
1.8.11