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;