From 7d25a88f8e8ef2465be942b8e3857ef28c552f7c Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Thu, 6 Oct 2016 18:02:03 +0200 Subject: make use of the fact that the first element of z_i is always 1 --- src/gensvm_optimize.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/gensvm_optimize.c') diff --git a/src/gensvm_optimize.c b/src/gensvm_optimize.c index 60a5682..e517332 100644 --- a/src/gensvm_optimize.c +++ b/src/gensvm_optimize.c @@ -455,7 +455,7 @@ void gensvm_get_update(struct GenModel *model, struct GenData *data, { int status; long i, j; - double alpha; + double alpha, sqalpha; long n = model->n; long m = model->m; @@ -469,8 +469,13 @@ void gensvm_get_update(struct GenModel *model, struct GenData *data, // calculate row of matrix LZ, which is a scalar // multiplication of sqrt(alpha_i) and row z_i' of Z - cblas_daxpy(m+1, sqrt(alpha), &data->Z[i*(m+1)], 1, - &work->LZ[i*(m+1)], 1); + // Note that we use the fact that the first column of Z is + // always 1, by only computing the product for m values and + // copying the first element over. + sqalpha = sqrt(alpha); + work->LZ[i*(m+1)] = sqalpha; + cblas_daxpy(m, sqalpha, &data->Z[i*(m+1)+1], 1, + &work->LZ[i*(m+1)+1], 1); // rank 1 update of matrix Z'*B // Note: LDA is the second dimension of ZB because of -- cgit v1.2.3