Skip to content
Snippets Groups Projects
Commit 42b85095 authored by Vesa Oikonen's avatar Vesa Oikonen
Browse files

edited to avoid warning from gcc 12.2.0

parent 57c332e1
No related branches found
No related tags found
No related merge requests found
......@@ -213,9 +213,9 @@ int main(int argc, char **argv)
if(verbose>1) fprintf(stdout, "allocating memory for NNLS\n");
int nnls_n=NNLS_N;
int nnls_m=dataNr;
int n, m, nnls_index[nnls_n];
double **nnls_a, nnls_b[nnls_m], nnls_zz[nnls_m], nnls_x[nnls_n], *nnls_mat,
nnls_wp[nnls_n], nnls_rnorm;
int n, m /*, nnls_index[nnls_n]*/;
double **nnls_a, nnls_b[nnls_m], nnls_zz[nnls_m], /* nnls_x[nnls_n],*/ *nnls_mat,
/*nnls_wp[nnls_n],*/ nnls_rnorm;
nnls_mat=(double*)malloc((nnls_n*nnls_m)*sizeof(double));
nnls_a=(double**)malloc(nnls_n*sizeof(double*));
if(nnls_mat==NULL || nnls_a==NULL) {
......@@ -225,7 +225,6 @@ int main(int argc, char **argv)
}
for(n=0; n<nnls_n; n++) nnls_a[n]=nnls_mat+n*nnls_m;
/*
* Compute pixel-by-pixel
*/
......@@ -268,6 +267,8 @@ int main(int argc, char **argv)
}
}
/* NNLS */
int nnls_index[nnls_n];
double nnls_x[nnls_n], nnls_wp[nnls_n];
ret=nnls(nnls_a, nnls_m, nnls_n, nnls_b, nnls_x, &nnls_rnorm, nnls_wp, nnls_zz, nnls_index);
if(ret!=0) { /* no solution is possible */
if(verbose>3) printf("no solution possible (%d)\n", ret);
......
......@@ -67,11 +67,11 @@ int nnls(
/* Check the parameters and data */
if(m<=0 || n<=0 || a==NULL || b==NULL || x==NULL) return(2);
/* Allocate memory for working space, if required */
int *index=NULL;
double *w=NULL, *zz=NULL;
if(wp!=NULL) w=wp; else w=(double*)calloc(n, sizeof(double));
if(zzp!=NULL) zz=zzp; else zz=(double*)calloc(m, sizeof(double));
if(indexp!=NULL) index=indexp; else index=(int*)calloc(n, sizeof(int));
int *index=NULL, *indexl=NULL;
double *w=NULL, *zz=NULL, *wl=NULL, *zzl=NULL;
if(wp!=NULL) w=wp; else w=wl=(double*)calloc(n, sizeof(double));
if(zzp!=NULL) zz=zzp; else zz=zzl=(double*)calloc(m, sizeof(double));
if(indexp!=NULL) index=indexp; else index=indexl=(int*)calloc(n, sizeof(int));
if(w==NULL || zz==NULL || index==NULL) return(2);
/* Initialize the arrays INDEX[] and X[] */
......@@ -234,10 +234,12 @@ int nnls(
}
/* Free working space, if it was allocated here */
if(wp==NULL) free(w);
if(zzp==NULL) free(zz);
if(indexp==NULL) free(index);
w=NULL; zz=NULL; index=NULL;
if(wl!=NULL) free(wl);
if(zzl!=NULL) free(zzl);
if(indexl!=NULL) free(indexl);
if(iter>=itmax) return(1);
return(0);
} /* nnls */
/*****************************************************************************/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment