From 653e854d77266289013bf73e7e65561975ccc931 Mon Sep 17 00:00:00 2001 From: AlexandreHiroyuki Date: Tue, 11 Jun 2024 12:43:29 -0300 Subject: [PATCH] refactor(DataTomeAnalysis): :zap: improve calculation of method var --- src/DataTomeAnalysis.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/DataTomeAnalysis.h b/src/DataTomeAnalysis.h index e9d7ec6..4d39768 100644 --- a/src/DataTomeAnalysis.h +++ b/src/DataTomeAnalysis.h @@ -133,7 +133,8 @@ class DataTomeAnalysis : public DataTomeMvAvg { TypeOfArray var = 0; for (size_t i = 0; i < this->point_count(); i++) { - var += ((*this)[i] - average) * ((*this)[i] - average); + TypeOfArray data_point = (*this)[i] - average; + var += (data_point - average) * (data_point - average); } return var; @@ -264,7 +265,8 @@ class DataTomeAnalysis : public DataTomeMvAvg { TypeOfArray var = 0; for (size_t i = 0; i < this->partial_point_count(partial_id); i++) { - var += ((*this)[i] - average) * ((*this)[i] - average); + TypeOfArray data_point = (*this)[i] - average; + var += (data_point - average) * (data_point - average); } return var;