Commit 1b32975f by Olivier Stasse Committed by olivier stasse

### Fix and test the inclusion problem of both fast and rt.

`Add a unittest showing the problem with classical use of the library.`
parent b08d57dd
 ... ... @@ -19,6 +19,8 @@ #ifndef __eiquadprog_rt_hxx__ #define __eiquadprog_rt_hxx__ #include "eiquadprog/eiquadprog-utils.hxx" namespace eiquadprog { namespace solvers { ... ... @@ -182,15 +184,6 @@ void RtEiquadprog::delete_constraint(typename RtMatrixX } } template void print_vector(const char* name, Eigen::MatrixBase& x, int n) { // std::cerr << name << x.transpose() << std::endl; } template void print_matrix(const char* name, Eigen::MatrixBase& x, int n) { // std::cerr << name << std::endl << x << std::endl; } template RtEiquadprog_status RtEiquadprog::solve_quadprog( const typename RtMatrixX::d& Hess, const typename RtVectorX::d& g0, ... ...
 #ifndef EIQUADPROG_UTILS_HPP_ #define EIQUADPROG_UTILS_HPP_ /// Compute sqrt(a^2 + b^2) template inline Scalar distance(Scalar a, Scalar b) { Scalar a1, b1, t; a1 = std::abs(a); b1 = std::abs(b); if (a1 > b1) { t = (b1 / a1); return a1 * std::sqrt(1.0 + t * t); } else if (b1 > a1) { t = (a1 / b1); return b1 * std::sqrt(1.0 + t * t); } return a1 * std::sqrt(2.0); } template void print_vector(const char* name, Eigen::MatrixBase& x, int n) { // std::cerr << name << x.transpose() << std::endl; } template void print_matrix(const char* name, Eigen::MatrixBase& x, int n) { // std::cerr << name << std::endl << x << std::endl; } #endif
 ... ... @@ -22,9 +22,16 @@ SET(TESTS eiquadprog-basic eiquadprog-fast eiquadprog-rt eiquadprog-both ) FOREACH(test \${TESTS}) ADD_UNIT_TEST(\${test} \${test}.cpp) TARGET_LINK_LIBRARIES(\${test} \${PROJECT_NAME} \${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) ENDFOREACH(test \${TESTS}) ADD_LIBRARY(testab SHARED TestA.cpp TestB.cpp) TARGET_INCLUDE_DIRECTORIES(testab SYSTEM PRIVATE \${EIGEN3_INCLUDE_DIR}) #ADD_UNIT_TEST(test-integration test-integration.cpp ) #TARGET_LINK_LIBRARIES(test-integration \${PROJECT_NAME} \${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} testab)
tests/TestA.cpp 0 → 100644
 #include #include #include #include "TestA.hpp" using namespace eiquadprog::solvers; using namespace eiquadprog::tests; A::A(): Q_(2, 2), C_(2), Aeq_(0,2), Beq_(0), Aineq_(0,2), Bineq_(0), solution_(2), QP_() { QP_.reset(2, 0, 0); Q_.setZero(); Q_(0, 0) = 1.0; Q_(1, 1) = 1.0; C_.setZero(); solution_.setZero(); expected_ = EIQUADPROG_FAST_OPTIMAL; } EiquadprogFast_status A::solve(Eigen::VectorXd &x) { return QP_.solve_quadprog(Q_, C_, Aeq_, Beq_, Aineq_, Bineq_, x); }
tests/TestB.cpp 0 → 100644
 #include #include #include #include "TestB.hpp" using namespace eiquadprog::solvers; using namespace eiquadprog::tests; B::B() { } bool B::do_something() { }