From 39c23ea0bdbad9b70f5b0839946617d02fdc82e1 Mon Sep 17 00:00:00 2001 From: Maria Dimashova Date: Tue, 10 Apr 2012 11:06:21 +0000 Subject: [PATCH] replaced using cv::exp --- modules/ml/src/em.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/ml/src/em.cpp b/modules/ml/src/em.cpp index 130c9b87a..f2f3520f1 100644 --- a/modules/ml/src/em.cpp +++ b/modules/ml/src/em.cpp @@ -503,8 +503,11 @@ void EM::computeProbabilities(const Mat& sample, int& label, Mat* probs, double* return; Mat buf, *sampleProbs = probs ? probs : &buf; - Mat expL_Lmax; - exp(L - L.at(label), expL_Lmax); + Mat expL_Lmax(L.size(), CV_64FC1); + double maxLVal = L.at(label); + for(int i = 0; i < L.cols; i++) + expL_Lmax.at(i) = std::exp(L.at(i) - maxLVal); + double partSum = 0, // sum_j!=q (exp(L_ij - L_iq)) factor; // 1/(1 + partExpSum) for(int clusterIndex = 0; clusterIndex < nclusters; clusterIndex++)