示例#1
0
 types::ndarray<typename types::numpy_type<dtype>::type, N>
 zeros(types::array<long, N> const &shape, dtype d)
 {
   using T = typename types::numpy_type<dtype>::type;
   // use calloc even if we have a non integer type. This looks ok on modern
   // architecture, although not really standard
   T *buffer = (T *)calloc(std::accumulate(shape.begin(), shape.end(), 1L,
                                           std::multiplies<long>()),
                           sizeof(T));
   return types::ndarray<T, N>{buffer, shape.data()};
 }