From 313c7d2c918b2e6eef6f1c6c45ff1c31135a3b08 Mon Sep 17 00:00:00 2001 From: Robert Jenssen Date: Sun, 16 Aug 2020 00:01:46 +1000 Subject: [PATCH 1/5] Fix compiler warnings about uninitialised variables and https://github.com/sqlp/sedumi/issues/15 --- blkchol2.c | 2 +- bwblkslv.c | 2 +- dpr1fact.c | 2 +- extractA.c | 2 +- fwblkslv.c | 2 +- install_sedumi.m | 4 ++++ sedumi.m | 2 +- spscale.c | 8 ++++++-- urotorder.c | 4 +++- 9 files changed, 19 insertions(+), 9 deletions(-) diff --git a/blkchol2.c b/blkchol2.c index 7b5a174..2d91642 100644 --- a/blkchol2.c +++ b/blkchol2.c @@ -113,7 +113,7 @@ void cholonBlk(double *x, double *d, mwIndex m, const mwIndex ncols, const mwInd ------------------------------------------------------- */ xkk = x[inz]; if(xkk > lb[k]){ /* now xkk > 0 */ - if(xkk < ub){ + if((m>1) && (xkk < ub)){ ubk = maxabs(x+inz+1,m-1) / maxu; if(xkk < ubk){ /* ------------------------------------------------------------ diff --git a/bwblkslv.c b/bwblkslv.c index 55a1a8e..f837e6d 100644 --- a/bwblkslv.c +++ b/bwblkslv.c @@ -186,7 +186,7 @@ void mexFunction(const int nlhs, mxArray *plhs[], mwIndex m,n, j, k, nsuper, inz; double *y, *fwork; const double *permPr, *b, *xsuperPr; - const mwIndex *yjc, *yir, *bjc, *bir; + const mwIndex *yjc=NULL, *yir=NULL, *bjc=NULL, *bir=NULL; mwIndex *perm, *xsuper, *iwork, *snode; jcir L; char bissparse; diff --git a/dpr1fact.c b/dpr1fact.c index 45778aa..83a5a59 100644 --- a/dpr1fact.c +++ b/dpr1fact.c @@ -365,7 +365,7 @@ char dodpr1fact(double *beta, mwIndex *perm, double *d, double t, const double * ------------------------------------------------------------ */ else{ psqrdep = 0.0; - for(i = 0; dep[i] < m; i++) + for(i = 0, j = 0; dep[i] < m; i++) if(psqr[dep[i]] > psqrdep){ j = i; psqrdep = psqr[dep[i]]; diff --git a/extractA.c b/extractA.c index ee7f683..23792c6 100644 --- a/extractA.c +++ b/extractA.c @@ -98,7 +98,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { jcir At, Apart; - mwIndex i, m, njc, ifirst, n, ynnz, blk0,blk1; + mwIndex i, m, njc, ifirst=0, n=0, ynnz, blk0, blk1; mwIndex *Ajc; const double *blkstartPr, *AjcPr; bool isblk0negative; diff --git a/fwblkslv.c b/fwblkslv.c index b449376..931cc2a 100644 --- a/fwblkslv.c +++ b/fwblkslv.c @@ -197,7 +197,7 @@ void mexFunction(const int nlhs, mxArray *plhs[], mwIndex m,n, j, k, nsuper, inz; double *y,*fwork; const double *permPr, *b, *xsuperPr; - const mwIndex *yjc, *yir, *bjc, *bir; + const mwIndex *yjc=NULL, *yir=NULL, *bjc=NULL, *bir=NULL; mwIndex *perm, *invperm, *snode, *xsuper, *iwork; jcir L; char bissparse; diff --git a/install_sedumi.m b/install_sedumi.m index 62d5e8f..5ba829f 100644 --- a/install_sedumi.m +++ b/install_sedumi.m @@ -175,6 +175,10 @@ function install_sedumi( varargin ) % whereas calling '-O' would result in gcc '-O1'. flags{end+1} = '-O2'; flags{end+1} = '-DOCTAVE'; + flags{end+1} = '-Werror'; + flags{end+1} = '-Wall'; + flags{end+1} = '-Wno-unused-variable'; + flags{end+1} = '-Wno-unused-but-set-variable'; if (ismac ()) % Assume Homebrew (https://brew.sh/) installation. % https://stackoverflow.com/questions/50634727/dyld-library-not-loaded-usr-local-opt-openblas-lib-libopenblasp-r0-2-20-dylib diff --git a/sedumi.m b/sedumi.m index f225414..1d66be9 100644 --- a/sedumi.m +++ b/sedumi.m @@ -794,7 +794,7 @@ info.err(4)=0; end % Dual infeasibility - %info.err(3)=0.0; %s is not maintained explicitely + info.err(3)=0.0; %s is not maintained explicitely % Relative duality gap info.err(5)=(cx-by)/(1+abs(cx)+abs(by)); % Relative complementarity diff --git a/spscale.c b/spscale.c index 23effea..413a966 100644 --- a/spscale.c +++ b/spscale.c @@ -76,6 +76,7 @@ mwIndex realdmulx(double *y, mwIndex *ycols, const double *d, { mwIndex knz, jfirst, jlast, inz, i, j; knz = 0; /* length(ycols) */ + jfirst = 0; jlast = 0; /* index right after last activated column */ y -= n; /* point to dummy column, which will be skipped */ /* ------------------------------------------------------------ @@ -133,6 +134,7 @@ mwIndex cpxdmulx(double *y, mwIndex *ycols, const double *d, const double *dpi; char found; knz = 0; /* length(ycols) */ + jfirst = 0; jlast = 0; /* index right after last activated column */ nsqr = SQR(n); dpi = d + nsqr; @@ -251,7 +253,7 @@ void sprealdxd(double *z, const mwIndex *zir, const mwIndex znnz, { mwIndex inz, i, icol, j, jfirst, jlast, m; double *xd; - const double *dj, *xdj; + const double *dj=NULL, *xdj=NULL; /* ------------------------------------------------------------ Partition 2*n^2 WORKING array fwork into [fwork(n^2), xd(n^2)]. ------------------------------------------------------------ */ @@ -276,6 +278,7 @@ void sprealdxd(double *z, const mwIndex *zir, const mwIndex znnz, zij = (D*sym(X)*D)_ij = [ DXD_ij + DXD_ji ] /2. Note that DXD_ij = xd(:,i)' * fwork(:,j). (m mults) ------------------------------------------------------------ */ + jfirst = 0; jlast = 0; /* index right after last activated column */ for(inz = 0; inz < znnz; inz++){ if((i = zir[inz]) >= jlast){ /* move to new z-column */ @@ -334,7 +337,8 @@ void spcpxdxd(double *z, const mwIndex *zir, const mwIndex znnz, mwIndex inz, i, icol, j, jfirst, jlast, m, nsqr, imgfirst; double *dx, *dxpi, *fworkpi; double zi; - const double *dj, *djpi, *djx, *djxpi; + const double *dj=NULL, *djpi=NULL, *djx=NULL, *djxpi=NULL; + jfirst = 0; nsqr = SQR(n); /* ------------------------------------------------------------ Partition 4*n^2 WORKING array fwork into [fwork(2*n^2), dxRows(2*n^2)]. diff --git a/urotorder.c b/urotorder.c index 01fdf6a..0937d5c 100644 --- a/urotorder.c +++ b/urotorder.c @@ -90,6 +90,7 @@ void rotorder(mwIndex *perm, double *u, mwIndex *gjc, twodouble *g, double *d, ------------------------------------------------------------ */ for(j = 0; j < n; j++) perm[j] = j; + pivk = 0; inz = 0; d[0] = 0.0; h = 1.0; for(k = 0, rowuk = u; k < n-1; k++, rowuk++){ @@ -208,6 +209,7 @@ void prpirotorder(mwIndex *perm, double *u,double *upi, mwIndex *gjc, ------------------------------------------------------------ */ for(j = 0; j < n; j++) perm[j] = j; + pivk = 0; inz = 0; d[0] = 0.0; h = 1.0; for(k = 0, rowuk = u, rowukpi = upi; k < n-1; k++, rowuk++, rowukpi++){ @@ -312,7 +314,7 @@ void mexFunction(const int nlhs, mxArray *plhs[], { mxArray *myplhs[NPAROUT]; mwIndex i,j,k, nk, nksqr, lenud, sdplen, gnnz, inz, maxKs,maxKssqr, rgnnz, hgnnz; - const double *uOld, *permOld; + const double *uOld, *permOld=NULL; double *u, *d, *gjcPr, *permPr, *fwork, *fworkpi; mwIndex *perm, *gjc; double *g, *gk; From 3d0e453313a7377d96a94bf7241d526b2688ce2d Mon Sep 17 00:00:00 2001 From: Robert Jenssen Date: Tue, 18 Aug 2020 22:00:12 +1000 Subject: [PATCH 2/5] Fix unused variable warnings when compiling SeDuMi --- adendotd.c | 7 ++++++- adenscale.c | 7 ++++++- blkchol2.c | 19 ++++++++++++------- dpr1fact.c | 3 ++- extractA.c | 4 +++- getada3.c | 7 ++++++- givensrot.c | 7 ++++++- install_sedumi.m | 4 ---- psdframeit.c | 9 +++++++-- psdinvjmul.c | 7 ++++++- sdmauxCone.c | 7 ++++++- sedumi.m | 16 +++++++--------- sqrtinv.c | 7 ++++++- urotorder.c | 2 +- vecsym.c | 4 +--- 15 files changed, 75 insertions(+), 35 deletions(-) diff --git a/adendotd.c b/adendotd.c index 3327649..eb448e6 100644 --- a/adendotd.c +++ b/adendotd.c @@ -136,7 +136,10 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { const mxArray *MY_FIELD; - mwIndex i,j,firstQ, m,nden, nl, nq, lorN; + mwIndex i,j,firstQ, m,nden, nl, nq; +#ifdef MEX_DEBUG + mwIndex lorN; +#endif mwIndex *q, *dencols, *blkend; const double *d1, *d2, *qPr, *dencolsPr, *blkstartPr; double *fwork; @@ -176,7 +179,9 @@ void mexFunction(int nlhs, mxArray *plhs[], mxAssert(mxIsStruct(D_IN), "d should be a structure."); MY_FIELD = mxGetField(D_IN,(mwIndex)0,"q1"); /* d.q1 */ mxAssert( MY_FIELD != NULL, "Missing field d.q1."); +#ifdef MEX_DEBUG lorN = mxGetM(MY_FIELD) * mxGetN(MY_FIELD); +#endif d1 = mxGetPr(MY_FIELD); MY_FIELD = mxGetField(D_IN,(mwIndex)0,"q2"); /* d.q2 */ mxAssert( MY_FIELD != NULL, "Missing field d.q2."); diff --git a/adenscale.c b/adenscale.c index f9ff8f6..a0692bd 100644 --- a/adenscale.c +++ b/adenscale.c @@ -88,7 +88,10 @@ void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { const mxArray *MY_FIELD; - mwIndex i, j, nden, nl, nq, lorN; + mwIndex i, j, nden, nl, nq; +#ifdef MEX_DEBUG + mwIndex lorN; +#endif mwIndex *q, *dencols, *blkend; const double *qPr, *dencolsPr, *detd, *blkstartPr; /* ------------------------------------------------------------ @@ -119,7 +122,9 @@ void mexFunction( int nlhs, mxArray *plhs[], MY_FIELD = mxGetField(D_IN,(mwIndex)0,"det"); /* d.det */ mxAssert( MY_FIELD != NULL, "Missing field d.det."); detd = mxGetPr(MY_FIELD); +#ifdef MEX_DEBUG lorN = (mwIndex) (mxGetM(MY_FIELD) * mxGetN(MY_FIELD)); +#endif /* ------------------------------------------------------------ Get INPUTS blkstart ------------------------------------------------------------ */ diff --git a/blkchol2.c b/blkchol2.c index 2d91642..c1822c5 100644 --- a/blkchol2.c +++ b/blkchol2.c @@ -113,16 +113,21 @@ void cholonBlk(double *x, double *d, mwIndex m, const mwIndex ncols, const mwInd ------------------------------------------------------- */ xkk = x[inz]; if(xkk > lb[k]){ /* now xkk > 0 */ - if((m>1) && (xkk < ub)){ +/* ------------------------------------------------------------ + maxabs is a wrapper for the BLAS IDAMAX Fortran function. + IDAMAX finds the first element having maximum absolute + value in an array. Only call maxabs with m>1. + ------------------------------------------------------------ */ + if ((m>1) && (xkk < ub)){ ubk = maxabs(x+inz+1,m-1) / maxu; if(xkk < ubk){ /* ------------------------------------------------------------ If we need to add on diagonal, store this in (skipIr, lb(k)). ------------------------------------------------------------ */ skipIr[nskip++] = first + k; - lb[k] = ubk - xkk; /* amount added on diagonal */ - xkk = ubk; - } + lb[k] = ubk - xkk; /* amount added on diagonal */ + xkk = ubk; + } } /* -------------------------------------------------------------- Set dk = xkk, lkk = 1 (for LDL'). @@ -170,7 +175,7 @@ void cholonBlk(double *x, double *d, mwIndex m, const mwIndex ncols, const mwInd INCLUDING THE DIAGONAL ENTRY. Lir - Lir[0:nnz-1] ARE THE ROW INDICES OF THE NONZEROS OF THE FIRST COLUMN OF THE SUPERNODE. - OUTPUT PARAMETERS - + OUTPUT PARAMETERS - irInv - On return, irInv[Lir[0:nnz-1]] = nnz:-1:1, so that Lir[nnz-irInv[i]] == i The position of subscript "xij" is thus @@ -314,7 +319,7 @@ void spadd(const mwIndex *xjjc, double *xnz, const mwIndex mj, const mwIndex nj, } } -/* ************************************************************ +/* ************************************************************ PROCEDURE precorrect - Apply corrections from affecting supernode (skipping subnodes with non-positive diagonal) on supernodal diagonal block in L-factor. @@ -520,7 +525,7 @@ mwIndex blkLDL(const mwIndex neqns, const mwIndex nsuper, const mwIndex *xsuper, length[k],xsuper[k],xsuper[k+1], relind,fwsiz,fwork)) == (mwIndex)-1 ) return (mwIndex)-1; /* fwsiz too small */ - } + } /* ------------------------------------------------------------ DO DENSE CHOLESKY on the current supernode ------------------------------------------------------------ */ diff --git a/dpr1fact.c b/dpr1fact.c index 83a5a59..0c92d61 100644 --- a/dpr1fact.c +++ b/dpr1fact.c @@ -365,7 +365,8 @@ char dodpr1fact(double *beta, mwIndex *perm, double *d, double t, const double * ------------------------------------------------------------ */ else{ psqrdep = 0.0; - for(i = 0, j = 0; dep[i] < m; i++) + j = 0; + for(i = 0; dep[i] < m; i++) if(psqr[dep[i]] > psqrdep){ j = i; psqrdep = psqr[dep[i]]; diff --git a/extractA.c b/extractA.c index 23792c6..896448e 100644 --- a/extractA.c +++ b/extractA.c @@ -98,7 +98,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { jcir At, Apart; - mwIndex i, m, njc, ifirst=0, n=0, ynnz, blk0, blk1; + mwIndex i, m, njc, ifirst, n, ynnz, blk0,blk1; mwIndex *Ajc; const double *blkstartPr, *AjcPr; bool isblk0negative; @@ -115,6 +115,8 @@ void mexFunction(int nlhs, mxArray *plhs[], At.ir = mxGetIr(AT_IN); At.pr = mxGetPr(AT_IN); m = mxGetN(AT_IN); + ifirst = 0; + n = 0; if(nrhs >= NPARIN){ n = (mwIndex) mxGetScalar(BLKSTART2_IN); ifirst = (mwIndex) mxGetScalar(BLKSTART_IN); diff --git a/getada3.c b/getada3.c index 289e648..d3f3225 100644 --- a/getada3.c +++ b/getada3.c @@ -373,7 +373,10 @@ void mexFunction(int nlhs, mxArray *plhs[], mxArray *myplhs[NPAROUT]; coneK cK; const mxArray *MY_FIELD; - mwIndex lenfull, lenud, m, i, j, k, fwsiz, iwsiz, dznnz, maxadd; + mwIndex lenud, m, i, j, k, fwsiz, iwsiz, dznnz, maxadd; +#ifdef MEX_DEBUG + mwIndex lenfull; +#endif const double *permPr, *Ajc1Pr, *blkstartPr, *udsqr; const mwIndex *dzstructjc, *dzstructir; double *fwork, *absd; @@ -393,7 +396,9 @@ void mexFunction(int nlhs, mxArray *plhs[], Compute some statistics based on cone K structure ------------------------------------------------------------ */ lenud = cK.rDim + cK.hDim; /* for PSD */ +#ifdef MEX_DEBUG lenfull = cK.lpN + cK.qDim + lenud; +#endif /* ------------------------------------------------------------ Allocate working array blkstart(|K.s|+1). ------------------------------------------------------------ */ diff --git a/givensrot.c b/givensrot.c index b4a2b50..c786c08 100644 --- a/givensrot.c +++ b/givensrot.c @@ -93,7 +93,10 @@ void prpimatgivens(double *y,double *ypi, const tridouble *g, void mexFunction(const int nlhs, mxArray *plhs[], const int nrhs, const mxArray *prhs[]) { - mwIndex inz, i, k, nk, nksqr, lenud, sdplen, gnnz; + mwIndex inz, i, k, nk, nksqr, lenud, sdplen; +#ifdef MEX_DEBUG + mwIndex gnnz; +#endif mwIndex *gjc, *iwork; const double *gjcPr; const double *g, *gk; @@ -118,7 +121,9 @@ void mexFunction(const int nlhs, mxArray *plhs[], ------------------------------------------------------------ */ gjcPr = mxGetPr(GJC_IN); g = (double *) mxGetPr(G_IN); +#ifdef MEX_DEBUG gnnz = mxGetM(G_IN) * mxGetN(G_IN); +#endif mxAssert(mxGetM(X_IN) == lenud && ( lenud == 0 || mxGetN(X_IN) == 1 ), "x size mismatch"); /* ------------------------------------------------------------ Allocate output y(lenud), and let y = x. diff --git a/install_sedumi.m b/install_sedumi.m index 5ba829f..62d5e8f 100644 --- a/install_sedumi.m +++ b/install_sedumi.m @@ -175,10 +175,6 @@ function install_sedumi( varargin ) % whereas calling '-O' would result in gcc '-O1'. flags{end+1} = '-O2'; flags{end+1} = '-DOCTAVE'; - flags{end+1} = '-Werror'; - flags{end+1} = '-Wall'; - flags{end+1} = '-Wno-unused-variable'; - flags{end+1} = '-Wno-unused-but-set-variable'; if (ismac ()) % Assume Homebrew (https://brew.sh/) installation. % https://stackoverflow.com/questions/50634727/dyld-library-not-loaded-usr-local-opt-openblas-lib-libopenblasp-r0-2-20-dylib diff --git a/psdframeit.c b/psdframeit.c index d5a1286..758d118 100644 --- a/psdframeit.c +++ b/psdframeit.c @@ -107,11 +107,15 @@ void psdframeit(double *x, const double *frms, const double *lab, void mexFunction(const int nlhs, mxArray *plhs[], const int nrhs, const mxArray *prhs[]) { - mwIndex i,lendiag, lenfull, lenud,qsize; + mwIndex i,lenud; +#ifdef MEX_DEBUG + mwIndex lendiag, qsize; +#endif double *x, *fwork; const double *lab,*frms; mwIndex *sdpNL; coneK cK; + /* ------------------------------------------------------------ Check for proper number of arguments ------------------------------------------------------------ */ @@ -125,9 +129,10 @@ void mexFunction(const int nlhs, mxArray *plhs[], Get statistics of cone K structure ------------------------------------------------------------ */ lenud = cK.rDim + cK.hDim; +#ifdef MEX_DEBUG qsize = lenud + cK.hLen; - lenfull = cK.lpN + cK.qDim + lenud; lendiag = cK.lpN + 2 * cK.lorN + cK.rLen + cK.hLen; +#endif /* ------------------------------------------------------------ Get inputs lab,frms ------------------------------------------------------------ */ diff --git a/psdinvjmul.c b/psdinvjmul.c index 41a2811..6c120d0 100644 --- a/psdinvjmul.c +++ b/psdinvjmul.c @@ -165,7 +165,10 @@ void psdinvjmul(double *z, const double *frms, const double *x, void mexFunction(const int nlhs, mxArray *plhs[], const int nrhs, const mxArray *prhs[]) { - mwIndex i, lenfull, lendiag, lenud, qsize; + mwIndex i, lenud; +#ifdef MEX_DEBUG + mwIndex lenfull, lendiag, qsize; +#endif double *z, *fwork; const double *x,*y, *frms; mwIndex *sdpNL; @@ -183,9 +186,11 @@ void mexFunction(const int nlhs, mxArray *plhs[], Get statistics of cone K structure ------------------------------------------------------------ */ lenud = cK.rDim + cK.hDim; +#ifdef MEX_DEBUG qsize = lenud + cK.hLen; lenfull = cK.lpN + cK.qDim + lenud; lendiag = cK.lpN + 2 * cK.lorN + cK.rLen + cK.hLen; +#endif /* ------------------------------------------------------------ Get inputs x, frm, y. ------------------------------------------------------------ */ diff --git a/sdmauxCone.c b/sdmauxCone.c index 10e787b..1cd4b14 100644 --- a/sdmauxCone.c +++ b/sdmauxCone.c @@ -49,7 +49,10 @@ void conepars(const mxArray *mxK, coneK *pK) { const mxArray *K_FIELD; const double *blkstartPr; - mwIndex idummy, nblk; + mwIndex idummy; +#ifdef MEX_DEBUG + mwIndex nblk; +#endif char gotthem; mxAssert(mxIsStruct(mxK), "Parameter `K' should be a structure."); @@ -110,7 +113,9 @@ void conepars(const mxArray *mxK, coneK *pK) pK->hMaxn = (mwSize) mxGetScalar(K_FIELD); if( (K_FIELD = mxGetField(mxK,(mwIndex)0,"blkstart"))!=NULL){ /*K.blkstart*/ mxAssert(!mxIsSparse(K_FIELD), "K.blkstart must be a full vector."); +#ifdef MEX_DEBUG nblk = 1 + pK->lorN + pK->sdpN; +#endif mxAssert(mxGetM(K_FIELD) * mxGetN(K_FIELD) == nblk + 1, "Size mismatch K.blkstart."); blkstartPr = mxGetPr(K_FIELD); pK->qDim = (mwSize) blkstartPr[pK->lorN+1] - (mwSize) blkstartPr[0]; diff --git a/sedumi.m b/sedumi.m index 1d66be9..5c75fa9 100644 --- a/sedumi.m +++ b/sedumi.m @@ -264,7 +264,11 @@ if N*m<100000 %Test if Ax=b is feasible at all %turn off the rank deficient warning for now - s = warning('off','MATLAB:singularMatrix'); + if (exist ('OCTAVE_VERSION', 'builtin') == 5) + s = warning('off','Octave:singular-matrix'); + else + s = warning('off','MATLAB:singularMatrix'); + endif y=[A;b']\[zeros(N,1);1]; if abs(y'*b-1) < 1e-10 && norm(A*y) < 1e-10 %Infeasibility certificate found @@ -778,8 +782,6 @@ info.err(1)=norm(x'*(origcoeff.At)-(origcoeff.b)',2)/(1+normb); %Let us get rid of the K.f part, since the free variables don't make %any difference in the cone infeasibility. - %origcoeff.K.f=0; - if origcoeff.K.f Date: Thu, 20 Aug 2020 23:03:48 +1000 Subject: [PATCH 3/5] Revert "Fix unused variable warnings when compiling SeDuMi" This reverts commit 3d0e453313a7377d96a94bf7241d526b2688ce2d. Revert changes as requested by siko1056 --- adendotd.c | 7 +------ adenscale.c | 7 +------ blkchol2.c | 19 +++++++------------ dpr1fact.c | 3 +-- extractA.c | 4 +--- getada3.c | 7 +------ givensrot.c | 7 +------ install_sedumi.m | 4 ++++ psdframeit.c | 9 ++------- psdinvjmul.c | 7 +------ sdmauxCone.c | 7 +------ sedumi.m | 16 +++++++++------- sqrtinv.c | 7 +------ urotorder.c | 2 +- vecsym.c | 4 +++- 15 files changed, 35 insertions(+), 75 deletions(-) diff --git a/adendotd.c b/adendotd.c index eb448e6..3327649 100644 --- a/adendotd.c +++ b/adendotd.c @@ -136,10 +136,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { const mxArray *MY_FIELD; - mwIndex i,j,firstQ, m,nden, nl, nq; -#ifdef MEX_DEBUG - mwIndex lorN; -#endif + mwIndex i,j,firstQ, m,nden, nl, nq, lorN; mwIndex *q, *dencols, *blkend; const double *d1, *d2, *qPr, *dencolsPr, *blkstartPr; double *fwork; @@ -179,9 +176,7 @@ void mexFunction(int nlhs, mxArray *plhs[], mxAssert(mxIsStruct(D_IN), "d should be a structure."); MY_FIELD = mxGetField(D_IN,(mwIndex)0,"q1"); /* d.q1 */ mxAssert( MY_FIELD != NULL, "Missing field d.q1."); -#ifdef MEX_DEBUG lorN = mxGetM(MY_FIELD) * mxGetN(MY_FIELD); -#endif d1 = mxGetPr(MY_FIELD); MY_FIELD = mxGetField(D_IN,(mwIndex)0,"q2"); /* d.q2 */ mxAssert( MY_FIELD != NULL, "Missing field d.q2."); diff --git a/adenscale.c b/adenscale.c index a0692bd..f9ff8f6 100644 --- a/adenscale.c +++ b/adenscale.c @@ -88,10 +88,7 @@ void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { const mxArray *MY_FIELD; - mwIndex i, j, nden, nl, nq; -#ifdef MEX_DEBUG - mwIndex lorN; -#endif + mwIndex i, j, nden, nl, nq, lorN; mwIndex *q, *dencols, *blkend; const double *qPr, *dencolsPr, *detd, *blkstartPr; /* ------------------------------------------------------------ @@ -122,9 +119,7 @@ void mexFunction( int nlhs, mxArray *plhs[], MY_FIELD = mxGetField(D_IN,(mwIndex)0,"det"); /* d.det */ mxAssert( MY_FIELD != NULL, "Missing field d.det."); detd = mxGetPr(MY_FIELD); -#ifdef MEX_DEBUG lorN = (mwIndex) (mxGetM(MY_FIELD) * mxGetN(MY_FIELD)); -#endif /* ------------------------------------------------------------ Get INPUTS blkstart ------------------------------------------------------------ */ diff --git a/blkchol2.c b/blkchol2.c index c1822c5..2d91642 100644 --- a/blkchol2.c +++ b/blkchol2.c @@ -113,21 +113,16 @@ void cholonBlk(double *x, double *d, mwIndex m, const mwIndex ncols, const mwInd ------------------------------------------------------- */ xkk = x[inz]; if(xkk > lb[k]){ /* now xkk > 0 */ -/* ------------------------------------------------------------ - maxabs is a wrapper for the BLAS IDAMAX Fortran function. - IDAMAX finds the first element having maximum absolute - value in an array. Only call maxabs with m>1. - ------------------------------------------------------------ */ - if ((m>1) && (xkk < ub)){ + if((m>1) && (xkk < ub)){ ubk = maxabs(x+inz+1,m-1) / maxu; if(xkk < ubk){ /* ------------------------------------------------------------ If we need to add on diagonal, store this in (skipIr, lb(k)). ------------------------------------------------------------ */ skipIr[nskip++] = first + k; - lb[k] = ubk - xkk; /* amount added on diagonal */ - xkk = ubk; - } + lb[k] = ubk - xkk; /* amount added on diagonal */ + xkk = ubk; + } } /* -------------------------------------------------------------- Set dk = xkk, lkk = 1 (for LDL'). @@ -175,7 +170,7 @@ void cholonBlk(double *x, double *d, mwIndex m, const mwIndex ncols, const mwInd INCLUDING THE DIAGONAL ENTRY. Lir - Lir[0:nnz-1] ARE THE ROW INDICES OF THE NONZEROS OF THE FIRST COLUMN OF THE SUPERNODE. - OUTPUT PARAMETERS - + OUTPUT PARAMETERS - irInv - On return, irInv[Lir[0:nnz-1]] = nnz:-1:1, so that Lir[nnz-irInv[i]] == i The position of subscript "xij" is thus @@ -319,7 +314,7 @@ void spadd(const mwIndex *xjjc, double *xnz, const mwIndex mj, const mwIndex nj, } } -/* ************************************************************ +/* ************************************************************ PROCEDURE precorrect - Apply corrections from affecting supernode (skipping subnodes with non-positive diagonal) on supernodal diagonal block in L-factor. @@ -525,7 +520,7 @@ mwIndex blkLDL(const mwIndex neqns, const mwIndex nsuper, const mwIndex *xsuper, length[k],xsuper[k],xsuper[k+1], relind,fwsiz,fwork)) == (mwIndex)-1 ) return (mwIndex)-1; /* fwsiz too small */ - } + } /* ------------------------------------------------------------ DO DENSE CHOLESKY on the current supernode ------------------------------------------------------------ */ diff --git a/dpr1fact.c b/dpr1fact.c index 0c92d61..83a5a59 100644 --- a/dpr1fact.c +++ b/dpr1fact.c @@ -365,8 +365,7 @@ char dodpr1fact(double *beta, mwIndex *perm, double *d, double t, const double * ------------------------------------------------------------ */ else{ psqrdep = 0.0; - j = 0; - for(i = 0; dep[i] < m; i++) + for(i = 0, j = 0; dep[i] < m; i++) if(psqr[dep[i]] > psqrdep){ j = i; psqrdep = psqr[dep[i]]; diff --git a/extractA.c b/extractA.c index 896448e..23792c6 100644 --- a/extractA.c +++ b/extractA.c @@ -98,7 +98,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { jcir At, Apart; - mwIndex i, m, njc, ifirst, n, ynnz, blk0,blk1; + mwIndex i, m, njc, ifirst=0, n=0, ynnz, blk0, blk1; mwIndex *Ajc; const double *blkstartPr, *AjcPr; bool isblk0negative; @@ -115,8 +115,6 @@ void mexFunction(int nlhs, mxArray *plhs[], At.ir = mxGetIr(AT_IN); At.pr = mxGetPr(AT_IN); m = mxGetN(AT_IN); - ifirst = 0; - n = 0; if(nrhs >= NPARIN){ n = (mwIndex) mxGetScalar(BLKSTART2_IN); ifirst = (mwIndex) mxGetScalar(BLKSTART_IN); diff --git a/getada3.c b/getada3.c index d3f3225..289e648 100644 --- a/getada3.c +++ b/getada3.c @@ -373,10 +373,7 @@ void mexFunction(int nlhs, mxArray *plhs[], mxArray *myplhs[NPAROUT]; coneK cK; const mxArray *MY_FIELD; - mwIndex lenud, m, i, j, k, fwsiz, iwsiz, dznnz, maxadd; -#ifdef MEX_DEBUG - mwIndex lenfull; -#endif + mwIndex lenfull, lenud, m, i, j, k, fwsiz, iwsiz, dznnz, maxadd; const double *permPr, *Ajc1Pr, *blkstartPr, *udsqr; const mwIndex *dzstructjc, *dzstructir; double *fwork, *absd; @@ -396,9 +393,7 @@ void mexFunction(int nlhs, mxArray *plhs[], Compute some statistics based on cone K structure ------------------------------------------------------------ */ lenud = cK.rDim + cK.hDim; /* for PSD */ -#ifdef MEX_DEBUG lenfull = cK.lpN + cK.qDim + lenud; -#endif /* ------------------------------------------------------------ Allocate working array blkstart(|K.s|+1). ------------------------------------------------------------ */ diff --git a/givensrot.c b/givensrot.c index c786c08..b4a2b50 100644 --- a/givensrot.c +++ b/givensrot.c @@ -93,10 +93,7 @@ void prpimatgivens(double *y,double *ypi, const tridouble *g, void mexFunction(const int nlhs, mxArray *plhs[], const int nrhs, const mxArray *prhs[]) { - mwIndex inz, i, k, nk, nksqr, lenud, sdplen; -#ifdef MEX_DEBUG - mwIndex gnnz; -#endif + mwIndex inz, i, k, nk, nksqr, lenud, sdplen, gnnz; mwIndex *gjc, *iwork; const double *gjcPr; const double *g, *gk; @@ -121,9 +118,7 @@ void mexFunction(const int nlhs, mxArray *plhs[], ------------------------------------------------------------ */ gjcPr = mxGetPr(GJC_IN); g = (double *) mxGetPr(G_IN); -#ifdef MEX_DEBUG gnnz = mxGetM(G_IN) * mxGetN(G_IN); -#endif mxAssert(mxGetM(X_IN) == lenud && ( lenud == 0 || mxGetN(X_IN) == 1 ), "x size mismatch"); /* ------------------------------------------------------------ Allocate output y(lenud), and let y = x. diff --git a/install_sedumi.m b/install_sedumi.m index 62d5e8f..5ba829f 100644 --- a/install_sedumi.m +++ b/install_sedumi.m @@ -175,6 +175,10 @@ function install_sedumi( varargin ) % whereas calling '-O' would result in gcc '-O1'. flags{end+1} = '-O2'; flags{end+1} = '-DOCTAVE'; + flags{end+1} = '-Werror'; + flags{end+1} = '-Wall'; + flags{end+1} = '-Wno-unused-variable'; + flags{end+1} = '-Wno-unused-but-set-variable'; if (ismac ()) % Assume Homebrew (https://brew.sh/) installation. % https://stackoverflow.com/questions/50634727/dyld-library-not-loaded-usr-local-opt-openblas-lib-libopenblasp-r0-2-20-dylib diff --git a/psdframeit.c b/psdframeit.c index 758d118..d5a1286 100644 --- a/psdframeit.c +++ b/psdframeit.c @@ -107,15 +107,11 @@ void psdframeit(double *x, const double *frms, const double *lab, void mexFunction(const int nlhs, mxArray *plhs[], const int nrhs, const mxArray *prhs[]) { - mwIndex i,lenud; -#ifdef MEX_DEBUG - mwIndex lendiag, qsize; -#endif + mwIndex i,lendiag, lenfull, lenud,qsize; double *x, *fwork; const double *lab,*frms; mwIndex *sdpNL; coneK cK; - /* ------------------------------------------------------------ Check for proper number of arguments ------------------------------------------------------------ */ @@ -129,10 +125,9 @@ void mexFunction(const int nlhs, mxArray *plhs[], Get statistics of cone K structure ------------------------------------------------------------ */ lenud = cK.rDim + cK.hDim; -#ifdef MEX_DEBUG qsize = lenud + cK.hLen; + lenfull = cK.lpN + cK.qDim + lenud; lendiag = cK.lpN + 2 * cK.lorN + cK.rLen + cK.hLen; -#endif /* ------------------------------------------------------------ Get inputs lab,frms ------------------------------------------------------------ */ diff --git a/psdinvjmul.c b/psdinvjmul.c index 6c120d0..41a2811 100644 --- a/psdinvjmul.c +++ b/psdinvjmul.c @@ -165,10 +165,7 @@ void psdinvjmul(double *z, const double *frms, const double *x, void mexFunction(const int nlhs, mxArray *plhs[], const int nrhs, const mxArray *prhs[]) { - mwIndex i, lenud; -#ifdef MEX_DEBUG - mwIndex lenfull, lendiag, qsize; -#endif + mwIndex i, lenfull, lendiag, lenud, qsize; double *z, *fwork; const double *x,*y, *frms; mwIndex *sdpNL; @@ -186,11 +183,9 @@ void mexFunction(const int nlhs, mxArray *plhs[], Get statistics of cone K structure ------------------------------------------------------------ */ lenud = cK.rDim + cK.hDim; -#ifdef MEX_DEBUG qsize = lenud + cK.hLen; lenfull = cK.lpN + cK.qDim + lenud; lendiag = cK.lpN + 2 * cK.lorN + cK.rLen + cK.hLen; -#endif /* ------------------------------------------------------------ Get inputs x, frm, y. ------------------------------------------------------------ */ diff --git a/sdmauxCone.c b/sdmauxCone.c index 1cd4b14..10e787b 100644 --- a/sdmauxCone.c +++ b/sdmauxCone.c @@ -49,10 +49,7 @@ void conepars(const mxArray *mxK, coneK *pK) { const mxArray *K_FIELD; const double *blkstartPr; - mwIndex idummy; -#ifdef MEX_DEBUG - mwIndex nblk; -#endif + mwIndex idummy, nblk; char gotthem; mxAssert(mxIsStruct(mxK), "Parameter `K' should be a structure."); @@ -113,9 +110,7 @@ void conepars(const mxArray *mxK, coneK *pK) pK->hMaxn = (mwSize) mxGetScalar(K_FIELD); if( (K_FIELD = mxGetField(mxK,(mwIndex)0,"blkstart"))!=NULL){ /*K.blkstart*/ mxAssert(!mxIsSparse(K_FIELD), "K.blkstart must be a full vector."); -#ifdef MEX_DEBUG nblk = 1 + pK->lorN + pK->sdpN; -#endif mxAssert(mxGetM(K_FIELD) * mxGetN(K_FIELD) == nblk + 1, "Size mismatch K.blkstart."); blkstartPr = mxGetPr(K_FIELD); pK->qDim = (mwSize) blkstartPr[pK->lorN+1] - (mwSize) blkstartPr[0]; diff --git a/sedumi.m b/sedumi.m index 5c75fa9..1d66be9 100644 --- a/sedumi.m +++ b/sedumi.m @@ -264,11 +264,7 @@ if N*m<100000 %Test if Ax=b is feasible at all %turn off the rank deficient warning for now - if (exist ('OCTAVE_VERSION', 'builtin') == 5) - s = warning('off','Octave:singular-matrix'); - else - s = warning('off','MATLAB:singularMatrix'); - endif + s = warning('off','MATLAB:singularMatrix'); y=[A;b']\[zeros(N,1);1]; if abs(y'*b-1) < 1e-10 && norm(A*y) < 1e-10 %Infeasibility certificate found @@ -782,6 +778,8 @@ info.err(1)=norm(x'*(origcoeff.At)-(origcoeff.b)',2)/(1+normb); %Let us get rid of the K.f part, since the free variables don't make %any difference in the cone infeasibility. + %origcoeff.K.f=0; + if origcoeff.K.f Date: Fri, 21 Aug 2020 00:22:14 +1000 Subject: [PATCH 4/5] Fix a valgrind error and suppress compiler warnings --- Contents.m | 3 +- examples/README.md | 12 +++++--- examples/test_sedumi.m | 62 ++++++++++++++++++++++++++---------------- 3 files changed, 49 insertions(+), 28 deletions(-) diff --git a/Contents.m b/Contents.m index deda01f..50b2f32 100644 --- a/Contents.m +++ b/Contents.m @@ -43,4 +43,5 @@ % eyeK - Identity with respect to symmetric cones % cellK - Transforms x-solution into a cell array % -% See also conversion. \ No newline at end of file +% See also conversion. + diff --git a/examples/README.md b/examples/README.md index abd62e8..1e17b6d 100644 --- a/examples/README.md +++ b/examples/README.md @@ -11,7 +11,7 @@ http://plato.asu.edu/sub/testcases.html. > Applied Mechanics and Engineering 94(1992):113-129. > DOI: [10.1016/0045-7825(92)90159-H](https://doi.org/10.1016/0045-7825(92)90159-H). - Optimal value is `5.66517e-01`. + Optimal value is `-5.66517e-01`. - **control07.mat**: Again from SDPLIB, a problem from control and system theory @@ -22,7 +22,7 @@ http://plato.asu.edu/sub/testcases.html. > Department of Mathematical and Computing Sciences, Tokyo Institute of > Technology, September, 1997. - Optimal value is `2.06251e+01`. + Optimal value is `-2.06251e+01`. - **nb.mat**: This problem is by Robert Vanderbei, it was used at the @@ -39,8 +39,12 @@ http://plato.asu.edu/sub/testcases.html. > "The reduced density matrix method for electronic structure calculations > and the role of three-index representability", October, 2003. > DOI: [10.1063/1.1636721](https://doi.org/10.1063/1.1636721). - - at http://mf.c.titech.ac.jp/mituhiro/software.html. + + and http://mf.c.titech.ac.jp/mituhiro/software.html. The reported energy is + `-75.1014` substracted by the repulsion energy `4.3656986614` and negated + due to the problem formulation. + + Optimal value is `7.946708e+01`. - **trto3.mat**: A problem by Kocvara, from single-load truss topology design. diff --git a/examples/test_sedumi.m b/examples/test_sedumi.m index 9b82b13..6226ae6 100644 --- a/examples/test_sedumi.m +++ b/examples/test_sedumi.m @@ -1,49 +1,64 @@ function test_sedumi (do_rebuild, do_exit) % TEST_SEDUMI Verify minimal functionality of SeDuMi using an example SDP. - -if (nargin < 2) - do_rebuild = false; - do_exit = false; -end +% +% Input: +% do_rebuild - Rebuild SeDuMi +% do_exit - Exit Matlab/GNU Octave on failure (suiteable for continuous +% integration CI). try old_dir = cd ('..'); - if (do_rebuild) + if ((nargin == 1) && do_rebuild) install_sedumi -rebuild else install_sedumi end cd (old_dir) - + example_path = mfilename ('fullpath'); example_path = example_path(1:max ([1, strfind(example_path, filesep ())]) - 1); - - test_problems = {'arch0.mat', 'control07.mat', 'nb.mat', ... - 'OH_2Pi_STO-6GN9r12g1T2.mat', 'trto3.mat'}; - - for i = 1:length (test_problems) + + % Name and optimal function value + test_problems = { ... + 'arch0.mat', -5.665170e-01; ... + 'control07.mat', -2.062510e+01; ... + 'nb.mat', -5.070309e-02; ... + 'OH_2Pi_STO-6GN9r12g1T2.mat', 7.946708e+01; ... + 'trto3.mat', -1.279999e+04}; + + tol = 1e-6; + + for i = 1:size (test_problems, 1) line_sep = repmat ('-', 1, 75); fprintf ('\n%s\n-- Test ''%s'' (%2d/%2d)\n%s\n\n', line_sep, ... - test_problems{i}, i, length (test_problems), line_sep); - - load (fullfile (example_path, test_problems{i}), 'At', 'b', 'c', 'K'); - [~,~,info] = sedumi (At, b, c, K); - if (info.pinf ~= 0 || info.dinf ~= 0 || info.numerr == 2) - fprintf ('\n\nSeDuMi TEST FAILED: Could not solve ''%s'' example.\n', ... - test_problems{i}); - if (do_exit) + test_problems{i,1}, i, size (test_problems, 1), line_sep); + + load (fullfile (example_path, test_problems{i,1}), 'At', 'b', 'c', 'K'); + [x, y, info] = sedumi (At, b, c, K); + cx = c' * x; + by = b' * y; + cx_relerr = abs (cx - test_problems{i,2}) / abs (test_problems{i,2}); + by_relerr = abs (by - test_problems{i,2}) / abs (test_problems{i,2}); + if ((cx_relerr >= tol) || (by_relerr >= tol) ... + || (info.pinf ~= 0) || (info.dinf ~= 0) || (info.numerr == 2)) + fprintf ('\n\tTEST FAILED\n'); + fprintf ('\n\t\tExpected = %e ( tol = %.1e)', test_problems{i,2}, tol); + fprintf ('\n\t\t c*x = %e (relerr = %.1e)', cx, cx_relerr); + fprintf ('\n\t\t b*y = %e (relerr = %.1e)\n', by, by_relerr); + if ((nargin == 2) && do_exit) exit (1); else return; end end if (info.numerr == 1) - warning ('SeDuMi reported reduced accuracy.') + fprintf ('\n\tWARNING: SeDuMi reported reduced accuracy.\n'); end + fprintf ('\n\tTEST PASSED\n'); end catch - disp ('SeDuMi TEST FAILED: Compilation or runtime error.'); - if (do_exit) + fprintf ('\n\tTEST FAILED: Compilation or runtime error.\n'); + if ((nargin == 2) && do_exit) exit (1); else return; @@ -51,3 +66,4 @@ function test_sedumi (do_rebuild, do_exit) end end + From 97a96be894f5dc744e91413290cd4aa10007a2c5 Mon Sep 17 00:00:00 2001 From: Robert Jenssen Date: Fri, 21 Aug 2020 00:22:54 +1000 Subject: [PATCH 5/5] Fix a valgrind error and suppress compiler warnings --- blkchol2.c | 19 ++++++++++++------- dpr1fact.c | 3 ++- install_sedumi.m | 4 ---- maxstep.m | 4 ++-- psdframeit.c | 5 ++--- sedumi.m | 16 +++++++--------- sqrtinv.c | 2 +- symfctmex.c | 1 - trydif.m | 4 ++-- urotorder.c | 2 +- vecsym.c | 4 +--- widelen.m | 4 ++-- 12 files changed, 32 insertions(+), 36 deletions(-) diff --git a/blkchol2.c b/blkchol2.c index 2d91642..c1822c5 100644 --- a/blkchol2.c +++ b/blkchol2.c @@ -113,16 +113,21 @@ void cholonBlk(double *x, double *d, mwIndex m, const mwIndex ncols, const mwInd ------------------------------------------------------- */ xkk = x[inz]; if(xkk > lb[k]){ /* now xkk > 0 */ - if((m>1) && (xkk < ub)){ +/* ------------------------------------------------------------ + maxabs is a wrapper for the BLAS IDAMAX Fortran function. + IDAMAX finds the first element having maximum absolute + value in an array. Only call maxabs with m>1. + ------------------------------------------------------------ */ + if ((m>1) && (xkk < ub)){ ubk = maxabs(x+inz+1,m-1) / maxu; if(xkk < ubk){ /* ------------------------------------------------------------ If we need to add on diagonal, store this in (skipIr, lb(k)). ------------------------------------------------------------ */ skipIr[nskip++] = first + k; - lb[k] = ubk - xkk; /* amount added on diagonal */ - xkk = ubk; - } + lb[k] = ubk - xkk; /* amount added on diagonal */ + xkk = ubk; + } } /* -------------------------------------------------------------- Set dk = xkk, lkk = 1 (for LDL'). @@ -170,7 +175,7 @@ void cholonBlk(double *x, double *d, mwIndex m, const mwIndex ncols, const mwInd INCLUDING THE DIAGONAL ENTRY. Lir - Lir[0:nnz-1] ARE THE ROW INDICES OF THE NONZEROS OF THE FIRST COLUMN OF THE SUPERNODE. - OUTPUT PARAMETERS - + OUTPUT PARAMETERS - irInv - On return, irInv[Lir[0:nnz-1]] = nnz:-1:1, so that Lir[nnz-irInv[i]] == i The position of subscript "xij" is thus @@ -314,7 +319,7 @@ void spadd(const mwIndex *xjjc, double *xnz, const mwIndex mj, const mwIndex nj, } } -/* ************************************************************ +/* ************************************************************ PROCEDURE precorrect - Apply corrections from affecting supernode (skipping subnodes with non-positive diagonal) on supernodal diagonal block in L-factor. @@ -520,7 +525,7 @@ mwIndex blkLDL(const mwIndex neqns, const mwIndex nsuper, const mwIndex *xsuper, length[k],xsuper[k],xsuper[k+1], relind,fwsiz,fwork)) == (mwIndex)-1 ) return (mwIndex)-1; /* fwsiz too small */ - } + } /* ------------------------------------------------------------ DO DENSE CHOLESKY on the current supernode ------------------------------------------------------------ */ diff --git a/dpr1fact.c b/dpr1fact.c index 83a5a59..0c92d61 100644 --- a/dpr1fact.c +++ b/dpr1fact.c @@ -365,7 +365,8 @@ char dodpr1fact(double *beta, mwIndex *perm, double *d, double t, const double * ------------------------------------------------------------ */ else{ psqrdep = 0.0; - for(i = 0, j = 0; dep[i] < m; i++) + j = 0; + for(i = 0; dep[i] < m; i++) if(psqr[dep[i]] > psqrdep){ j = i; psqrdep = psqr[dep[i]]; diff --git a/install_sedumi.m b/install_sedumi.m index 5ba829f..62d5e8f 100644 --- a/install_sedumi.m +++ b/install_sedumi.m @@ -175,10 +175,6 @@ function install_sedumi( varargin ) % whereas calling '-O' would result in gcc '-O1'. flags{end+1} = '-O2'; flags{end+1} = '-DOCTAVE'; - flags{end+1} = '-Werror'; - flags{end+1} = '-Wall'; - flags{end+1} = '-Wno-unused-variable'; - flags{end+1} = '-Wno-unused-but-set-variable'; if (ismac ()) % Assume Homebrew (https://brew.sh/) installation. % https://stackoverflow.com/questions/50634727/dyld-library-not-loaded-usr-local-opt-openblas-lib-libopenblasp-r0-2-20-dylib diff --git a/maxstep.m b/maxstep.m index fbb4663..e4ffe83 100644 --- a/maxstep.m +++ b/maxstep.m @@ -50,7 +50,7 @@ reltr = x(ix(1):ix(2)-1).*dx(ix(1):ix(2)-1)... - ddot(x(ix(2):ix(3)-1),dx,K.qblkstart); norm2 = reltr.^2 - tdet(dx,K).*auxx.tdet; - if norm2 > 0 + if all(norm2 > 0) norm2 = sqrt(norm2); end mindxq = min( (reltr - norm2)./auxx.tdet); @@ -64,4 +64,4 @@ mindxs = minpsdeig(reldx, K); mindx = min(mindx, mindxs); end -tp = 1 / max(-mindx, 1E-16); \ No newline at end of file +tp = 1 / max(-mindx, 1E-16); diff --git a/psdframeit.c b/psdframeit.c index d5a1286..f9cc2ae 100644 --- a/psdframeit.c +++ b/psdframeit.c @@ -107,9 +107,9 @@ void psdframeit(double *x, const double *frms, const double *lab, void mexFunction(const int nlhs, mxArray *plhs[], const int nrhs, const mxArray *prhs[]) { - mwIndex i,lendiag, lenfull, lenud,qsize; + mwIndex i, lendiag, lenud, qsize; double *x, *fwork; - const double *lab,*frms; + const double *lab, *frms; mwIndex *sdpNL; coneK cK; /* ------------------------------------------------------------ @@ -126,7 +126,6 @@ void mexFunction(const int nlhs, mxArray *plhs[], ------------------------------------------------------------ */ lenud = cK.rDim + cK.hDim; qsize = lenud + cK.hLen; - lenfull = cK.lpN + cK.qDim + lenud; lendiag = cK.lpN + 2 * cK.lorN + cK.rLen + cK.hLen; /* ------------------------------------------------------------ Get inputs lab,frms diff --git a/sedumi.m b/sedumi.m index 1d66be9..5c75fa9 100644 --- a/sedumi.m +++ b/sedumi.m @@ -264,7 +264,11 @@ if N*m<100000 %Test if Ax=b is feasible at all %turn off the rank deficient warning for now - s = warning('off','MATLAB:singularMatrix'); + if (exist ('OCTAVE_VERSION', 'builtin') == 5) + s = warning('off','Octave:singular-matrix'); + else + s = warning('off','MATLAB:singularMatrix'); + endif y=[A;b']\[zeros(N,1);1]; if abs(y'*b-1) < 1e-10 && norm(A*y) < 1e-10 %Infeasibility certificate found @@ -778,8 +782,6 @@ info.err(1)=norm(x'*(origcoeff.At)-(origcoeff.b)',2)/(1+normb); %Let us get rid of the K.f part, since the free variables don't make %any difference in the cone infeasibility. - %origcoeff.K.f=0; - if origcoeff.K.f 0 + if all(tmp > 0) lab2q = halfxz + sqrt(tmp); else lab2q = halfxz; @@ -69,4 +69,4 @@ t = 0; w = wIN; wr = wrIN; -end \ No newline at end of file +end diff --git a/urotorder.c b/urotorder.c index 0937d5c..86b5b74 100644 --- a/urotorder.c +++ b/urotorder.c @@ -313,7 +313,7 @@ void mexFunction(const int nlhs, mxArray *plhs[], const int nrhs, const mxArray *prhs[]) { mxArray *myplhs[NPAROUT]; - mwIndex i,j,k, nk, nksqr, lenud, sdplen, gnnz, inz, maxKs,maxKssqr, rgnnz, hgnnz; + mwIndex i, k, nk, nksqr, lenud, sdplen, gnnz, inz, maxKs, maxKssqr, rgnnz, hgnnz; const double *uOld, *permOld=NULL; double *u, *d, *gjcPr, *permPr, *fwork, *fworkpi; mwIndex *perm, *gjc; diff --git a/vecsym.c b/vecsym.c index 3f116d1..991aba9 100644 --- a/vecsym.c +++ b/vecsym.c @@ -139,10 +139,8 @@ void vecsymPSD(double *y, const double *x,const mwIndex rsdpN,const mwIndex sdpN void mexFunction(const int nlhs, mxArray *plhs[], const int nrhs, const mxArray *prhs[]) { - mxArray *output_array[1], *Xk; - coneK cK; - mwIndex k, nk, nksqr, lqDim,lenfull; + mwIndex lqDim, lenfull; const double *x; double *y; diff --git a/widelen.m b/widelen.m index 2dacf29..0d49bf2 100644 --- a/widelen.m +++ b/widelen.m @@ -91,7 +91,7 @@ halfxz = (xM(ix(1):ix(2)-1).*zM(ix(1):ix(2)-1)... + ddot(xM(ix(2):ix(3)-1),zM,K.qblkstart)) / 2; tmp = halfxz.^2 - detxz; - if tmp > 0 + if all(tmp > 0) lab2q = halfxz + sqrt(tmp); else lab2q = halfxz; @@ -124,4 +124,4 @@ wr.alpha=alphaM; wr.delta=deltaM; end -wr.desc = 1; % always descent direction. \ No newline at end of file +wr.desc = 1; % always descent direction.