From c72515c2944be48b106d1181dab580b16bea667e Mon Sep 17 00:00:00 2001 From: Joana Niermann <53186085+niermann999@users.noreply.github.com> Date: Thu, 19 Dec 2024 12:47:14 +0000 Subject: [PATCH] fix: Zero init (#143) Explicitly initialize every element in array matrix --- math/cmath/include/algebra/math/impl/cmath_matrix.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/math/cmath/include/algebra/math/impl/cmath_matrix.hpp b/math/cmath/include/algebra/math/impl/cmath_matrix.hpp index 796569be..585fd01c 100644 --- a/math/cmath/include/algebra/math/impl/cmath_matrix.hpp +++ b/math/cmath/include/algebra/math/impl/cmath_matrix.hpp @@ -19,7 +19,15 @@ namespace algebra::cmath { template requires(std::is_scalar_v) ALGEBRA_HOST_DEVICE inline matrix_t zero() { - return matrix_t{}; + matrix_t ret; + + for (std::size_t j = 0; j < algebra::traits::columns; ++j) { + for (std::size_t i = 0; i < algebra::traits::rows; ++i) { + ret[j][i] = 0; + } + } + + return ret; } /// @returns identity matrix of type @tparam matrix_t