From 623eb2915d5df5ce065e070aef3a55ba28e7d2a7 Mon Sep 17 00:00:00 2001 From: conrad Date: Tue, 20 May 2025 22:27:38 +1000 Subject: [PATCH] take into account possible inf and nan --- include/armadillo_bits/fn_accu.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/armadillo_bits/fn_accu.hpp b/include/armadillo_bits/fn_accu.hpp index 9886652e..f3dd4cd5 100644 --- a/include/armadillo_bits/fn_accu.hpp +++ b/include/armadillo_bits/fn_accu.hpp @@ -1162,10 +1162,14 @@ accu(const SpGlue& expr) if((x_it_col < y_it_col) || ((x_it_col == y_it_col) && (x_it_row < y_it_row))) // if y is closer to the end { + acc += (*x_it) * eT(0); // in case (*x_it) is inf or nan + ++x_it; } else // x is closer to the end { + acc += eT(0) * (*y_it); // in case (*y_it) is inf or nan + ++y_it; } }