From c37c009dbd69b5798d655934f8c2e12655db23db Mon Sep 17 00:00:00 2001 From: claisne Date: Sun, 5 Jun 2022 19:11:06 +0200 Subject: [PATCH] check if constraints are not NULL before unsetting equilibration --- src/ecos.c | 8 ++++---- src/equil.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ecos.c b/src/ecos.c index e5e321d4..d058bb69 100644 --- a/src/ecos.c +++ b/src/ecos.c @@ -1655,11 +1655,11 @@ void ECOS_updateData(pwork *w, pfloat *Gpr, pfloat *Apr, /* Only unequilibrate the old data if the new data is in a different location in memory. */ /* This is required for backward compatibility since existing code might need this step. */ if ( - ((Gpr + w->G->nnz < w->G->pr) || (w->G->pr + w->G->nnz < Gpr)) && - ((Apr + w->A->nnz < w->A->pr) || (w->A->pr + w->A->nnz < Apr)) && + (!w->G || ((Gpr + w->G->nnz < w->G->pr) || (w->G->pr + w->G->nnz < Gpr))) && + (!w->A || ((Apr + w->A->nnz < w->A->pr) || (w->A->pr + w->A->nnz < Apr))) && ((c + w->n < w->c) || (w->c + w->n < c)) && - ((h + w->m < w->h) || (w->h + w->m < h)) && - ((b + w->p < w->b) || (w->b + w->p < b)) + (!w->h || ((h + w->m < w->h) || (w->h + w->m < h))) && + (!w->b || ((b + w->p < w->b) || (w->b + w->p < b))) ){ unset_equilibration(w); } diff --git a/src/equil.c b/src/equil.c index 975014de..172b6e07 100644 --- a/src/equil.c +++ b/src/equil.c @@ -371,9 +371,9 @@ void unset_equilibration(pwork *w) idxint i; /* idxint num_cols = w->A ? w->A->n : w->G->n; */ idxint num_A_rows = w->A ? w->A->m : 0; - idxint num_G_rows = w->G->m; + idxint num_G_rows = w->G ? w->G->m : 0; - if(w->A) + if(num_A_rows > 0) restore(w->Aequil, w->xequil, w->A); if(num_G_rows > 0) restore(w->Gequil, w->xequil, w->G);