Scarab  v2.9.0
Project 8 C++ Utility Library
Classes | Namespaces | Macros | Typedefs | Enumerations | Functions | Variables
numpy.h File Reference
#include "pybind11.h"
#include "complex.h"
#include <numeric>
#include <algorithm>
#include <array>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <string>
#include <functional>
#include <utility>
#include <vector>
#include <typeindex>
Include dependency graph for numpy.h:

Go to the source code of this file.

Classes

struct  npy_format_descriptor< T, SFINAE >
 
struct  PyArrayDescr_Proxy
 
struct  PyArray_Proxy
 
struct  PyVoidScalarObject_Proxy
 
struct  numpy_type_info
 
struct  numpy_internals
 
struct  same_size< T >
 
struct  npy_api
 
struct  npy_api::PyArray_Dims
 
struct  is_std_array< T >
 
struct  is_std_array< std::array< T, N > >
 
struct  is_complex< T >
 
struct  is_complex< std::complex< T > >
 
struct  array_info_scalar< T >
 
struct  array_info< T >
 
struct  array_info< std::array< T, N > >
 
struct  array_info< char[N]>
 
struct  array_info< std::array< char, N > >
 
struct  array_info< T[N]>
 
class  unchecked_reference< T, Dims >
 
class  unchecked_mutable_reference< T, Dims >
 
struct  type_caster< unchecked_reference< T, Dim > >
 
struct  type_caster< unchecked_mutable_reference< T, Dim > >
 
class  dtype
 
class  array
 
class  array_t< T, ExtraFlags >
 
struct  array_t< T, ExtraFlags >::private_ctor
 
struct  format_descriptor< T, detail::enable_if_t< detail::is_pod_struct< T >::value > >
 
struct  format_descriptor< char[N]>
 
struct  format_descriptor< std::array< char, N > >
 
struct  format_descriptor< T, detail::enable_if_t< std::is_enum< T >::value > >
 
struct  format_descriptor< T, detail::enable_if_t< detail::array_info< T >::is_array > >
 
struct  pyobject_caster< array_t< T, ExtraFlags > >
 
struct  compare_buffer_info< T, detail::enable_if_t< detail::is_pod_struct< T >::value > >
 
struct  npy_format_descriptor_name< T, typename >
 
struct  npy_format_descriptor_name< T, enable_if_t< std::is_integral< T >::value > >
 
struct  npy_format_descriptor_name< T, enable_if_t< std::is_floating_point< T >::value > >
 
struct  npy_format_descriptor_name< T, enable_if_t< is_complex< T >::value > >
 
struct  npy_format_descriptor< T, enable_if_t< satisfies_any_of< T, std::is_arithmetic, is_complex >::value > >
 
struct  npy_format_descriptor< char[N]>
 
struct  npy_format_descriptor< std::array< char, N > >
 
struct  npy_format_descriptor< T, enable_if_t< array_info< T >::is_array > >
 
struct  npy_format_descriptor< T, enable_if_t< std::is_enum< T >::value > >
 
struct  field_descriptor
 
struct  npy_format_descriptor< T, SFINAE >
 
class  common_iterator
 
class  multi_array_iterator< N >
 
struct  vectorize_arg< T >
 
struct  vectorize_helper< Func, Return, Args >
 
struct  handle_type_name< array_t< T, Flags > >
 

Namespaces

 pybind11
 glibc defines I as a macro which breaks things, e.g., boost template names
 
 pybind11::detail
 

Macros

#define DECL_NPY_API(Func)   api.Func##_ = (decltype(api.Func##_)) api_ptr[API_##Func];
 
#define PYBIND11_DECL_CHAR_FMT
 
#define PYBIND11_FIELD_DESCRIPTOR_EX(T, Field, Name)
 
#define PYBIND11_FIELD_DESCRIPTOR(T, Field)   PYBIND11_FIELD_DESCRIPTOR_EX(T, Field, #Field)
 
