Skip to content

Commit 6d790dc

Browse files
committed
[CMake] add TRACE_SOLVER option
fix stack-of-tasks/tsid#93
1 parent 4c4d040 commit 6d790dc

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ SET(PROJECT_NAME eiquadprog)
2525
SET(PROJECT_DESCRIPTION "C++ reimplementation of eiquadprog")
2626
SET(PROJECT_URL "https://github.com/${PROJECT_ORG}/${PROJECT_NAME}")
2727

28+
# Project options
29+
OPTION(TRACE_SOLVER "trace solver on stderr" OFF)
30+
2831
# Project configuration
2932
SET(PROJECT_USE_CMAKE_EXPORT TRUE)
3033
SET(CXX_DISABLE_WERROR TRUE)
@@ -50,14 +53,18 @@ SET(${PROJECT_NAME}_HEADERS
5053
include/${PROJECT_NAME}/eiquadprog-fast.hpp
5154
include/${PROJECT_NAME}/eiquadprog-rt.hpp
5255
include/${PROJECT_NAME}/eiquadprog-rt.hxx
53-
include/${PROJECT_NAME}/eiquadprog-utils.hxx
56+
include/${PROJECT_NAME}/eiquadprog-utils.hxx
5457
)
5558

5659
ADD_LIBRARY(${PROJECT_NAME} SHARED
5760
src/eiquadprog-fast.cpp
5861
src/eiquadprog.cpp
5962
)
6063

64+
IF(TRACE_SOLVER)
65+
TARGET_COMPILE_DEFINITIONS(${PROJECT_NAME} PRIVATE TRACE_SOLVER)
66+
ENDIF(TRACE_SOLVER)
67+
6168
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} SYSTEM PRIVATE ${EIGEN3_INCLUDE_DIR})
6269
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} SYSTEM INTERFACE ${EIGEN3_INCLUDE_DIR})
6370
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} INTERFACE $<INSTALL_INTERFACE:include>)

src/eiquadprog-fast.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <iostream>
22

33
#include "eiquadprog/eiquadprog-fast.hpp"
4-
#define TRACE_SOLVER
54

65
namespace eiquadprog {
76
namespace solvers {

src/eiquadprog.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ double solve_quadprog2(LLT<MatrixXd, Lower>& chol, double c1, VectorXd& g0, cons
193193
print_vector("r", r, iq + 1);
194194
print_vector("u", u, iq + 1);
195195
print_vector("d", d, n);
196-
print_ivector("A", A, iq + 1);
196+
print_vector("A", A, iq + 1);
197197
#endif
198198

199199
/* Step 2b: compute step length */
@@ -240,7 +240,7 @@ double solve_quadprog2(LLT<MatrixXd, Lower>& chol, double c1, VectorXd& g0, cons
240240
std::cerr << " in dual space: " << f_value << std::endl;
241241
print_vector("x", x, n);
242242
print_vector("z", z, n);
243-
print_ivector("A", A, iq + 1);
243+
print_vector("A", A, iq + 1);
244244
#endif
245245
goto l2a;
246246
}
@@ -258,7 +258,7 @@ double solve_quadprog2(LLT<MatrixXd, Lower>& chol, double c1, VectorXd& g0, cons
258258
print_vector("x", x, n);
259259
print_vector("u", u, iq + 1);
260260
print_vector("r", r, iq + 1);
261-
print_ivector("A", A, iq + 1);
261+
print_vector("A", A, iq + 1);
262262
#endif
263263

264264
if (t == t2) {
@@ -273,7 +273,7 @@ double solve_quadprog2(LLT<MatrixXd, Lower>& chol, double c1, VectorXd& g0, cons
273273
delete_constraint(R, J, A, u, p, iq, ip);
274274
#ifdef TRACE_SOLVER
275275
print_matrix("R", R, n);
276-
print_ivector("A", A, iq);
276+
print_vector("A", A, iq);
277277
#endif
278278
for (i = 0; i < m; i++) iai(i) = static_cast<VectorXi::Scalar>(i);
279279
for (i = 0; i < iq; i++) {
@@ -287,7 +287,7 @@ double solve_quadprog2(LLT<MatrixXd, Lower>& chol, double c1, VectorXd& g0, cons
287287
iai(ip) = -1;
288288
#ifdef TRACE_SOLVER
289289
print_matrix("R", R, n);
290-
print_ivector("A", A, iq);
290+
print_vector("A", A, iq);
291291
#endif
292292
goto l1;
293293
}
@@ -302,7 +302,7 @@ double solve_quadprog2(LLT<MatrixXd, Lower>& chol, double c1, VectorXd& g0, cons
302302
delete_constraint(R, J, A, u, p, iq, l);
303303
#ifdef TRACE_SOLVER
304304
print_matrix("R", R, n);
305-
print_ivector("A", A, iq);
305+
print_vector("A", A, iq);
306306
#endif
307307

308308
s(ip) = CI.col(ip).dot(x) + ci0(ip);

0 commit comments

Comments
 (0)