#ifndef PYTHONIC_INCLUDE_NUMPY_REDUCE_HPP #define PYTHONIC_INCLUDE_NUMPY_REDUCE_HPP #include "pythonic/include/types/ndarray.hpp" #include "pythonic/include/builtins/None.hpp" #include PYTHONIC_NS_BEGIN namespace operator_ { namespace functor { struct imax; struct imin; } } namespace numpy { namespace { template struct reduce_result_type_helper { using type = typename T::type; }; template struct reduce_result_type_helper { using type = typename std::conditional< std::is_integral::type>::value && (sizeof(typename types::dtype_of::type) < sizeof(long)) && !std::is_same::value && !std::is_same::value, typename std::conditional< std::is_same::type, bool>::value, long, typename std::conditional< std::is_signed::type>::value, long, unsigned long>::type>::type, typename types::dtype_of::type>::type; }; template using reduce_result_type = typename reduce_result_type_helper::type; } template typename std::enable_if< std::is_scalar::value || types::is_complex::value, E>::type reduce(E const &expr, types::none_type _ = types::none_type()); template typename std::enable_if< std::is_scalar::value || types::is_complex::value, E>::type reduce(E const &array, long axis); template typename std::enable_if::value, reduce_result_type>::type reduce(E const &expr, types::none_type axis = {}, dtype d = {}); template reduce_result_type reduce(types::numpy_texpr const &expr, types::none_type axis = {}, dtype d = {}) { return reduce(expr.arg, axis, d); } template typename std::enable_if>::type reduce(E const &array, long axis, dtype d = {}, types::none_type out = {}); template typename std::enable_if>::type reduce(E const &array, long axis, types::none_type dtype, Out &&out); namespace { template using reduced_type = types::ndarray, types::array>; } template typename std::enable_if>::type reduce(E const &array, long axis, dtype d = {}, types::none_type out = types::none_type()); template reduced_type reduce(types::numpy_texpr const &array, long axis, types::none_type dtype = types::none_type(), types::none_type out = types::none_type()) { return reduce(array.arg, (axis + 1) % 2); } template typename std::enable_if>::type reduce(E const &array, long axis, types::none_type dtype, Out &&out); } PYTHONIC_NS_END #endif