eiquadprog-utils.hxx
Go to the documentation of this file.
1 #ifndef EIQUADPROG_UTILS_HPP_
2 #define EIQUADPROG_UTILS_HPP_
3 
4 #include <Eigen/Core>
5 
7 template <typename Scalar>
8 inline Scalar distance(Scalar a, Scalar b) {
9  Scalar a1, b1, t;
10  a1 = std::abs(a);
11  b1 = std::abs(b);
12  if (a1 > b1) {
13  t = (b1 / a1);
14  return a1 * std::sqrt(1.0 + t * t);
15  } else if (b1 > a1) {
16  t = (a1 / b1);
17  return b1 * std::sqrt(1.0 + t * t);
18  }
19  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
distance
Scalar distance(Scalar a, Scalar b)
Compute sqrt(a^2 + b^2)
Definition: eiquadprog-utils.hxx:8
print_matrix
void print_matrix(const char *name, Eigen::MatrixBase< Derived > &x, int n)
Definition: eiquadprog-utils.hxx:27
print_vector
void print_vector(const char *name, Eigen::MatrixBase< Derived > &x, int n)
Definition: eiquadprog-utils.hxx:23