 |
NumCpp
2.4.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
|
Go to the documentation of this file.
30 #if defined(INCLUDE_BOOST_PYTHON_INTERFACE) && !defined(NO_USE_BOOST)
37 #include "boost/python.hpp"
38 #include "boost/python/numpy.hpp"
45 namespace boostPythonInterface
54 template<
typename dtype>
72 returnArray[i] = helper(i);
82 for (
uint32 row = 0; row < arrayShape.
rows; ++row)
84 for (
uint32 col = 0; col < arrayShape.
cols; ++col)
86 returnArray(row, col) = helper(row, col);
100 template<
typename dtype>
104 boost::python::tuple
shape = boost::python::make_tuple(inShape.
rows, inShape.
cols);
107 for (
uint32 row = 0; row < inShape.
rows; ++row)
109 for (
uint32 col = 0; col < inShape.
cols; ++col)
111 newNdArrayHelper(row, col) = inArray(row, col);
125 inline std::vector<T>
list2vector(
const boost::python::list& inList)
127 return std::vector<T>(boost::python::stl_input_iterator<T>(inList), boost::python::stl_input_iterator<T>());
137 template <
typename T>
140 boost::python::list outList;
141 for (
auto& value : inVector)
143 outList.append(value);
156 template <
class Key,
class Value>
157 inline boost::python::dict
map2dict(
const std::map<Key, Value>& inMap)
159 boost::python::dict dictionary;
160 for (
auto& keyValue : inMap)
162 dictionary[keyValue.first] = keyValue.second;
169 #endif // #if defined(INCLUDE_BOOST_PYTHON_INTERFACE) && !defined(NO_USE_BOOST)
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4356
Shape shape(const NdArray< dtype > &inArray) noexcept
Definition: Functions/Shape.hpp:44
std::vector< T > list2vector(const boost::python::list &inList)
Definition: BoostInterface.hpp:125
NdArray< dtype > boost2Nc(const boost::python::numpy::ndarray &inArray)
Definition: BoostInterface.hpp:55
const std::vector< Py_intptr_t > & shape() noexcept
Definition: BoostNumpyNdarrayHelper.hpp:147
std::uint32_t uint32
Definition: Types.hpp:40
const boost::python::numpy::ndarray & getArray() noexcept
Definition: BoostNumpyNdarrayHelper.hpp:117
A Shape Class for NdArrays.
Definition: Core/Shape.hpp:40
uint32 cols
Definition: Core/Shape.hpp:45
uint32 size() const noexcept
Definition: Core/Shape.hpp:102
boost::python::list vector2list(std::vector< T > &inVector)
Definition: BoostInterface.hpp:138
Helper class for ndarray.
Definition: BoostNumpyNdarrayHelper.hpp:52
boost::python::dict map2dict(const std::map< Key, Value > &inMap)
Definition: BoostInterface.hpp:157
#define THROW_RUNTIME_ERROR(msg)
Definition: Error.hpp:37
Definition: Coordinate.hpp:44
uint32 rows
Definition: Core/Shape.hpp:44
uint8 numDimensions() noexcept
Definition: BoostNumpyNdarrayHelper.hpp:137
boost::python::numpy::ndarray nc2Boost(const NdArray< dtype > &inArray)
Definition: BoostInterface.hpp:101