Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
gtsam
3rdparty
Eigen
test
numext.cpp
Go to the documentation of this file.
1
// This file is part of Eigen, a lightweight C++ template library
2
// for linear algebra.
3
//
4
// Copyright (C) 2017 Gael Guennebaud <gael.guennebaud@inria.fr>
5
//
6
// This Source Code Form is subject to the terms of the Mozilla
7
// Public License v. 2.0. If a copy of the MPL was not distributed
8
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
10
#include "
main.h
"
11
12
template
<
typename
T>
13
void
check_abs
() {
14
typedef
typename
NumTraits<T>::Real
Real
;
15
16
if
(
NumTraits<T>::IsSigned
)
17
VERIFY_IS_EQUAL
(
numext::abs
(-
T
(1)),
T
(1));
18
VERIFY_IS_EQUAL
(
numext::abs
(
T
(0)),
T
(0));
19
VERIFY_IS_EQUAL
(
numext::abs
(
T
(1)),
T
(1));
20
21
for
(
int
k=0; k<
g_repeat
*100; ++k)
22
{
23
T
x
= internal::random<T>();
24
if
(!
internal::is_same<T,bool>::value
)
25
x = x/
Real
(2);
26
if
(
NumTraits<T>::IsSigned
)
27
{
28
VERIFY_IS_EQUAL
(
numext::abs
(x),
numext::abs
(-x));
29
VERIFY
(
numext::abs
(-x) >=
Real
(0));
30
}
31
VERIFY
(
numext::abs
(x) >=
Real
(0));
32
VERIFY_IS_APPROX
(
numext::abs2
(x),
numext::abs2
(
numext::abs
(x)) );
33
}
34
}
35
36
void
test_numext
() {
37
CALL_SUBTEST
( check_abs<bool>() );
38
CALL_SUBTEST
( check_abs<signed char>() );
39
CALL_SUBTEST
( check_abs<unsigned char>() );
40
CALL_SUBTEST
( check_abs<short>() );
41
CALL_SUBTEST
( check_abs<unsigned short>() );
42
CALL_SUBTEST
( check_abs<int>() );
43
CALL_SUBTEST
( check_abs<unsigned int>() );
44
CALL_SUBTEST
( check_abs<long>() );
45
CALL_SUBTEST
( check_abs<unsigned long>() );
46
CALL_SUBTEST
( check_abs<half>() );
47
CALL_SUBTEST
( check_abs<float>() );
48
CALL_SUBTEST
( check_abs<double>() );
49
CALL_SUBTEST
( check_abs<long double>() );
50
51
CALL_SUBTEST
(
check_abs
<std::complex<float> >() );
52
CALL_SUBTEST
(
check_abs
<std::complex<double> >() );
53
}
test_numext
void test_numext()
Definition:
numext.cpp:36
Eigen::NumTraits
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition:
NumTraits.h:150
check_abs
void check_abs()
Definition:
numext.cpp:13
main.h
VERIFY_IS_APPROX
#define VERIFY_IS_APPROX(a, b)
Definition:
integer_types.cpp:15
VERIFY_IS_EQUAL
#define VERIFY_IS_EQUAL(a, b)
Definition:
main.h:331
test_callbacks.value
value
Definition:
test_callbacks.py:116
Eigen::g_repeat
static int g_repeat
Definition:
main.h:144
T
Eigen::Triplet< double > T
Definition:
Tutorial_sparse_example.cpp:6
abs2
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Abs2ReturnType abs2() const
Definition:
ArrayCwiseUnaryOps.h:71
Eigen::Triplet< double >
Real
mp::number< mp::cpp_dec_float< 100 >, mp::et_on > Real
Definition:
boostmultiprec.cpp:72
CALL_SUBTEST
#define CALL_SUBTEST(FUNC)
Definition:
main.h:342
VERIFY
#define VERIFY(a)
Definition:
main.h:325
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition:
gnuplot_common_settings.hh:12
abs
#define abs(x)
Definition:
datatypes.h:17
gtsam
Author(s):
autogenerated on Sat May 8 2021 02:43:05