Skip to content

Commit

Permalink
Addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
spectre-ns committed Nov 16, 2023
1 parent d0506d8 commit 444dbe5
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions include/xtensor/xstrided_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,27 +827,24 @@ namespace xt
template <
class S,
std::enable_if_t<std::is_signed<get_value_type_t<typename std::decay<S>::type>>::value, bool> = true>
inline auto recalculate_shape_impl(S& shape, size_t size)
inline void recalculate_shape_impl(S& shape, size_t size)
{
using value_type = get_value_type_t<typename std::decay_t<S>>;
const auto num_auto_dims = std::count(shape.cbegin(), shape.cend(), -1);
XTENSOR_ASSERT(num_auto_dims <= 1);
XTENSOR_ASSERT(std::count(shape.cbegin(), shape.cend(), -1) <= 1);
auto iter = std::find(shape.begin(), shape.end(), -1);
if (iter != std::end(shape))
{
const auto total = std::accumulate(shape.cbegin(), shape.cend(), -1, std::multiplies<int>{});
const auto missing_dimension = size / total;
(*iter) = static_cast<value_type>(missing_dimension);
}
return shape;
}

template <
class S,
std::enable_if_t<!std::is_signed<get_value_type_t<typename std::decay<S>::type>>::value, bool> = true>
inline auto recalculate_shape_impl(S& shape, size_t)
inline void recalculate_shape_impl(S&, size_t)
{
return shape;
}

template <class S>
Expand Down

0 comments on commit 444dbe5

Please sign in to comment.