30#ifdef NUMCPP_INCLUDE_PYBIND_PYTHON_INTERFACE
32#include "pybind11/numpy.h"
33#include "pybind11/pybind11.h"
53 static const std::map<ReturnPolicy, std::string>
returnPolicyStringMap = { { ReturnPolicy::COPY,
"COPY" },
54 { ReturnPolicy::REFERENCE,
"REFERENCE" },
55 { ReturnPolicy::TAKE_OWNERSHIP,
58 template<
typename dtype>
59 using pbArray = pybind11::array_t<dtype, pybind11::array::c_style>;
70 template<
typename dtype>
107 template<
typename dtype>
143 template<
typename dtype>
147 const std::vector<pybind11::ssize_t>
shape{
static_cast<pybind11::ssize_t
>(
inShape.rows),
148 static_cast<pybind11::ssize_t
>(
inShape.cols) };
149 const std::vector<pybind11::ssize_t>
strides{
static_cast<pybind11::ssize_t
>(
inShape.cols *
sizeof(
dtype)),
150 static_cast<pybind11::ssize_t
>(
sizeof(
dtype)) };
162 template<
typename dtype>
166 const std::vector<pybind11::ssize_t>
shape{
static_cast<pybind11::ssize_t
>(
inShape.rows),
167 static_cast<pybind11::ssize_t
>(
inShape.cols) };
168 const std::vector<pybind11::ssize_t>
strides{
static_cast<pybind11::ssize_t
>(
inShape.cols *
sizeof(
dtype)),
169 static_cast<pybind11::ssize_t
>(
sizeof(
dtype)) };
173 case ReturnPolicy::COPY:
177 case ReturnPolicy::REFERENCE:
179 typename pybind11::capsule reference(
inArray.data(), [](
void* ) {});
182 case ReturnPolicy::TAKE_OWNERSHIP:
187 auto* dataPtr = reinterpret_cast<dtype*>(ptr);
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition Error.hpp:37
uint32 size(const NdArray< dtype > &inArray) noexcept
Definition size.hpp:43
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition arange.hpp:59
Shape shape(const NdArray< dtype > &inArray) noexcept
Definition Functions/shape.hpp:42
std::uint32_t uint32
Definition Types.hpp:40