aboutsummaryrefslogtreecommitdiff
path: root/src/msvmmaj_train.c
diff options
context:
space:
mode:
authorGertjan van den Burg <burg@ese.eur.nl>2014-06-12 11:49:39 +0200
committerGertjan van den Burg <burg@ese.eur.nl>2014-06-12 11:49:39 +0200
commitf226aea54c5d0b64afe4ab07ecc27d639b94c1e1 (patch)
treef9cecc05999f48a6dcdccf2007ee1db0c74f86cd /src/msvmmaj_train.c
parentfixed merge (diff)
downloadgensvm-f226aea54c5d0b64afe4ab07ecc27d639b94c1e1.tar.gz
gensvm-f226aea54c5d0b64afe4ab07ecc27d639b94c1e1.zip
work on reallocation of model and work on bugfix free
Diffstat (limited to 'src/msvmmaj_train.c')
-rw-r--r--src/msvmmaj_train.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/msvmmaj_train.c b/src/msvmmaj_train.c
index 0f42ff6..2333544 100644
--- a/src/msvmmaj_train.c
+++ b/src/msvmmaj_train.c
@@ -84,7 +84,7 @@ void msvmmaj_optimize(struct MajModel *model, struct MajData *data)
msvmmaj_get_update(model, data, B, ZAZ, ZAZV, ZAZVT);
if (it > 50)
msvmmaj_step_doubling(model);
-
+
Lbar = L;
L = msvmmaj_get_loss(model, data, ZV);
@@ -217,6 +217,10 @@ double msvmmaj_get_loss(struct MajModel *model, struct MajData *data,
* @f]
* solving this system is done through dposv().
*
+ * @todo
+ * Consider allocating IPIV and WORK at a higher level, they probably don't
+ * change much during the iterations.
+ *
* @param [in,out] model model to be updated
* @param [in] data data used in model
* @param [in] B pre-allocated matrix used for linear coefficients
@@ -408,6 +412,7 @@ void msvmmaj_get_update(struct MajModel *model, struct MajData *data, double *B,
0.0,
ZAZV,
K-1);
+
cblas_dgemm(
CblasRowMajor,
CblasTrans,
@@ -446,6 +451,7 @@ void msvmmaj_get_update(struct MajModel *model, struct MajData *data, double *B,
// because we have used the upper part in the BLAS
// calls above in Row-major order, and Lapack uses
// column major order.
+
status = dposv(
'L',
m+1,
@@ -489,10 +495,12 @@ void msvmmaj_get_update(struct MajModel *model, struct MajData *data, double *B,
if (status != 0)
fprintf(stderr, "Received nonzero status from "
"dsysv: %i\n", status);
+ free(WORK);
+ free(IPIV);
}
- // Return to Row-major order. The matrix ZAZVT contains the
- // solution after the dposv/dsysv call.
+ // Return to Row-major order. The matrix ZAZVT contains the solution
+ // after the dposv/dsysv call.
for (i=0; i<m+1; i++)
for (j=0; j<K-1; j++)
ZAZV[i*(K-1)+j] = ZAZVT[j*(m+1)+i];
@@ -509,7 +517,7 @@ void msvmmaj_get_update(struct MajModel *model, struct MajData *data, double *B,
model->V = ZAZVT;
ZAZVT = ptr;
*/
-
+
for (i=0; i<m+1; i++) {
for (j=0; j<K-1; j++) {
matrix_set(