Skip to content

Commit

Permalink
fix: Zero init (#143)
Browse files Browse the repository at this point in the history
Explicitly initialize every element in array matrix
  • Loading branch information
niermann999 authored Dec 19, 2024
1 parent d9eca07 commit c72515c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion math/cmath/include/algebra/math/impl/cmath_matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ namespace algebra::cmath {
template <concepts::matrix matrix_t>
requires(std::is_scalar_v<typename matrix_t::value_type::value_type>)
ALGEBRA_HOST_DEVICE inline matrix_t zero() {
return matrix_t{};
matrix_t ret;

for (std::size_t j = 0; j < algebra::traits::columns<matrix_t>; ++j) {
for (std::size_t i = 0; i < algebra::traits::rows<matrix_t>; ++i) {
ret[j][i] = 0;
}
}

return ret;
}

/// @returns identity matrix of type @tparam matrix_t
Expand Down

0 comments on commit c72515c

Please sign in to comment.