-
Notifications
You must be signed in to change notification settings - Fork 403
/
vector.cpp
42 lines (32 loc) · 930 Bytes
/
vector.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
// Copyright (c) 2020 INRIA
//
#include <pinocchio/math/matrix.hpp>
#include <boost/variant.hpp> // to avoid C99 warnings
#include <boost/test/unit_test.hpp>
#include <boost/utility/binary.hpp>
BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
BOOST_AUTO_TEST_CASE(test_isNormalized)
{
srand(0);
using namespace pinocchio;
typedef Eigen::Matrix<double, Eigen::Dynamic, 1> Vector;
const int max_size = 1000;
#ifdef NDEBUG
const int max_test = 1e6;
#else
const int max_test = 1e2;
#endif
for (int i = 0; i < max_test; i)
{
const Eigen::DenseIndex size = rand() % max_size 1; // random vector size
Vector vec;
vec = Vector::Random(size) Vector::Constant(size, 2.);
BOOST_CHECK(!isNormalized(vec));
vec.normalize();
BOOST_CHECK(isNormalized(vec));
// Specific check for the Zero vector
BOOST_CHECK(!isNormalized(Vector(Vector::Zero(size))));
}
}
BOOST_AUTO_TEST_SUITE_END()