Avoid division by zero in running_scalar_covariance_decayed.

This commit is contained in:
Davis King 2016-11-14 15:47:04 -05:00
parent 7c63185739
commit 539993f359
1 changed files with 5 additions and 1 deletions

View File

@ -549,7 +549,11 @@ namespace dlib
<< "\n\tthis: " << this
);
return covariance() / std::sqrt(variance_x()*variance_y());
T temp = std::sqrt(variance_x()*variance_y());
if (temp != 0)
return covariance() / temp;
else
return 0; // just say it's zero if there isn't any variance in x or y.
}
T variance_x (