diff options
author | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2022-03-23 13:24:40 +0000 |
---|---|---|
committer | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2022-04-09 21:00:48 +0200 |
commit | 8ca491cbf1a5cede5757ce15c7b5be30f7b26d68 (patch) | |
tree | 861720876f1174c039c2fdf738bb7b2eefba8e8c /src/ipa/ipu3/algorithms/af.cpp | |
parent | 2f7a52df95e64679c4d0f1b009ed354bbd067c5b (diff) |
ipa: ipu3: af: Simplify accumulations of y_items
Simplify the accumulation of the total and variance with a ternary
operator.
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Tested-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Tested-by: Kate Hsuan <hpa@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/ipa/ipu3/algorithms/af.cpp')
-rw-r--r-- | src/ipa/ipu3/algorithms/af.cpp | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp index f243aceb..addf98af 100644 --- a/src/ipa/ipu3/algorithms/af.cpp +++ b/src/ipa/ipu3/algorithms/af.cpp @@ -360,20 +360,14 @@ double Af::afEstimateVariance(Span<const y_table_item_t> y_items, bool isY1) double mean; double var_sum = 0; - for (auto y : y_items) { - if (isY1) - total += y.y1_avg; - else - total += y.y2_avg; - } + for (auto y : y_items) + total += isY1 ? y.y1_avg : y.y2_avg; mean = total / y_items.size(); for (auto y : y_items) { - if (isY1) - var_sum += pow(y.y1_avg - mean, 2); - else - var_sum += pow(y.y2_avg - mean, 2); + double avg = isY1 ? y.y1_avg : y.y2_avg; + var_sum += pow(avg - mean, 2); } return var_sum / y_items.size(); |