#ifndef PYTHONIC_NUMPY_ZEROS_HPP #define PYTHONIC_NUMPY_ZEROS_HPP #include "pythonic/include/numpy/zeros.hpp" #include "pythonic/utils/functor.hpp" #include "pythonic/types/ndarray.hpp" PYTHONIC_NS_BEGIN namespace numpy { template types::ndarray> zeros(pS const &shape, dtype d) { using T = typename dtype::type; // use calloc even if we have a non integer type. This looks ok on modern // architecture, although not really standard auto *buffer = (T *)calloc(sutils::sprod(shape), sizeof(T)); return {buffer, (sutils::shape_t)shape, types::ownership::owned}; } template types::ndarray> zeros(long size, dtype d) { return zeros(types::pshape(size), d); } template types::ndarray>> zeros(std::integral_constant, dtype d) { return zeros(types::pshape>({}), d); } } PYTHONIC_NS_END #endif