#define PYBIND11_EVAL0(...)   __VA_ARGS__
 
#define PYBIND11_EVAL1(...)   PYBIND11_EVAL0 (PYBIND11_EVAL0 (PYBIND11_EVAL0 (__VA_ARGS__)))
 
#define PYBIND11_EVAL2(...)   PYBIND11_EVAL1 (PYBIND11_EVAL1 (PYBIND11_EVAL1 (__VA_ARGS__)))
 
#define PYBIND11_EVAL3(...)   PYBIND11_EVAL2 (PYBIND11_EVAL2 (PYBIND11_EVAL2 (__VA_ARGS__)))
 
#define PYBIND11_EVAL4(...)   PYBIND11_EVAL3 (PYBIND11_EVAL3 (PYBIND11_EVAL3 (__VA_ARGS__)))
 
#define PYBIND11_EVAL(...)   PYBIND11_EVAL4 (PYBIND11_EVAL4 (PYBIND11_EVAL4 (__VA_ARGS__)))
 
#define PYBIND11_MAP_END(...)
 
#define PYBIND11_MAP_OUT
 
#define PYBIND11_MAP_COMMA   ,
 
#define PYBIND11_MAP_GET_END()   0, PYBIND11_MAP_END
 
#define PYBIND11_MAP_NEXT0(test, next, ...)   next PYBIND11_MAP_OUT
 
#define PYBIND11_MAP_NEXT1(test, next)   PYBIND11_MAP_NEXT0 (test, next, 0)
 
#define PYBIND11_MAP_NEXT(test, next)   PYBIND11_MAP_NEXT1 (PYBIND11_MAP_GET_END test, next)
 
#define PYBIND11_MAP_LIST_NEXT1(test, next)   PYBIND11_MAP_NEXT0 (test, PYBIND11_MAP_COMMA next, 0)
 
#define PYBIND11_MAP_LIST_NEXT(test, next)   PYBIND11_MAP_LIST_NEXT1 (PYBIND11_MAP_GET_END test, next)
 
#define PYBIND11_MAP_LIST0(f, t, x, peek, ...)   f(t, x) PYBIND11_MAP_LIST_NEXT (peek, PYBIND11_MAP_LIST1) (f, t, peek, __VA_ARGS__)
 
#define PYBIND11_MAP_LIST1(f, t, x, peek, ...)   f(t, x) PYBIND11_MAP_LIST_NEXT (peek, PYBIND11_MAP_LIST0) (f, t, peek, __VA_ARGS__)
 
#define PYBIND11_MAP_LIST(f, t, ...)   PYBIND11_EVAL (PYBIND11_MAP_LIST1 (f, t, __VA_ARGS__, (), 0))
 
#define PYBIND11_NUMPY_DTYPE(Type, ...)
 
#define PYBIND11_MAP2_LIST_NEXT1(test, next)   PYBIND11_MAP_NEXT0 (test, PYBIND11_MAP_COMMA next, 0)
 
#define PYBIND11_MAP2_LIST_NEXT(test, next)   PYBIND11_MAP2_LIST_NEXT1 (PYBIND11_MAP_GET_END test, next)
 
#define PYBIND11_MAP2_LIST0(f, t, x1, x2, peek, ...)   f(t, x1, x2) PYBIND11_MAP2_LIST_NEXT (peek, PYBIND11_MAP2_LIST1) (f, t, peek, __VA_ARGS__)
 
#define PYBIND11_MAP2_LIST1(f, t, x1, x2, peek, ...)   f(t, x1, x2) PYBIND11_MAP2_LIST_NEXT (peek, PYBIND11_MAP2_LIST0) (f, t, peek, __VA_ARGS__)
 
#define PYBIND11_MAP2_LIST(f, t, ...)   PYBIND11_EVAL (PYBIND11_MAP2_LIST1 (f, t, __VA_ARGS__, (), 0))
 
#define PYBIND11_NUMPY_DTYPE_EX(Type, ...)
 

