23 ctrl_t * ctrl = gk_malloc(
sizeof(
ctrl_t),
"malloc ctrl");
72 gk_free((
void **)&ctrl->
test_file, LTERM);
73 gk_free((
void **)&ctrl->
pred_file, LTERM);
74 gk_free((
void **)&ctrl->
fs_file, LTERM);
76 gk_free((
void **)&ctrl, LTERM);
90 ctimer->
start = clock();
103 ctimer->
end = clock();
118 printf(
"----- elapsed CPU time for %s: %f s\n", msg,
119 (
double)(ctimer->
end - ctimer->
start)/CLOCKS_PER_SEC);
138 for (
int i = 0; i < narray; i ++){
159 void find_topk(
double * w,
int n,
int topk,
double * map,
int * topk2){
162 gk_dkv_t * wkv = gk_malloc(
sizeof(gk_dkv_t)*n,
"malloc wkv");
165 for (
int i = 0; i < n; i ++){
168 if (w[i] > 1e-10) k2 ++;
174 for (
int i = 0; i < ((topk <= k2)? topk:k2); i ++){
178 *topk2 = ((topk <= k2)? topk:k2);
179 gk_free((
void **)&wkv, LTERM);
196 if (i > constraint->ncols){
197 gk_dset(constraint->nrows, 0, w);
200 int nnz = constraint->colptr[i+1] - constraint->colptr[i];
201 for (
int j = 0; j < nnz; j ++){
202 int k = *(constraint->colptr[i] + j + constraint->colind);
203 w[k] = *(constraint->colptr[i] + j + constraint->colval);