Skip to content

Commit

Permalink
add safeguard
Browse files Browse the repository at this point in the history
  • Loading branch information
takenori-y committed Oct 19, 2023
1 parent 37beca3 commit 195b986
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/math/statistics_accumulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ bool StatisticsAccumulation::GetStandardDeviation(
bool StatisticsAccumulation::GetFullCovariance(
const StatisticsAccumulation::Buffer& buffer,
SymmetricMatrix* full_covariance) const {
if (!is_valid_ || num_statistics_order_ < 2 ||
if (!is_valid_ || num_statistics_order_ < 2 || diagonal_ ||
buffer.zeroth_order_statistics_ <= 0 || NULL == full_covariance) {
return false;
}
Expand Down Expand Up @@ -162,7 +162,7 @@ bool StatisticsAccumulation::GetFullCovariance(
bool StatisticsAccumulation::GetUnbiasedCovariance(
const StatisticsAccumulation::Buffer& buffer,
SymmetricMatrix* unbiased_covariance) const {
if (!is_valid_ || num_statistics_order_ < 2 ||
if (!is_valid_ || num_statistics_order_ < 2 || diagonal_ ||
buffer.zeroth_order_statistics_ <= 1 || NULL == unbiased_covariance) {
return false;
}
Expand All @@ -185,7 +185,8 @@ bool StatisticsAccumulation::GetUnbiasedCovariance(
bool StatisticsAccumulation::GetCorrelation(
const StatisticsAccumulation::Buffer& buffer,
SymmetricMatrix* correlation) const {
if (!is_valid_ || num_statistics_order_ < 2 || NULL == correlation) {
if (!is_valid_ || num_statistics_order_ < 2 || diagonal_ ||
NULL == correlation) {
return false;
}

Expand Down

0 comments on commit 195b986

Please sign in to comment.