#ifndef PYTHONIC_NUMPY_MEAN_HPP #define PYTHONIC_NUMPY_MEAN_HPP #include "pythonic/include/numpy/mean.hpp" #include "pythonic/utils/functor.hpp" #include "pythonic/numpy/asarray.hpp" #include "pythonic/numpy/expand_dims.hpp" #include "pythonic/numpy/sum.hpp" #include "pythonic/builtins/None.hpp" PYTHONIC_NS_BEGIN namespace numpy { template auto mean(E const &expr, types::none_type axis, dtype d, types::none_type out, types::false_immediate keepdims) -> decltype(sum(expr, axis, d) / details::dtype_or_double(expr.flat_size())) { return sum(expr, axis, d) / details::dtype_or_double(expr.flat_size()); } template auto mean(E const &expr, long axis, dtype d, types::none_type out, types::false_immediate keepdims) -> decltype(sum(expr, axis, d)) { return sum(expr, axis, d) /= details::dtype_or_double(sutils::getshape(expr)[axis]); } template types::ndarray, typename details::make_scalar_pshape::type> mean(E const &expr, types::none_type axis, dtype d, types::none_type out, types::true_immediate keep_dims) { return {typename details::make_scalar_pshape::type(), mean(expr, axis, d, out)}; } template auto mean(E const &expr, long axis, dtype d, types::none_type out, types::true_immediate keepdims) -> decltype(expand_dims(mean(expr, axis, d), axis)) { return expand_dims(mean(expr, axis, d), axis); } } PYTHONIC_NS_END #endif