From e2c0ca1c082bfd7755c7af5bc5c9021bce64f3ba Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Mon, 17 Oct 2016 13:41:46 +0200 Subject: Update predictions to work with sparse matrices This is done by pulling the Z*V routines from the gensvm_optimize file to a seperate file, since they are shared by prediction and get_loss --- src/gensvm_optimize.c | 43 +------------------------------------------ 1 file changed, 1 insertion(+), 42 deletions(-) (limited to 'src/gensvm_optimize.c') diff --git a/src/gensvm_optimize.c b/src/gensvm_optimize.c index e83fa47..300df40 100644 --- a/src/gensvm_optimize.c +++ b/src/gensvm_optimize.c @@ -257,10 +257,7 @@ void gensvm_calculate_errors(struct GenModel *model, struct GenData *data, long n = model->n; long K = model->K; - if (data->spZ == NULL) - gensvm_calculate_ZV_dense(model, data, ZV); - else - gensvm_calculate_ZV_sparse(model, data, ZV); + gensvm_calculate_ZV(model, data, ZV); for (i=0; ispZ->n_row; - double z_ij; - - K = model->K; - - int *Zia = data->spZ->ia; - int *Zja = data->spZ->ja; - double *vals = data->spZ->values; - - for (i=0; iV[j*(K-1)], 1, - &ZV[i*(K-1)], 1); - } - } -} - -void gensvm_calculate_ZV_dense(struct GenModel *model, - struct GenData *data, double *ZV) -{ - long n = model->n; - long m = model->m; - long K = model->K; - - cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, n, K-1, m+1, - 1.0, data->Z, m+1, model->V, K-1, 0, ZV, K-1); -} - -- cgit v1.2.3