SLIM learning.
{
int nr = train->nrows;
int ni = train->ncols;
double * bl = gk_malloc(sizeof(double)*ni, "malloc bl");
gk_dset(ni, ctrl->
bl, bl);
double * bu = gk_malloc(sizeof(double)*ni, "malloc bu");
gk_dset(ni, ctrl->
bu, bu);
double * b = gk_malloc(sizeof(double)*nr, "malloc b");
gk_dset(nr, 0, b);
double * c = gk_malloc(sizeof(double)*ni, "malloc c");
double * w = gk_malloc(sizeof(double)*ni, "malloc w");
gk_dset(ni, 0, w);
gk_csr_t * A = train;
cs * csA = gk_malloc(
sizeof(
cs),
"malloc csA");
csA->
nzmax = *(A->rowptr + A->nrows);
Wrk->
acol = gk_malloc(
sizeof(
int)*ni,
"malloc acol");
gk_iset(ni, 1, Wrk->
acol);
float * A_colval = NULL;
gk_csr_t * mat = gk_csr_Create();
mat->nrows = 0;
mat->ncols = train->ncols;
mat->rowptr = gk_malloc(sizeof(int)*(ni+1), "malloc mat->rowptr");
mat->rowptr[0] = 0;
mat->rowind = gk_malloc(sizeof(int)*ni*bsize, "malloc mat->rowind");
gk_iset(ni*bsize, 0, mat->rowind);
mat->rowval = gk_malloc(sizeof(float)*ni*bsize, "malloc mat->rowval");
gk_fset(ni*bsize, 0, mat->rowval);
gk_csr_t * constraint = NULL;
}
int endi = (ctrl->
endi >= 0)? ctrl->
endi:ni;
for (int i = starti; i < endi; i ++){
printf("column %8d: ", i);
if (i >= train->ncols){
*(mat->rowptr + mat->nrows + 1) = *(mat->rowptr + mat->nrows);
mat->nrows ++;
continue;
}
if (train->colptr[i+1] - train->colptr[i] == 0){
*(mat->rowptr + mat->nrows + 1) = *(mat->rowptr + mat->nrows);
mat->nrows ++;
continue;
}
int allzeros = 1;
for (int j = train->colptr[i]; j < train->colptr[i+1]; j ++){
if (train->colval[j] != 0) {
allzeros = 0; break;
}
}
if (allzeros == 1){
*(mat->rowptr + mat->nrows + 1) = *(mat->rowptr + mat->nrows);
mat->nrows ++;
continue;
}
gk_dset(nr, 0, b);
gk_dset(ni, 0, w);
bcsol(ctrl, A, b, w, Wrk, bl, bu, ctrl->
beta, c);
}
else{
}
if (mat->nrows >= ctrl->
bsize){
printf("Dumping data...\n");
mat->nrows = 0;
}
*(mat->rowptr + mat->nrows + 1) = *(mat->rowptr + mat->nrows);
for (int j = 0, k = 0; j < ni; j ++){
*(mat->rowind + mat->rowptr[mat->nrows] + k) = j;
*(mat->rowval + mat->rowptr[mat->nrows] + k) = w[j];
(*(mat->rowptr + mat->nrows + 1)) ++;
k ++;
}
}
mat->nrows ++;
}
printf("Dumping data...\n");
gk_free((void **)&timer, LTERM); gk_free((void **)&timer0, LTERM);
gk_csr_Free(&mat); gk_free((void **)&w, LTERM);
gk_free((void **)&bl, &bu, &b, &c, LTERM);
gk_csr_Free(&constraint);
gk_free((void **)&csA, LTERM);
gk_free((
void **)&Wrk->
acol, LTERM); gk_free((
void **)&Wrk, LTERM);
gk_free((void **)&A_colval, LTERM);
}