Typedefs

template<typename T >
using remove_all_extents_t = typename array_info< T >::type
 
template<typename T >
using is_pod_struct = all_of< std::is_standard_layout< T >, std::is_trivially_copyable< T >, satisfies_none_of< T, std::is_reference, std::is_array, is_std_array, std::is_arithmetic, is_complex, std::is_enum > >
 
template<class T >
using array_iterator = typename std::add_pointer< T >::type
 

Enumerations

enum  broadcast_trivial { non_trivial, c_trivial, f_trivial }
 

Functions

 __attribute__ ((noinline)) inline internals &get_internals()
 Return a reference to the current internals data. More...
 
numpy_internals & get_numpy_internals ()
 
template<typename Concrete , typename... Check, typename... Int>
constexpr int platform_lookup (Int... codes)
 
PyArray_Proxy * array_proxy (void *ptr)
 
const PyArray_Proxy * array_proxy (const void *ptr)
 
PyArrayDescr_Proxy * array_descriptor_proxy (PyObject *ptr)
 
const PyArrayDescr_Proxy * array_descriptor_proxy (const PyObject *ptr)
 
bool check_flags (const void *ptr, int flag)
 
template<ssize_t Dim = 0, typename Strides >
ssize_t byte_offset_unsafe (const Strides &)
 
template<ssize_t Dim = 0, typename Strides , typename... Ix>
ssize_t byte_offset_unsafe (const Strides &strides, ssize_t i, Ix... index)
 
 __attribute__ ((noinline)) inline detail
 Return the type info for a given C++ type; on lookup failure can either throw or return nullptr. More...
 
template<class T >
array_iterator< T > array_begin (const buffer_info &buffer)
 
template<class T >
array_iterator< T > array_end (const buffer_info &buffer)
 
template<size_t N>
broadcast_trivial broadcast (const std::array< buffer_info, N > &buffers, ssize_t &ndim, std::vector< ssize_t > &shape)
 
template<typename Func , typename Return , typename... Args>
vectorize_helper< Func, Return, Args... > vectorize_extractor (const Func &f, Return(*)(Args ...))
 
template<typename Return , typename... Args>
detail::vectorize_helper< Return(*)(Args...), Return, Args... > vectorize (Return(*f)(Args ...))
 
template<typename Func , detail::enable_if_t< detail::is_lambda< Func >::value, int > = 0>
auto vectorize (Func &&f) -> decltype(detail::vectorize_extractor(std::forward< Func >(f),(detail::function_signature_t< Func > *) nullptr))
 
template<typename Return , typename Class , typename... Args, typename Helper = detail::vectorize_helper<decltype(std::mem_fn(std::declval<Return (Class::*)(Args...)>())), Return, Class *, Args...>>
Helper vectorize (Return(Class::*f)(Args...))
 

Variables

const std::type_info & tinfo
 
const std::type_info ssize_t itemsize
 
const std::type_info ssize_t bool(* direct_converter )(PyObject *, void *&))
 

Macro Definition Documentation

◆ DECL_NPY_API

#define DECL_NPY_API (   Func)    api.Func##_ = (decltype(api.Func##_)) api_ptr[API_##Func];

◆ PYBIND11_DECL_CHAR_FMT

#define PYBIND11_DECL_CHAR_FMT
Value:
static constexpr auto name = _("S") + _<N>(); \
static pybind11::dtype dtype() { return pybind11::dtype(std::string("S") + std::to_string(N)); }
constexpr descr< N - 1 > _(char const(&text)[N])
Definition: descr.h:54
auto to_string(T &&value) -> decltype(std::forward< T >(value))
Convert an object to a string (directly forward if this can become a string)
Definition: CLI11.hpp:1028

Definition at line 1052 of file numpy.h.

◆ PYBIND11_EVAL

#define PYBIND11_EVAL (   ...)    PYBIND11_EVAL4 (PYBIND11_EVAL4 (PYBIND11_EVAL4 (__VA_ARGS__)))

