Skip to content

Commit

Permalink
Zero-intialization made explicit in Tensor::add_to.
Browse files Browse the repository at this point in the history
  • Loading branch information
bimalgaudel committed Jan 15, 2024
1 parent 6b78a63 commit 21d6a7a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/TiledArray/tensor/tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,11 @@ class Tensor {
template <typename Right,
typename std::enable_if<is_tensor<Right>::value>::type* = nullptr>
Tensor& add_to(const Right& right) {
if (empty()) *this = Tensor{right.range()};
if (empty()) {
*this = Tensor{right.range()};
if constexpr (detail::is_numeric_v<value_type>)
std::fill(begin(), end(), value_type{0});
}
return inplace_binary(right, [](value_type& MADNESS_RESTRICT l,
const value_t<Right> r) { l += r; });
}
Expand Down

0 comments on commit 21d6a7a

Please sign in to comment.