From 303ee78bdd9b32da7d972d8e7202207e145f94e4 Mon Sep 17 00:00:00 2001 From: Davis King Date: Wed, 28 Jul 2010 23:50:20 +0000 Subject: [PATCH] Minor change to get better cache locality. Gives a nice speedup though. --HG-- extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403797 --- dlib/svm/krr_trainer.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dlib/svm/krr_trainer.h b/dlib/svm/krr_trainer.h index 0f8ee19ca..b53fe5aff 100644 --- a/dlib/svm/krr_trainer.h +++ b/dlib/svm/krr_trainer.h @@ -372,9 +372,12 @@ namespace dlib matrix Vx; if (lambda == 0 || output_looe) { + // Save the transpose of V into a temporary because the subsequent matrix + // vector multiplies will be faster (because of better cache locality). + const general_matrix_type transV(trans(V)); Vx.set_size(proj_x.size()); for (long i = 0; i < proj_x.size(); ++i) - Vx(i) = squared(trans(V)*proj_x(i)); + Vx(i) = squared(transV*proj_x(i)); } the_lambda = lambda;