Definition at line 1213 of file numpy.h.

◆ PYBIND11_EVAL0

#define PYBIND11_EVAL0 (   ...)    __VA_ARGS__

Definition at line 1208 of file numpy.h.

◆ PYBIND11_EVAL1

#define PYBIND11_EVAL1 (   ...)    PYBIND11_EVAL0 (PYBIND11_EVAL0 (PYBIND11_EVAL0 (__VA_ARGS__)))

Definition at line 1209 of file numpy.h.

◆ PYBIND11_EVAL2

#define PYBIND11_EVAL2 (   ...)    PYBIND11_EVAL1 (PYBIND11_EVAL1 (PYBIND11_EVAL1 (__VA_ARGS__)))

Definition at line 1210 of file numpy.h.

◆ PYBIND11_EVAL3

#define PYBIND11_EVAL3 (   ...)    PYBIND11_EVAL2 (PYBIND11_EVAL2 (PYBIND11_EVAL2 (__VA_ARGS__)))

Definition at line 1211 of file numpy.h.

◆ PYBIND11_EVAL4

#define PYBIND11_EVAL4 (   ...)    PYBIND11_EVAL3 (PYBIND11_EVAL3 (PYBIND11_EVAL3 (__VA_ARGS__)))

Definition at line 1212 of file numpy.h.

◆ PYBIND11_FIELD_DESCRIPTOR

#define PYBIND11_FIELD_DESCRIPTOR (   T,
  Field 
)    PYBIND11_FIELD_DESCRIPTOR_EX(T, Field, #Field)

Definition at line 1204 of file numpy.h.

◆ PYBIND11_FIELD_DESCRIPTOR_EX

#define PYBIND11_FIELD_DESCRIPTOR_EX (   T,
  Field,
  Name 
)
Value:
Name, offsetof(T, Field), sizeof(decltype(std::declval<T>().Field)), \
::pybind11::format_descriptor<decltype(std::declval<T>().Field)>::format(), \
}
auto format(const std::locale &loc, const CharT *fmt, const Streamable &tp) -> decltype(to_stream(std::declval< std::basic_ostream< CharT > &>(), fmt, tp), std::basic_string< CharT >
Definition: date.h:5663

Definition at line 1196 of file numpy.h.

◆ PYBIND11_MAP2_LIST

#define PYBIND11_MAP2_LIST (   f,
  t,
  ... 
)    PYBIND11_EVAL (PYBIND11_MAP2_LIST1 (f, t, __VA_ARGS__, (), 0))

Definition at line 1257 of file numpy.h.

◆ PYBIND11_MAP2_LIST0

#define PYBIND11_MAP2_LIST0 (   f,
  t,
  x1,
  x2,
  peek,
  ... 
)    f(t, x1, x2) PYBIND11_MAP2_LIST_NEXT (peek, PYBIND11_MAP2_LIST1) (f, t, peek, __VA_ARGS__)

Definition at line 1252 of file numpy.h.

◆ PYBIND11_MAP2_LIST1

#define PYBIND11_MAP2_LIST1 (   f,
  t,
  x1,
  x2,
  peek,
  ... 
)    f(t, x1, x2) PYBIND11_MAP2_LIST_NEXT (peek, PYBIND11_MAP2_LIST0) (f, t, peek, __VA_ARGS__)

Definition at line 1254 of file numpy.h.

◆ PYBIND11_MAP2_LIST_NEXT

#define PYBIND11_MAP2_LIST_NEXT (   test,
  next 
)    PYBIND11_MAP2_LIST_NEXT1 (PYBIND11_MAP_GET_END test, next)

Definition at line 1250 of file numpy.h.

◆ PYBIND11_MAP2_LIST_NEXT1

#define PYBIND11_MAP2_LIST_NEXT1 (   test,
  next 
)    PYBIND11_MAP_NEXT0 (test, PYBIND11_MAP_COMMA next, 0)

