GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: unittest/eigen-basic-op.cpp Lines: 20 20 100.0 %
Date: 2024-01-23 21:41:47 Branches: 134 268 50.0 %

Line Branch Exec Source
1
//
2
// Copyright (c) 2019 INRIA
3
//
4
5
#include "pinocchio/multibody/model.hpp"
6
7
#include <Eigen/Core>
8
#include "pinocchio/math/matrix.hpp"
9
10
#include <boost/test/unit_test.hpp>
11
#include <boost/utility/binary.hpp>
12
13
BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
14
15
















4
BOOST_AUTO_TEST_CASE(test_matrix_matrix_product)
16
{
17
  using namespace pinocchio;
18
  using namespace Eigen;
19
2
  const Eigen::DenseIndex m = 20, n = 100;
20


4
  MatrixXd M1(MatrixXd::Ones(m,n)), M2(MatrixXd::Ones(n,m));
21
2
  MatrixMatrixProduct<MatrixXd,MatrixXd>::type res = M1 * M2;
22




2
  BOOST_CHECK(!res.eval().isZero());
23
2
}
24
25
















4
BOOST_AUTO_TEST_CASE(test_scalar_matrix_product)
26
{
27
  using namespace pinocchio;
28
  using namespace Eigen;
29
2
  const Eigen::DenseIndex m = 20, n = 100;
30

4
  MatrixXd M(MatrixXd::Ones(m,n));
31
2
  const double alpha = 0.;
32
2
  ScalarMatrixProduct<double,MatrixXd>::type res = alpha * M;
33




2
  BOOST_CHECK(res.eval().isZero());
34
2
}
35
36
















4
BOOST_AUTO_TEST_CASE(test_matrix_scalar_product)
37
{
38
  using namespace pinocchio;
39
  using namespace Eigen;
40
2
  const Eigen::DenseIndex m = 20, n = 100;
41

4
  MatrixXd M(MatrixXd::Ones(m,n));
42
2
  const double alpha = 1.;
43
2
  MatrixScalarProduct<MatrixXd,double>::type res = M * alpha;
44




2
  BOOST_CHECK(res.eval() == M);
45
2
}
46
47
BOOST_AUTO_TEST_SUITE_END()
48