Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce computational cost of vstat #50

Merged
merged 4 commits into from
Oct 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add safeguard
  • Loading branch information
takenori-y committed Oct 19, 2023
commit 195b986e39b0fc981a1fce59b0797848383fce29
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