Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiler warnings about uninitialised variables and issue #15 #58

Merged
merged 5 commits into from
Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion adendotd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.");
Expand Down
7 changes: 6 additions & 1 deletion adenscale.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/* ------------------------------------------------------------
Expand Down Expand Up @@ -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
------------------------------------------------------------ */
Expand Down
19 changes: 12 additions & 7 deletions blkchol2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(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').
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
------------------------------------------------------------ */
Expand Down
2 changes: 1 addition & 1 deletion bwblkslv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions dpr1fact.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +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++)
if(psqr[dep[i]] > psqrdep){
j = i;
Expand Down
2 changes: 2 additions & 0 deletions extractA.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion fwblkslv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion getada3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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).
------------------------------------------------------------ */
Expand Down
7 changes: 6 additions & 1 deletion givensrot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand Down
9 changes: 7 additions & 2 deletions psdframeit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------------------------------------------------------ */
Expand All @@ -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
------------------------------------------------------------ */
Expand Down
7 changes: 6 additions & 1 deletion psdinvjmul.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
------------------------------------------------------------ */
Expand Down
7 changes: 6 additions & 1 deletion sdmauxCone.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -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];
Expand Down
16 changes: 7 additions & 9 deletions sedumi.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<length(origcoeff.c)
%not all primal variables are free
% Primal cone infeasibility
Expand All @@ -788,14 +790,10 @@
info.err(2)=max(0,-min(eigK(full(x(origcoeff.K.f+1:end)),tempK)/(1+normb)));
% Dual cone infeasibility
info.err(4)=max(0,-min(eigK(full(s(origcoeff.K.f+1:end)),tempK)/(1+normc)));

else
info.err(2)=0;
info.err(4)=0;
end
% Dual infeasibility
%info.err(3)=0.0; %s is not maintained explicitely
% Relative duality gap
info.err(3)=0.0; % not maintained explicitly
% Relative duality gap
info.err(5)=(cx-by)/(1+abs(cx)+abs(by));
% Relative complementarity
info.err(6)=xs/(1+abs(cx)+abs(by));
Expand Down
8 changes: 6 additions & 2 deletions spscale.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
/* ------------------------------------------------------------
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)].
------------------------------------------------------------ */
Expand All @@ -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 */
Expand Down Expand Up @@ -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)].
Expand Down
7 changes: 6 additions & 1 deletion sqrtinv.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ void prpiqdivv(double *y,double *ypi, const double *q,const double *qpi,
void mexFunction(const int nlhs, mxArray *plhs[],
const int nrhs, const mxArray *prhs[])
{
mwIndex i,k, nk, nksqr, lenud, lendiag, diagskip;
mwIndex k, nk, nksqr, lenud, diagskip;
#ifdef MEX_DEBUG
mwIndex lendiag;
#endif
double *y;
const double *q,*v;
coneK cK;
Expand All @@ -113,7 +116,9 @@ void mexFunction(const int nlhs, mxArray *plhs[],
------------------------------------------------------------ */
lenud = cK.rDim + cK.hDim;
diagskip = cK.lpN + 2 * cK.lorN; /* diag for LP and Lorentz */
#ifdef MEX_DEBUG
lendiag = diagskip + cK.rLen + cK.hLen;
#endif
/* ------------------------------------------------------------
Get inputs v, q
------------------------------------------------------------ */
Expand Down
6 changes: 4 additions & 2 deletions urotorder.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++){
Expand Down Expand Up @@ -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++){
Expand Down Expand Up @@ -311,8 +313,8 @@ 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;
const double *uOld, *permOld;
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;
double *g, *gk;
Expand Down
4 changes: 1 addition & 3 deletions vecsym.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down