mirror of https://github.com/davisking/dlib.git
Avoid division by zero in running_scalar_covariance_decayed.
This commit is contained in:
parent
7c63185739
commit
539993f359
|
@ -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 (
|
||||
|
|
Loading…
Reference in New Issue