Skip to content

Commit 97a96be

Browse files
committedAug 20, 2020
Fix a valgrind error and suppress compiler warnings
1 parent c5ef9ca commit 97a96be

12 files changed

+32
-36
lines changed
 

‎blkchol2.c

+12-7
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,21 @@ void cholonBlk(double *x, double *d, mwIndex m, const mwIndex ncols, const mwInd
113113
------------------------------------------------------- */
114114
xkk = x[inz];
115115
if(xkk > lb[k]){ /* now xkk > 0 */
116-
if((m>1) && (xkk < ub)){
116+
/* ------------------------------------------------------------
117+
maxabs is a wrapper for the BLAS IDAMAX Fortran function.
118+
IDAMAX finds the first element having maximum absolute
119+
value in an array. Only call maxabs with m>1.
120+
------------------------------------------------------------ */
121+
if ((m>1) && (xkk < ub)){
117122
ubk = maxabs(x+inz+1,m-1) / maxu;
118123
if(xkk < ubk){
119124
/* ------------------------------------------------------------
120125
If we need to add on diagonal, store this in (skipIr, lb(k)).
121126
------------------------------------------------------------ */
122127
skipIr[nskip++] = first + k;
123-
lb[k] = ubk - xkk; /* amount added on diagonal */
124-
xkk = ubk;
125-
}
128+
lb[k] = ubk - xkk; /* amount added on diagonal */
129+
xkk = ubk;
130+
}
126131
}
127132
/* --------------------------------------------------------------
128133
Set dk = xkk, lkk = 1 (for LDL').
@@ -170,7 +175,7 @@ void cholonBlk(double *x, double *d, mwIndex m, const mwIndex ncols, const mwInd
170175
INCLUDING THE DIAGONAL ENTRY.
171176
Lir - Lir[0:nnz-1] ARE THE ROW INDICES OF THE NONZEROS
172177
OF THE FIRST COLUMN OF THE SUPERNODE.
173-
OUTPUT PARAMETERS -
178+
OUTPUT PARAMETERS -
174179
irInv - On return, irInv[Lir[0:nnz-1]] = nnz:-1:1, so that
175180
Lir[nnz-irInv[i]] == i
176181
The position of subscript "xij" is thus
@@ -314,7 +319,7 @@ void spadd(const mwIndex *xjjc, double *xnz, const mwIndex mj, const mwIndex nj,
314319
}
315320
}
316321

317-
/* ************************************************************
322+
/* ************************************************************
318323
PROCEDURE precorrect - Apply corrections from affecting supernode
319324
(skipping subnodes with non-positive diagonal) on supernodal
320325
diagonal block in L-factor.
@@ -520,7 +525,7 @@ mwIndex blkLDL(const mwIndex neqns, const mwIndex nsuper, const mwIndex *xsuper,
520525
length[k],xsuper[k],xsuper[k+1],
521526
relind,fwsiz,fwork)) == (mwIndex)-1 )
522527
return (mwIndex)-1; /* fwsiz too small */
523-
}
528+
}
524529
/* ------------------------------------------------------------
525530
DO DENSE CHOLESKY on the current supernode
526531
------------------------------------------------------------ */