Definition at line 1247 of file numpy.h.

◆ PYBIND11_MAP_COMMA

#define PYBIND11_MAP_COMMA   ,

Definition at line 1216 of file numpy.h.

◆ PYBIND11_MAP_END

#define PYBIND11_MAP_END (   ...)

Definition at line 1214 of file numpy.h.

◆ PYBIND11_MAP_GET_END

#define PYBIND11_MAP_GET_END ( )    0, PYBIND11_MAP_END

Definition at line 1217 of file numpy.h.

◆ PYBIND11_MAP_LIST

#define PYBIND11_MAP_LIST (   f,
  t,
  ... 
)    PYBIND11_EVAL (PYBIND11_MAP_LIST1 (f, t, __VA_ARGS__, (), 0))

Definition at line 1235 of file numpy.h.

◆ PYBIND11_MAP_LIST0

#define PYBIND11_MAP_LIST0 (   f,
  t,
  x,
  peek,
  ... 
)    f(t, x) PYBIND11_MAP_LIST_NEXT (peek, PYBIND11_MAP_LIST1) (f, t, peek, __VA_ARGS__)

Definition at line 1230 of file numpy.h.

◆ PYBIND11_MAP_LIST1

#define PYBIND11_MAP_LIST1 (   f,
  t,
  x,
  peek,
  ... 
)    f(t, x) PYBIND11_MAP_LIST_NEXT (peek, PYBIND11_MAP_LIST0) (f, t, peek, __VA_ARGS__)

Definition at line 1232 of file numpy.h.

◆ PYBIND11_MAP_LIST_NEXT

#define PYBIND11_MAP_LIST_NEXT (   test,
  next 
)    PYBIND11_MAP_LIST_NEXT1 (PYBIND11_MAP_GET_END test, next)

Definition at line 1228 of file numpy.h.

◆ PYBIND11_MAP_LIST_NEXT1

#define PYBIND11_MAP_LIST_NEXT1 (   test,
  next 
)    PYBIND11_MAP_NEXT0 (test, PYBIND11_MAP_COMMA next, 0)

Definition at line 1225 of file numpy.h.

◆ PYBIND11_MAP_NEXT

#define PYBIND11_MAP_NEXT (   test,
  next 
)    PYBIND11_MAP_NEXT1 (PYBIND11_MAP_GET_END test, next)

Definition at line 1220 of file numpy.h.

◆ PYBIND11_MAP_NEXT0

#define PYBIND11_MAP_NEXT0 (   test,
  next,
  ... 
)    next PYBIND11_MAP_OUT

Definition at line 1218 of file numpy.h.

◆ PYBIND11_MAP_NEXT1

#define PYBIND11_MAP_NEXT1 (   test,
  next 
)    PYBIND11_MAP_NEXT0 (test, next, 0)

Definition at line 1219 of file numpy.h.

◆ PYBIND11_MAP_OUT

#define PYBIND11_MAP_OUT

Definition at line 1215 of file numpy.h.

◆ PYBIND11_NUMPY_DTYPE

#define PYBIND11_NUMPY_DTYPE (   Type,
  ... 
)
Value:
(::std::vector<::pybind11::detail::field_descriptor> \
#define PYBIND11_FIELD_DESCRIPTOR(T, Field)
Definition: numpy.h:1204
#define PYBIND11_MAP_LIST(f, t,...)
Definition: numpy.h:1235

Definition at line 1238 of file numpy.h.

◆ PYBIND11_NUMPY_DTYPE_EX

#define PYBIND11_NUMPY_DTYPE_EX (   Type,
  ... 
)
Value:
(::std::vector<::pybind11::detail::field_descriptor> \
#define PYBIND11_FIELD_DESCRIPTOR_EX(T, Field, Name)
Definition: numpy.h:1196
#define PYBIND11_MAP2_LIST(f, t,...)
Definition: numpy.h:1257

Definition at line 1260 of file numpy.h.