vector.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 INRIA
3 //
4 
6 
7 #include <boost/variant.hpp> // to avoid C99 warnings
8 
9 #include <boost/test/unit_test.hpp>
10 #include <boost/utility/binary.hpp>
11 
12 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
13 
14 BOOST_AUTO_TEST_CASE(test_isNormalized)
15 {
16  srand(0);
17 
18  using namespace pinocchio;
19  typedef Eigen::Matrix<double, Eigen::Dynamic, 1> Vector;
20 
21  const int max_size = 1000;
22 #ifdef NDEBUG
23  const int max_test = 1e6;
24 #else
25  const int max_test = 1e2;
26 #endif
27  for (int i = 0; i < max_test; ++i)
28  {
29  const Eigen::DenseIndex size = rand() % max_size + 1; // random vector size
30  Vector vec;
31  vec = Vector::Random(size) + Vector::Constant(size, 2.);
32  BOOST_CHECK(!isNormalized(vec));
33 
34  vec.normalize();
35  BOOST_CHECK(isNormalized(vec));
36 
37  // Specific check for the Zero vector
38  BOOST_CHECK(!isNormalized(Vector(Vector::Zero(size))));
39  }
40 }
41 
42 BOOST_AUTO_TEST_SUITE_END()
inverse-kinematics.i
int i
Definition: inverse-kinematics.py:17
vec
vec
pinocchio::isNormalized
bool isNormalized(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const Eigen::MatrixBase< ConfigVectorType > &q, const Scalar &prec=Eigen::NumTraits< Scalar >::dummy_precision())
Check whether a configuration vector is normalized within the given precision provided by prec.
Definition: joint-configuration.hpp:933
matrix.hpp
size
FCL_REAL size() const
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(test_isNormalized)
Definition: vector.cpp:14
pinocchio.utils.rand
def rand(n)
Definition: bindings/python/pinocchio/utils.py:41
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27


pinocchio
Author(s):
autogenerated on Thu Dec 19 2024 03:41:33