32 int nr = train->nrows;
33 int ni = train->ncols;
36 double * bl = gk_malloc(
sizeof(
double)*ni,
"malloc bl");
37 gk_dset(ni, ctrl->
bl, bl);
38 double * bu = gk_malloc(
sizeof(
double)*ni,
"malloc bu");
39 gk_dset(ni, ctrl->
bu, bu);
42 double * b = gk_malloc(
sizeof(
double)*nr,
"malloc b");
45 double * c = gk_malloc(
sizeof(
double)*ni,
"malloc c");
46 gk_dset(ni, ctrl->
lambda, c);
49 double * w = gk_malloc(
sizeof(
double)*ni,
"malloc w");
54 cs * csA = gk_malloc(
sizeof(
cs),
"malloc csA");
64 csA->
nzmax = *(A->rowptr + A->nrows);
67 Wrk->
acol = gk_malloc(
sizeof(
int)*ni,
"malloc acol");
68 gk_iset(ni, 1, Wrk->
acol);
71 float * A_colval = NULL;
75 int bsize = ctrl->
bsize;
76 gk_csr_t * mat = gk_csr_Create();
78 mat->ncols = train->ncols;
79 mat->rowptr = gk_malloc(
sizeof(
int)*(ni+1),
"malloc mat->rowptr");
81 mat->rowind = gk_malloc(
sizeof(
int)*ni*bsize,
"malloc mat->rowind");
82 gk_iset(ni*bsize, 0, mat->rowind);
83 mat->rowval = gk_malloc(
sizeof(
float)*ni*bsize,
"malloc mat->rowval");
84 gk_fset(ni*bsize, 0, mat->rowval);
90 gk_csr_t * constraint = NULL;
98 int endi = (ctrl->
endi >= 0)? ctrl->
endi:ni;
101 for (
int i = starti; i < endi; i ++){
104 printf(
"column %8d: ", i);
107 if (i >= train->ncols){
108 *(mat->rowptr + mat->nrows + 1) = *(mat->rowptr + mat->nrows);
116 if (train->colptr[i+1] - train->colptr[i] == 0){
117 *(mat->rowptr + mat->nrows + 1) = *(mat->rowptr + mat->nrows);
125 for (
int j = train->colptr[i]; j < train->colptr[i+1]; j ++){
126 if (train->colval[j] != 0) {
131 *(mat->rowptr + mat->nrows + 1) = *(mat->rowptr + mat->nrows);
152 bcsol(ctrl, A, b, w, Wrk, bl, bu, ctrl->
beta, c);
170 if (mat->nrows >= ctrl->
bsize){
171 printf(
"Dumping data...\n");
177 *(mat->rowptr + mat->nrows + 1) = *(mat->rowptr + mat->nrows);
178 for (
int j = 0, k = 0; j < ni; j ++){
180 *(mat->rowind + mat->rowptr[mat->nrows] + k) = j;
181 *(mat->rowval + mat->rowptr[mat->nrows] + k) = w[j];
182 (*(mat->rowptr + mat->nrows + 1)) ++;
199 printf(
"Dumping data...\n");
205 gk_free((
void **)&timer, LTERM); gk_free((
void **)&timer0, LTERM);
206 gk_csr_Free(&mat); gk_free((
void **)&w, LTERM);
207 gk_free((
void **)&bl, &bu, &b, &c, LTERM);
208 gk_csr_Free(&constraint);
209 gk_free((
void **)&csA, LTERM);
210 gk_free((
void **)&Wrk->
acol, LTERM); gk_free((
void **)&Wrk, LTERM);
211 gk_free((
void **)&A_colval, LTERM);