From 17e3d92a905ed4f4bef2001935d49f2fb47e6bf1 Mon Sep 17 00:00:00 2001 From: darnstrom Date: Sun, 18 Oct 2026 00:08:21 +0200 Subject: [PATCH] Remove dead code and fix compiler warnings --- .github/copilot-instructions.md | 2 +- codegen/codegen.c | 2 +- include/api.h | 2 -- include/factorization.h | 2 -- src/api.c | 10 +--------- src/factorization.c | 4 ---- src/utils.c | 4 +--- 7 files changed, 4 insertions(+), 22 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 7cb36197..14bf3b30 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -58,7 +58,7 @@ Key data structures are in `include/types.h`: `DAQPProblem` (problem data), `DAQ The typical call sequence is: 1. `setup_daqp(qp, work, ...)` — allocate workspace and factor the Hessian 2. `daqp_solve(res, work)` — run the solver -3. Optionally call `setup_daqp_bnb` / `setup_daqp_hiqp` / `setup_daqp_avi` before step 2 for specialized variants +3. Optionally call `setup_daqp_bnb` / `setup_daqp_hiqp` before step 2 for specialized variants (AVIs are selected by setting `qp->problem_type = 1` before `setup_daqp`) ## Conventions diff --git a/codegen/codegen.c b/codegen/codegen.c index e7e4f6e7..531aafe3 100644 --- a/codegen/codegen.c +++ b/codegen/codegen.c @@ -32,7 +32,7 @@ void render_daqp_workspace(DAQPWorkspace* work, const char *fname, const char *d strcat(hguard, "_H"); char *s = hguard; while(*s){ - *s = toupper((unsigned char) *s); + *s = (char)toupper((unsigned char) *s); s++; } fprintf(fh, "#ifndef %s\n", hguard); diff --git a/include/api.h b/include/api.h index a0fd7903..d49c3aaf 100644 --- a/include/api.h +++ b/include/api.h @@ -35,7 +35,6 @@ int setup_daqp_main(DAQPProblem *qp, DAQPWorkspace* work, c_float* setup_time, i int setup_daqp_ldp(DAQPWorkspace *work, DAQPProblem* qp, const int init_mask); void setup_daqp_hiqp(DAQPWorkspace *work, int* break_points, int nh); int setup_daqp_bnb(DAQPWorkspace* work, int* sense, int nb, int ns); -int setup_daqp_avi(DAQPAVI* avi, DAQPProblem* p, DAQPWorkspace* work, c_float* setup_time); void allocate_daqp_settings(DAQPWorkspace *work); void allocate_daqp_workspace(DAQPWorkspace *work, int n, int ns); @@ -58,7 +57,6 @@ void daqp_extract_result(DAQPResult* res, DAQPWorkspace* work); // result of the original problem, and carry its working set over to the // original constraints void daqp_eq_expand(DAQPResult* res, DAQPWorkspace* work); -void daqp_extract_active_duals(DAQPResult* res, DAQPWorkspace* work); void daqp_default_settings(DAQPSettings *settings); void daqp_minrep(int* is_redundant, c_float* A, c_float* b, int n, int m, int ms); int daqp_first_violating(c_float* x, c_float* A, c_float* bu, c_float* bl, int n, int m, int ms, c_float tol); diff --git a/include/factorization.h b/include/factorization.h index b03ba52c..afde04a4 100644 --- a/include/factorization.h +++ b/include/factorization.h @@ -8,8 +8,6 @@ extern "C" { #include "types.h" #include "constants.h" -c_float daqp_dot(const c_float* v1, const c_float* v2, const int n); - static inline c_float daqp_dot_inline(const c_float* v1, const c_float* v2, const int n) { c_float sum = 0.0; for (int i = 0; i < n; i++) sum += v1[i] * v2[i]; diff --git a/src/api.c b/src/api.c index 87dde831..60af8859 100644 --- a/src/api.c +++ b/src/api.c @@ -143,7 +143,7 @@ int setup_daqp_main(DAQPProblem* qp, DAQPWorkspace *work, c_float* setup_time, i if(qp->nh > 1){ ns = 0; // Reset int start = 0; - for(int i = 0; i < qp->nh; i++){ + for(i = 0; i < qp->nh; i++){ ns = (ns > qp->break_points[i]-start) ? ns : qp->break_points[i]-start; start = qp->break_points[i]; } @@ -559,14 +559,6 @@ void daqp_extract_result(DAQPResult* res, DAQPWorkspace* work){ res->nodes = work->outer_iter; } -void daqp_extract_active_duals(DAQPResult* res, DAQPWorkspace* work){ - int i; - if(res->lam == NULL) return; - for(i=0;im;i++) res->lam[i] = 0; - for(i=0;in_active;i++) - res->lam[work->WS[i]] = work->lam_star[i]; -} - void daqp_default_settings(DAQPSettings* settings){ settings->primal_tol = DAQP_DEFAULT_PRIM_TOL; settings->dual_tol = DAQP_DEFAULT_DUAL_TOL; diff --git a/src/factorization.c b/src/factorization.c index 4348e19f..1d42e4ab 100644 --- a/src/factorization.c +++ b/src/factorization.c @@ -14,10 +14,6 @@ static c_float dot_row(const c_float* a, const c_float* b, const int n){ return (s0+s1)+(s2+s3); } -c_float daqp_dot(const c_float* v1, const c_float* v2, const int n) { - return daqp_dot_inline(v1, v2, n); -} - void daqp_update_LDL_add(DAQPWorkspace *work, const int add_ind, const c_float rho){ work->sing_ind = DAQP_EMPTY_IND; int i,j,disp,id; diff --git a/src/utils.c b/src/utils.c index 548066d0..89f63640 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1028,7 +1028,6 @@ void daqp_minrep_work(int* is_redundant, DAQPWorkspace* work){ reset_daqp_workspace(work); work->sense[i] = 5; daqp_add_constraint(work,i,1.0); - //work->dupper[i] += tol_weak; TODO support weaky infeasible constraints exitflag = daqp_ldp(work); if(exitflag== DAQP_EXIT_INFEASIBLE){ is_redundant[i] = 1; @@ -1041,7 +1040,6 @@ void daqp_minrep_work(int* is_redundant, DAQPWorkspace* work){ for(j=0; j < work->n_active; j++) // all active constraint must also be nonredundant is_redundant[work->WS[j]] = 0; } - // work->dupper[i] -= tol_weak; // TODO support weakly infeasible constraints daqp_deactivate_constraints(work); } } @@ -1092,7 +1090,7 @@ double get_time(DAQPtimer *timer){ struct timespec diff; if ((timer->stop.tv_nsec - timer->start.tv_nsec) < 0) { diff.tv_sec = timer->stop.tv_sec - timer->start.tv_sec - 1; - diff.tv_nsec = 1e9 + timer->stop.tv_nsec - timer->start.tv_nsec; + diff.tv_nsec = 1000000000L + timer->stop.tv_nsec - timer->start.tv_nsec; } else { diff.tv_sec = timer->stop.tv_sec - timer->start.tv_sec; diff.tv_nsec = timer->stop.tv_nsec - timer->start.tv_nsec;