aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGertjan van den Burg <burg@ese.eur.nl>2016-10-06 18:02:03 +0200
committerGertjan van den Burg <burg@ese.eur.nl>2016-10-06 18:02:03 +0200
commit7d25a88f8e8ef2465be942b8e3857ef28c552f7c (patch)
tree78fc452b433441e29f0a7191d61a19b64bb51779
parentchange timer functionality to use clock_monotonic_raw (diff)
downloadgensvm-7d25a88f8e8ef2465be942b8e3857ef28c552f7c.tar.gz
gensvm-7d25a88f8e8ef2465be942b8e3857ef28c552f7c.zip
make use of the fact that the first element of z_i is always 1
-rw-r--r--src/gensvm_optimize.c11
1 files changed, 8 insertions, 3 deletions
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