‎dpr1fact.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ char dodpr1fact(double *beta, mwIndex *perm, double *d, double t, const double *
365365
------------------------------------------------------------ */
366366
else{
367367
psqrdep = 0.0;
368-
for(i = 0, j = 0; dep[i] < m; i++)
368+
j = 0;
369+
for(i = 0; dep[i] < m; i++)
369370
if(psqr[dep[i]] > psqrdep){
370371
j = i;
371372
psqrdep = psqr[dep[i]];

‎install_sedumi.m

-4
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,6 @@ function install_sedumi( varargin )
175175
% whereas calling '-O' would result in gcc '-O1'.
176176
flags{end+1} = '-O2';
177177
flags{end+1} = '-DOCTAVE';
178-
flags{end+1} = '-Werror';
179-
flags{end+1} = '-Wall';
180-
flags{end+1} = '-Wno-unused-variable';
181-
flags{end+1} = '-Wno-unused-but-set-variable';
182178
if (ismac ())
183179
% Assume Homebrew (https://brew.sh/) installation.
184180
% https://stackoverflow.com/questions/50634727/dyld-library-not-loaded-usr-local-opt-openblas-lib-libopenblasp-r0-2-20-dylib

‎maxstep.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
reltr = x(ix(1):ix(2)-1).*dx(ix(1):ix(2)-1)...
5151
- ddot(x(ix(2):ix(3)-1),dx,K.qblkstart);
5252
norm2 = reltr.^2 - tdet(dx,K).*auxx.tdet;
53-
if norm2 > 0
53+
if all(norm2 > 0)
5454
norm2 = sqrt(norm2);
5555
end
5656
mindxq = min( (reltr - norm2)./auxx.tdet);
@@ -64,4 +64,4 @@
6464
mindxs = minpsdeig(reldx, K);
6565
mindx = min(mindx, mindxs);
6666
end
67-
tp = 1 / max(-mindx, 1E-16);
67+
tp = 1 / max(-mindx, 1E-16);

‎psdframeit.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ void psdframeit(double *x, const double *frms, const double *lab,
107107
void mexFunction(const int nlhs, mxArray *plhs[],
108108
const int nrhs, const mxArray *prhs[])
109109
{
110-
mwIndex i,lendiag, lenfull, lenud,qsize;
110+
mwIndex i, lendiag, lenud, qsize;
111111
double *x, *fwork;
112-
const double *lab,*frms;
112+
const double *lab, *frms;
113113
mwIndex *sdpNL;
114114
coneK cK;
115115
/* ------------------------------------------------------------
@@ -126,7 +126,6 @@ void mexFunction(const int nlhs, mxArray *plhs[],
126126
------------------------------------------------------------ */
127127
lenud = cK.rDim + cK.hDim;
128128
qsize = lenud + cK.hLen;
129-
lenfull = cK.lpN + cK.qDim + lenud;
130129
lendiag = cK.lpN + 2 * cK.lorN + cK.rLen + cK.hLen;
131130
/* ------------------------------------------------------------
132131
Get inputs lab,frms

‎sedumi.m

+7-9
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,11 @@
264264
if N*m<100000
265265
%Test if Ax=b is feasible at all
266266
%turn off the rank deficient warning for now
267-
s = warning('off','MATLAB:singularMatrix');
267+
if (exist ('OCTAVE_VERSION', 'builtin') == 5)
268+
s = warning('off','Octave:singular-matrix');
269+
else
270+
s = warning('off','MATLAB:singularMatrix');
271+
endif
268272
y=[A;b']\[zeros(N,1);1];
269273
if abs(y'*b-1) < 1e-10 && norm(A*y) < 1e-10
270274
%Infeasibility certificate found
@@ -778,8 +782,6 @@
778782
info.err(1)=norm(x'*(origcoeff.At)-(origcoeff.b)',2)/(1+normb);
779783
%Let us get rid of the K.f part, since the free variables don't make
780784
%any difference in the cone infeasibility.
781-
%origcoeff.K.f=0;
782-
783785
if origcoeff.K.f<length(origcoeff.c)
784786
%not all primal variables are free
785787
% Primal cone infeasibility
@@ -788,14 +790,10 @@
788790
info.err(2)=max(0,-min(eigK(full(x(origcoeff.K.f+1:end)),tempK)/(1+normb)));
789791
% Dual cone infeasibility
790792
info.err(4)=max(0,-min(eigK(full(s(origcoeff.K.f+1:end)),tempK)/(1+normc)));
791-
792-
else
793-
info.err(2)=0;
794-
info.err(4)=0;
795793
end
796794
% Dual infeasibility
797-
info.err(3)=0.0; %s is not maintained explicitely
798-
% Relative duality gap
795+
info.err(3)=0.0; % not maintained explicitly
796+
% Relative duality gap
799797
info.err(5)=(cx-by)/(1+abs(cx)+abs(by));
800798
% Relative complementarity
801799
info.err(6)=xs/(1+abs(cx)+abs(by));

‎sqrtinv.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void prpiqdivv(double *y,double *ypi, const double *q,const double *qpi,
9595
void mexFunction(const int nlhs, mxArray *plhs[],
9696
const int nrhs, const mxArray *prhs[])
9797
{
98-
mwIndex i,k, nk, nksqr, lenud, lendiag, diagskip;
98+
mwIndex k, nk, nksqr, lenud, lendiag, diagskip;
9999
double *y;
100100
const double *q,*v;
101101
coneK cK;

‎symfctmex.c

-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ void mexFunction(const int nlhs, mxArray *plhs[],
136136
*invp, *colcnt;
137137
mxArray *L_FIELD;
138138
const char *LFieldnames[] = {"L", "perm", "xsuper"};
139-
mwIndex *mwXjc, *mwXir, *mwLjc, *mwLir;
140139
/* ------------------------------------------------------------
141140
Check for proper number of arguments
142141
------------------------------------------------------------ */

‎trydif.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
halfxz = (x(ix(1):ix(2)-1).*z(ix(1):ix(2)-1)...
5353
+ ddot(x(ix(2):ix(3)-1),z,K.qblkstart)) / 2;
5454
tmp = halfxz.^2 - detxz;
55-
if tmp > 0
55+
if all(tmp > 0)
5656
lab2q = halfxz + sqrt(tmp);
5757
else
5858
lab2q = halfxz;
@@ -69,4 +69,4 @@
6969
t = 0;
7070
w = wIN;
7171
wr = wrIN;
72-
end
72+
end

‎urotorder.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ void mexFunction(const int nlhs, mxArray *plhs[],
313313
const int nrhs, const mxArray *prhs[])
314314
{
315315
mxArray *myplhs[NPAROUT];
316-
mwIndex i,j,k, nk, nksqr, lenud, sdplen, gnnz, inz, maxKs,maxKssqr, rgnnz, hgnnz;
316+
mwIndex i, k, nk, nksqr, lenud, sdplen, gnnz, inz, maxKs, maxKssqr, rgnnz, hgnnz;
317317
const double *uOld, *permOld=NULL;
318318
double *u, *d, *gjcPr, *permPr, *fwork, *fworkpi;
319319
mwIndex *perm, *gjc;

‎vecsym.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,8 @@ void vecsymPSD(double *y, const double *x,const mwIndex rsdpN,const mwIndex sdpN
139139
void mexFunction(const int nlhs, mxArray *plhs[],
140140
const int nrhs, const mxArray *prhs[])
141141
{
142-
mxArray *output_array[1], *Xk;
143-
144142
coneK cK;
145-
mwIndex k, nk, nksqr, lqDim,lenfull;
143+
mwIndex lqDim, lenfull;
146144
const double *x;
147145
double *y;
148146

‎widelen.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
halfxz = (xM(ix(1):ix(2)-1).*zM(ix(1):ix(2)-1)...
9292
+ ddot(xM(ix(2):ix(3)-1),zM,K.qblkstart)) / 2;
9393
tmp = halfxz.^2 - detxz;
94-
if tmp > 0
94+
if all(tmp > 0)
9595
lab2q = halfxz + sqrt(tmp);
9696
else
9797
lab2q = halfxz;
@@ -124,4 +124,4 @@
124124
wr.alpha=alphaM;
125125
wr.delta=deltaM;
126126
end
127-
wr.desc = 1; % always descent direction.
127+
wr.desc = 1; % always descent direction.

0 commit comments

Comments
 (0)
Please sign in to comment.