GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tests/math_utils.cpp Lines: 9 9 100.0 %
Date: 2024-02-02 08:47:34 Branches: 50 100 50.0 %

Line Branch Exec Source
1
//
2
// Copyright (c) 2017 CNRS
3
//
4
// This file is part of tsid
5
// tsid is free software: you can redistribute it
6
// and/or modify it under the terms of the GNU Lesser General Public
7
// License as published by the Free Software Foundation, either version
8
// 3 of the License, or (at your option) any later version.
9
// tsid is distributed in the hope that it will be
10
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
// General Lesser Public License for more details. You should have
13
// received a copy of the GNU Lesser General Public License along with
14
// tsid If not, see
15
// <http://www.gnu.org/licenses/>.
16
//
17
18
#include <iostream>
19
20
#include <boost/test/unit_test.hpp>
21
#include <boost/utility/binary.hpp>
22
23
#include <tsid/math/utils.hpp>
24
25
BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
26
27
















4
BOOST_AUTO_TEST_CASE(test_pseudoinverse) {
28
2
  std::cout << "test_pseudoinverse\n";
29
  using namespace tsid::math;
30
2
  const unsigned int m = 3;
31
2
  const unsigned int n = 5;
32
33

4
  Matrix A = Matrix::Random(m, n);
34

4
  Matrix Apinv = Matrix::Zero(n, m);
35

2
  pseudoInverse(A, Apinv, 1e-5);
36
37




2
  BOOST_CHECK(Matrix::Identity(m, m).isApprox(A * Apinv));
38
2
}
39
40
BOOST_AUTO_TEST_SUITE_END()