GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/eiquadprog/eiquadprog-utils.hxx Lines: 8 10 80.0 %
Date: 2021-03-10 23:02:29 Branches: 3 4 75.0 %

Line Branch Exec Source
1
#ifndef EIQUADPROG_UTILS_HPP_
2
#define EIQUADPROG_UTILS_HPP_
3
4
#include <Eigen/Core>
5
6
/// Compute sqrt(a^2 + b^2)
7
template <typename Scalar>
8
12
inline Scalar distance(Scalar a, Scalar b) {
9
  Scalar a1, b1, t;
10
12
  a1 = std::abs(a);
11
12
  b1 = std::abs(b);
12
12
  if (a1 > b1) {
13
6
    t = (b1 / a1);
14
6
    return a1 * std::sqrt(1.0 + t * t);
15
6
  } else if (b1 > a1) {
16
    t = (a1 / b1);
17
    return b1 * std::sqrt(1.0 + t * t);
18
  }
19
6
  return a1 * std::sqrt(2.0);
20
}
21
22
template <class Derived>
23
void print_vector(const char* name, Eigen::MatrixBase<Derived>& x, int n) {
24
  //  std::cerr << name << x.transpose() << std::endl;
25
}
26
template <class Derived>
27
void print_matrix(const char* name, Eigen::MatrixBase<Derived>& x, int n) {
28
  //  std::cerr << name << std::endl << x << std::endl;
29
}
30
31
#endif