From f226aea54c5d0b64afe4ab07ecc27d639b94c1e1 Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Thu, 12 Jun 2014 11:49:39 +0200 Subject: work on reallocation of model and work on bugfix free --- src/msvmmaj_train.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/msvmmaj_train.c') 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; iV = ZAZVT; ZAZVT = ptr; */ - + for (i=0; i