Skip to content

Commit

Permalink
BugFix: Logging would divide by 0 if calculating standard deviation o…
Browse files Browse the repository at this point in the history
…f variable for empty agent population.
  • Loading branch information
Robadob committed Jan 18, 2022
1 parent 9d0774b commit 8aa3b56
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/flamegpu/sim/AgentLoggingConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ template<typename T>
util::Any getAgentVariableStandardDevFunc(HostAgentAPI &ai, const std::string &variable_name) {
// Todo, workout how to make this more multi-thread/deviceable.
// Todo, streams for the memcpy?
if (ai.count() == 0)
return util::Any(0);
// Work out the Mean
const double mean = ai.sum<T, typename sum_input_t<T>::result_t>(variable_name) / static_cast<double>(ai.count());
// Then for each number: subtract the Mean and square the result
Expand Down

0 comments on commit 8aa3b56

Please sign in to comment.