Skip to content

Commit

Permalink
Merge pull request #13 from robertgj/master
Browse files Browse the repository at this point in the history
Fix compiler warnings
  • Loading branch information
siko1056 committed Aug 17, 2020
2 parents b21edad + c33698e commit c460d48
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 87 deletions.
10 changes: 7 additions & 3 deletions Solver/Mexfun/mexProd2.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void symmetrize(double *P, int n)
void product(double *A, double *B, double *P,
int m, int n, int p, int type)

{ int i, j, k, jm, jn, km, kstart, kend;
{ int j, k, jm, jn, km, kstart, kend;
int istart, iend;
double tmp;

Expand All @@ -84,7 +84,7 @@ void product(double *A, double *B, double *P,
void product2(double *A, double *B, mwIndex *irB, mwIndex *jcB,
double *P, int m, int n, int p, int type)

{ int i, j, k, r, kstart, kend, istart, iend, jm, rm;
{ int j, k, r, kstart, kend, istart, iend, jm, rm;
double tmp;

for (j=0; j<p; j++){
Expand Down Expand Up @@ -144,6 +144,8 @@ void product4(double *A, mwIndex *irA, mwIndex *jcA,
int idx;
double tmp;

jend=0;

idx = 0; jcP[0]=0;
for (l=0; l<numblk; l++) {
jstart = cumblk[l]; jend = cumblk[l+1];
Expand Down Expand Up @@ -222,10 +224,12 @@ void mexFunction(int nlhs, mxArray *plhs[],
mwIndex *irA, *jcA, *irB, *jcB, *irP, *jcP;
int *cumblk;
int isspA, isspB, m1, n1, m2, n2;
int type, index, numblk, NZmax, cols, i, l;
int type, index, numblk, NZmax, cols, l;
mwIndex subs[2];
mwSize nsubs=2;

jcB=0; irB=0; jcA=0; irA=0;

/* Check for proper number of arguments */
if (nrhs<3){
mexErrMsgTxt("mexProd2: requires at least 3 input arguments."); }
Expand Down
6 changes: 4 additions & 2 deletions Solver/Mexfun/mexProd2nz.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ void prod1(int m, int n, int p,
{ int j, k, r, t, rn, jn, jold, kstart, kend, idx, count;
double tmp;

jn = 0;
jold = -1; count = 0;
for (t=0; t<len; ++t) {
r = list1[t];
Expand Down Expand Up @@ -96,15 +97,14 @@ void prod2(int m, int n, int p,
double *P, mwIndex *irP, mwIndex *jcP, double *Btmp,
int *list1, int *list2, int len)

{ int j, k, r, t, rn, jn, jold, kstart, kend, idx, count;
{ int j, k, r, t, rn, jold, kstart, kend, idx, count;
double tmp;

jold = -1; count = 0;
for (t=0; t<len; ++t) {
r = list1[t];
j = list2[t];
if (j != jold) {
jn = j*n;
/***** copy j-th column of sparse B to Btmp *****/
for (k=0; k<n; ++k) { Btmp[k] = 0; }
kstart = jcB[j]; kend = jcB[j+1];
Expand Down Expand Up @@ -139,6 +139,8 @@ void mexFunction(int nlhs, mxArray *plhs[],
double *Btmp, *listtmp;
int m1, n1, m2, n2, mlist, nlist, isspA, isspB, k;

jcA=0; irA=0;

/* Check for proper number of arguments */
if (nrhs < 4){
mexErrMsgTxt("mexProd2nz: requires at least 4 input arguments."); }
Expand Down
2 changes: 1 addition & 1 deletion Solver/Mexfun/mexinprod.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void mexFunction(int nlhs, mxArray *plhs[],

mwIndex subs[2];
mwSize nsubs=2;
int mA, nA, m1, n1, m2, n2, j, index;
int mA, m1, n1, m2, n2, j, index;
int rowidx, colidx, r, k, kstart, kend;


Expand Down
28 changes: 14 additions & 14 deletions Solver/Mexfun/mexmat.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void mat1(int n,
jcB[j+1] = count;
}
} else if (isspA && !isspB) {
j2 = 0; idxj = 0;
i = 0; j2 = 0; idxj = 0;
kstart = jcA[colidx]; kend = jcA[colidx+1];
for (k=kstart; k<kend; k++) {
r = irA[k];
Expand All @@ -52,7 +52,7 @@ void mat1(int n,
}
} else if (isspA && isspB) {
count = 0;
j2 = 0; idxj = 0;
i = 0; j2 = 0; idxj = 0;
kstart = jcA[colidx]; kend = jcA[colidx+1];
for (k=kstart; k<kend; k++) {
r = irA[k];
Expand Down Expand Up @@ -101,7 +101,7 @@ void mat1cmp(int n,
jcB[j+1] = count;
}
} else if (isspA && !isspB) {
j2 = 0; idxj = 0;
i = 0; j2 = 0; idxj = 0;
kstart = jcA[colidx]; kend = jcA[colidx+1];
for (k=kstart; k<kend; k++) {
r = irA[k];
Expand All @@ -111,7 +111,7 @@ void mat1cmp(int n,
}
} else if (isspA && isspB) {
count = 0;
j2 = 0; idxj = 0;
i = 0; j2 = 0; idxj = 0;
kstart = jcA[colidx]; kend = jcA[colidx+1];
for (k=kstart; k<kend; k++) {
r = irA[k];
Expand All @@ -133,9 +133,8 @@ void mat2(int n, int numblk, int *cumblksize, int *blknnz,
double *A, int mA, int colidx,
double *B, mwIndex *irB, mwIndex *jcB, int isspB)

{ int idx, i, j, r, jn, k, kstart, kend, idxj, j2, count;
int t, t2, istart, jstart, jend, rowidx, nsub;
double tmp;
{ int idx, i, j, idxj;
int t, istart, jstart, jend, rowidx, nsub;

idx = 0;
jstart = 0; jend = 0; jcB[0]=0;
Expand Down Expand Up @@ -164,9 +163,8 @@ void mat2cmp(int n, int numblk, int *cumblksize, int *blknnz,
double *B, mwIndex *irB, mwIndex *jcB, int isspB,
double *AI, double *BI)

{ int idx, i, j, r, jn, k, kstart, kend, idxj, j2, count;
int t, t2, istart, jstart, jend, rowidx, nsub;
double tmp;
{ int idx, i, j, idxj;
int t, istart, jstart, jend, rowidx, nsub;

idx = 0;
jstart = 0; jend = 0; jcB[0]=0;
Expand Down Expand Up @@ -201,13 +199,15 @@ void mexFunction(int nlhs, mxArray *plhs[],
double *A, *B, *AI, *BI, *blksize, *Atmp, *AItmp;
mwIndex *irA, *jcA, *irB, *jcB;
int *cumblksize, *blknnz;
int iscellA, mblk, mA, nA, m1, n1, rowidx, colidx, isspA, isspB;
int iscmpA, iscmpB;
int iscellA, mA, m1, n1, rowidx, colidx, isspA, isspB;
int iscmpA;

mwIndex subs[2];
mwSize nsubs=2;
int n, n2, k, nsub, index, numblk, NZmax, r, kstart, kend;

jcB=0; irB=0; AItmp=0; jcA=0; irA=0;

/* CHECK FOR PROPER NUMBER OF ARGUMENTS */

if (nrhs < 2){
Expand All @@ -218,8 +218,8 @@ void mexFunction(int nlhs, mxArray *plhs[],
/* CHECK THE DIMENSIONS */

iscellA = mxIsCell(prhs[1]);
if (iscellA) { mA = mxGetM(prhs[1]); nA = mxGetN(prhs[1]); }
else { mA = 1; nA = 1; }
if (iscellA) { mA = mxGetM(prhs[1]); }
else { mA = 1; }
if (mxGetM(prhs[0]) != mA) {
mexErrMsgTxt("mexsmat: blk and Avec not compatible"); }

Expand Down
3 changes: 1 addition & 2 deletions Solver/Mexfun/mexnnz.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void mexFunction(int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[] )

{ double *A, *nnz;
mwIndex *irA, *jcA;
mwIndex *jcA;

int NZmax, m, n, isspA, j, k, jm, nnztmp;

Expand All @@ -43,7 +43,6 @@ void mexFunction(int nlhs, mxArray *plhs[],
A = mxGetPr(prhs[0]);
isspA = mxIsSparse(prhs[0]);
if (isspA) {
irA = mxGetIr(prhs[0]);
jcA = mxGetJc(prhs[0]);
NZmax = jcA[n];
}
Expand Down
2 changes: 1 addition & 1 deletion Solver/Mexfun/mexqops.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void mexFunction(int nlhs, mxArray *plhs[],
{ double *blksize, *x, *y, *z, *xtmp, *ytmp;
mwIndex *irx, *jcx, *iry, *jcy;
int *cumblk;
int mblk, options;
int options;

int l, n, k, r, numblk, cols;

Expand Down
20 changes: 12 additions & 8 deletions Solver/Mexfun/mexschur.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ void schurij2(double *Avec,
mwIndex *nzlistAr, mwIndex *nzlistAc, mwIndex *cumblksize,
mwIndex *blkidx, int col, double *schurcol)

{ int r, ra, ca, rb, cb, l, k, kstart, kend, kstartnew, lstart, lend;
int colcb1, idxrb, idxcb, idx1, idx2, idx3, idx4;
{ int ra, ca, rb, cb, l, k, kstart, kend, kstartnew, lstart, lend;
int idxrb, idxcb, idx1, idx2, idx3, idx4;
int i, cblk, calk, firstime;
double tmp0, tmp1, tmp2, tmp3, tmp4;

Expand Down Expand Up @@ -227,8 +227,8 @@ void schurij4( double *Avec,
mwIndex *nzlistAr, mwIndex *nzlistAc, mwIndex *cumblksize,
mwIndex *blkidx, int col, double *schurcol)

{ int r, ra, ca, rb, cb, l, k, kstart, kend, kstartnew, lstart, lend;
int colcb1, idxrb, idxcb, idx1, idx2, idx3, idx4;
{ int ra, ca, rb, cb, l, k, kstart, kend, kstartnew, lstart, lend;
int idxrb, idxcb, idx1, idx2, idx3, idx4;
int i, cblk, calk, firstime;
double tmp0, tmp1, tmp2, tmp3, tmp4;
double hlf=0.5;
Expand Down Expand Up @@ -291,9 +291,10 @@ void mexFunction(int nlhs, mxArray *plhs[],
mwIndex subs[2];
mwSize nsubs=2;
int index, colend, type, isspU, isspV, numblk, nzP, existP;
int len, row, col, nU, nV, n, m, m1, idx1, idx2, l, k, nsub, n1, n2, opt, opt2;
int len, row, col, nU, nV, n, m, m1, idx1, idx2, l, k, nsub, n1, n2, opt;
int kstart, kend, rb, cb, cblk, colcb, count;
double tmp;

opt=0; Utmp=0; Vtmp=0; nzlistAc=0; nzlistAr=0; blknnz=0; cumblksize=0; blkidx=0; nzP=0; jcP=0; irP=0; jcV=0; irV=0;

/* CHECK THE DIMENSIONS */

Expand Down Expand Up @@ -363,9 +364,10 @@ void mexFunction(int nlhs, mxArray *plhs[],
/************************************
* output
************************************/

if (nlhs>=1) {
plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL);
nzschur = mxGetPr(plhs[0]);
}
if (nlhs==2) {
nzP = (int) (0.2*m*m+5);
plhs[1] = mxCreateSparse(m,colend,nzP,mxREAL);
Expand Down Expand Up @@ -454,11 +456,13 @@ void mexFunction(int nlhs, mxArray *plhs[],
}
}

if (nlhs>=1) {
nzschur[0] = count;
}

mxFree(blksize); mxFree(nzlistAi); mxFree(nzlistAj);
mxFree(permA); mxFree(idxstart); mxFree(schurcol);
if (isspU) {
if (isspU && isspV) {
mxFree(Utmp); mxFree(Vtmp);
mxFree(nzlistAc); mxFree(nzlistAr);
mxFree(blknnz); mxFree(cumblksize); mxFree(blkidx);
Expand Down
16 changes: 9 additions & 7 deletions Solver/Mexfun/mexschurfun.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ void mexFunction(const int nlhs, mxArray *plhs[],
mwIndex *irX, *jcX, *irY, *jcY;
int n, isspX, isspY, j, jn, k, kstart, kend, r, kstart2, kend2;
int options, scalarY;
double tmp, tmp2, alpha;
double alpha;

alpha=0; scalarY=0; jcY=0; irY=0; jcX=0; irX=0;

if(nrhs < 2)
mexErrMsgTxt("mexschurfun: requires at least 2 input arguments.");
Expand All @@ -41,7 +43,7 @@ void mexFunction(const int nlhs, mxArray *plhs[],
jcY = mxGetJc(prhs[1]);
}
if (nrhs == 2) {
if ((mxGetM(prhs[1]) == n) & (mxGetN(prhs[1]) == n)) {
if ((mxGetM(prhs[1]) == n) && (mxGetN(prhs[1]) == n)) {
options = 2;
} else {
options = 1;
Expand All @@ -50,10 +52,10 @@ void mexFunction(const int nlhs, mxArray *plhs[],
options = (int) (*mxGetPr(prhs[2]));
}
if (options == 1 || options == 3) {
if ((mxGetN(prhs[1]) != 1) & (mxGetM(prhs[1]) != 1)) {
if ((mxGetN(prhs[1]) != 1) && (mxGetM(prhs[1]) != 1)) {
mexErrMsgTxt("mexschurfun: Y should be a vector."); }
} else {
if ((mxGetN(prhs[1]) == 1) & (mxGetM(prhs[1]) == 1)) {
if ((mxGetN(prhs[1]) == 1) && (mxGetM(prhs[1]) == 1)) {
scalarY = 1;
alpha = Y[0];
} else {
Expand Down Expand Up @@ -95,19 +97,19 @@ void mexFunction(const int nlhs, mxArray *plhs[],
}
}
} else {
if (isspX & !isspY) {
if (isspX && !isspY) {
for (j=0; j<n; j++) {
kstart = jcX[j]; kend = jcX[j+1]; jn = j*n;
for (k=kstart; k<kend; k++) {
r = irX[k];
X[k] += Y[r+jn]; }
}
} else if (!isspX & !isspY) {
} else if (!isspX && !isspY) {
for (j=0; j<n; j++) {
jn = j*n;
for (k=0; k<n; k++) { X[k+jn] += Y[k+jn]; }
}
} else if (!isspX & isspY) {
} else if (!isspX && isspY) {
for (j=0; j<n; j++) {
kstart = jcY[j]; kend = jcY[j+1]; jn = j*n;
for (k=kstart; k<kend; k++) {
Expand Down
2 changes: 1 addition & 1 deletion Solver/Mexfun/mexskron.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void mexFunction(int nlhs, mxArray *plhs[],
{ mxArray *blk_cell_pr;
mxArray *tmparr[3];
double *A, *B, *blksizetmp, *P, *Q, *V;
double *ii, *jj, *vv, *vvtmp, *x1, *y1, *x2, *y2;
double *vvtmp, *x1, *y1, *x2, *y2;
mwIndex *irA, *jcA, *irB, *jcB, *irV, *jcV;
int *blksize, *blksize2, *cumblksize, *blksize4;
int isspA, isspB, sym;
Expand Down
Loading

0 comments on commit c460d48

Please sign in to comment.