Classes | Macros | Typedefs | Enumerations | Functions
numpy.h File Reference
#include "pybind11.h"
#include "complex.h"
#include <algorithm>
#include <array>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <sstream>
#include <string>
#include <type_traits>
#include <typeindex>
#include <utility>
#include <vector>
Include dependency graph for numpy.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

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

Macros

#define DECL_NPY_API(Func)   api.Func##_ = (decltype(api.Func##_)) api_ptr[API_##Func];
 
#define PYBIND11_DECL_CHAR_FMT
 
#define PYBIND11_EVAL(...)   PYBIND11_EVAL4(PYBIND11_EVAL4(PYBIND11_EVAL4(__VA_ARGS__)))
 
#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_FIELD_DESCRIPTOR(T, Field)   PYBIND11_FIELD_DESCRIPTOR_EX(T, Field, #Field)
 
#define PYBIND11_FIELD_DESCRIPTOR_EX(T, Field, Name)
 
#define PYBIND11_MAP2_LIST(f, t, ...)   PYBIND11_EVAL(PYBIND11_MAP2_LIST1(f, t, __VA_ARGS__, (), 0))
 
#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_NEXT(test, next)   PYBIND11_MAP2_LIST_NEXT1(PYBIND11_MAP_GET_END test, next)
 
#define PYBIND11_MAP2_LIST_NEXT1(test, next)   PYBIND11_MAP_NEXT0(test, PYBIND11_MAP_COMMA next, 0)
 
#define PYBIND11_MAP_COMMA   ,
 
#define PYBIND11_MAP_END(...)
 
#define PYBIND11_MAP_GET_END()   0, PYBIND11_MAP_END
 
#define PYBIND11_MAP_LIST(f, t, ...)   PYBIND11_EVAL(PYBIND11_MAP_LIST1(f, t, __VA_ARGS__, (), 0))
 
#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_NEXT(test, next)   PYBIND11_MAP_LIST_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_NEXT(test, next)   PYBIND11_MAP_NEXT1(PYBIND11_MAP_GET_END test, next)
 
#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_OUT
 
#define PYBIND11_NUMPY_DTYPE(Type, ...)
 
#define PYBIND11_NUMPY_DTYPE_EX(Type, ...)
 

Typedefs

template<typename T >
using is_pod = all_of< std::is_standard_layout< T >, std::is_trivial< T > >
 
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<typename T >
using remove_all_extents_t = typename array_info< T >::type
 

Enumerations

enum  broadcast_trivial { broadcast_trivial::non_trivial, broadcast_trivial::c_trivial, broadcast_trivial::f_trivial }
 

Functions

const PyArrayDescr_Proxyarray_descriptor_proxy (const PyObject *ptr)
 
PyArrayDescr_Proxyarray_descriptor_proxy (PyObject *ptr)
 
const PyArray_Proxyarray_proxy (const void *ptr)
 
PyArray_Proxyarray_proxy (void *ptr)
 
template<size_t N>
broadcast_trivial broadcast (const std::array< buffer_info, N > &buffers, ssize_t &ndim, std::vector< ssize_t > &shape)
 
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)
 
bool check_flags (const void *ptr, int flag)
 
numpy_internalsget_numpy_internals ()
 
PYBIND11_NOINLINE void load_numpy_internals (numpy_internals *&ptr)
 
template<typename Concrete >
constexpr int platform_lookup ()
 
template<typename Concrete , typename T , typename... Ts, typename... Ints>
constexpr int platform_lookup (int I, Ints... Is)
 
PYBIND11_NOINLINE void register_structured_dtype (any_container< field_descriptor > fields, const std::type_info &tinfo, ssize_t itemsize, bool(*direct_converter)(PyObject *, void *&))
 
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... Args>
detail::vectorize_helper< Return(*)(Args...), Return, Args... > vectorize (Return(*f)(Args...))
 
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...))
 
template<typename Func , typename Return , typename... Args>
vectorize_helper< Func, Return, Args... > vectorize_extractor (const Func &f, Return(*)(Args...))
 

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 = const_name("S") + const_name<N>(); \
static pybind11::dtype dtype() { \
return pybind11::dtype(std::string("S") + std::to_string(N)); \
}

Definition at line 1300 of file numpy.h.

◆ PYBIND11_EVAL

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

Definition at line 1489 of file numpy.h.

◆ PYBIND11_EVAL0

#define PYBIND11_EVAL0 (   ...)    __VA_ARGS__

Definition at line 1484 of file numpy.h.

◆ PYBIND11_EVAL1

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

Definition at line 1485 of file numpy.h.

◆ PYBIND11_EVAL2

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

Definition at line 1486 of file numpy.h.

◆ PYBIND11_EVAL3

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

Definition at line 1487 of file numpy.h.

◆ PYBIND11_EVAL4

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

Definition at line 1488 of file numpy.h.

◆ PYBIND11_FIELD_DESCRIPTOR

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

Definition at line 1480 of file numpy.h.

◆ PYBIND11_FIELD_DESCRIPTOR_EX

#define PYBIND11_FIELD_DESCRIPTOR_EX (   T,
  Field,
  Name 
)
Value:
::pybind11::detail::field_descriptor { \
Name, offsetof(T, Field), sizeof(decltype(std::declval<T>().Field)), \
::pybind11::format_descriptor<decltype(std::declval<T>().Field)>::format(), \
::pybind11::detail::npy_format_descriptor< \
decltype(std::declval<T>().Field)>::dtype() \
}

Definition at line 1471 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 1534 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 1529 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 1531 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 1527 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 1524 of file numpy.h.

◆ PYBIND11_MAP_COMMA

#define PYBIND11_MAP_COMMA   ,

Definition at line 1492 of file numpy.h.

◆ PYBIND11_MAP_END

#define PYBIND11_MAP_END (   ...)

Definition at line 1490 of file numpy.h.

◆ PYBIND11_MAP_GET_END

#define PYBIND11_MAP_GET_END ( )    0, PYBIND11_MAP_END

Definition at line 1493 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 1512 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 1507 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 1509 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 1505 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 1502 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 1496 of file numpy.h.

◆ PYBIND11_MAP_NEXT0

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

Definition at line 1494 of file numpy.h.

◆ PYBIND11_MAP_NEXT1

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

Definition at line 1495 of file numpy.h.

◆ PYBIND11_MAP_OUT

#define PYBIND11_MAP_OUT

Definition at line 1491 of file numpy.h.

◆ PYBIND11_NUMPY_DTYPE

#define PYBIND11_NUMPY_DTYPE (   Type,
  ... 
)
Value:
::pybind11::detail::npy_format_descriptor<Type>::register_dtype( \
::std::vector<::pybind11::detail::field_descriptor>{ \
PYBIND11_MAP_LIST(PYBIND11_FIELD_DESCRIPTOR, Type, __VA_ARGS__)})

Definition at line 1515 of file numpy.h.

◆ PYBIND11_NUMPY_DTYPE_EX

#define PYBIND11_NUMPY_DTYPE_EX (   Type,
  ... 
)
Value:
::pybind11::detail::npy_format_descriptor<Type>::register_dtype( \
::std::vector<::pybind11::detail::field_descriptor>{ \
PYBIND11_MAP2_LIST(PYBIND11_FIELD_DESCRIPTOR_EX, Type, __VA_ARGS__)})

Definition at line 1537 of file numpy.h.

Typedef Documentation

◆ is_pod

template<typename T >
using is_pod = all_of<std::is_standard_layout<T>, std::is_trivial<T> >

Definition at line 390 of file numpy.h.

◆ is_pod_struct

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> >

Definition at line 386 of file numpy.h.

◆ remove_all_extents_t

template<typename T >
using remove_all_extents_t = typename array_info<T>::type

Definition at line 364 of file numpy.h.

Enumeration Type Documentation

◆ broadcast_trivial

enum broadcast_trivial
strong
Enumerator
non_trivial 
c_trivial 
f_trivial 

Definition at line 1647 of file numpy.h.

Function Documentation

◆ array_descriptor_proxy() [1/2]

const PyArrayDescr_Proxy* array_descriptor_proxy ( const PyObject *  ptr)
inline

Definition at line 309 of file numpy.h.

◆ array_descriptor_proxy() [2/2]

PyArrayDescr_Proxy* array_descriptor_proxy ( PyObject *  ptr)
inline

Definition at line 305 of file numpy.h.

◆ array_proxy() [1/2]

const PyArray_Proxy* array_proxy ( const void *  ptr)
inline

Definition at line 301 of file numpy.h.

◆ array_proxy() [2/2]

PyArray_Proxy* array_proxy ( void *  ptr)
inline

Definition at line 299 of file numpy.h.

◆ broadcast()

template<size_t N>
broadcast_trivial broadcast ( const std::array< buffer_info, N > &  buffers,
ssize_t ndim,
std::vector< ssize_t > &  shape 
)

Definition at line 1655 of file numpy.h.

◆ byte_offset_unsafe() [1/2]

template<ssize_t Dim = 0, typename Strides >
ssize_t byte_offset_unsafe ( const Strides &  )

Definition at line 393 of file numpy.h.

◆ byte_offset_unsafe() [2/2]

template<ssize_t Dim = 0, typename Strides , typename... Ix>
ssize_t byte_offset_unsafe ( const Strides &  strides,
ssize_t  i,
Ix...  index 
)

Definition at line 397 of file numpy.h.

◆ check_flags()

bool check_flags ( const void *  ptr,
int  flag 
)
inline

Definition at line 313 of file numpy.h.

◆ get_numpy_internals()

numpy_internals& get_numpy_internals ( )
inline

Definition at line 115 of file numpy.h.

◆ load_numpy_internals()

PYBIND11_NOINLINE void load_numpy_internals ( numpy_internals *&  ptr)

Definition at line 111 of file numpy.h.

◆ platform_lookup() [1/2]

template<typename Concrete >
constexpr int platform_lookup ( )
constexpr

Definition at line 130 of file numpy.h.

◆ platform_lookup() [2/2]

template<typename Concrete , typename T , typename... Ts, typename... Ints>
constexpr int platform_lookup ( int  I,
Ints...  Is 
)
constexpr

Definition at line 136 of file numpy.h.

◆ register_structured_dtype()

PYBIND11_NOINLINE void register_structured_dtype ( any_container< field_descriptor fields,
const std::type_info &  tinfo,
ssize_t  itemsize,
bool(*)(PyObject *, void *&)  direct_converter 
)

Definition at line 1351 of file numpy.h.

◆ vectorize() [1/3]

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))

Definition at line 1965 of file numpy.h.

◆ vectorize() [2/3]

template<typename Return , typename... Args>
detail::vectorize_helper<Return (*)(Args...), Return, Args...> vectorize ( Return(*)(Args...)  f)

Definition at line 1959 of file numpy.h.

◆ vectorize() [3/3]

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::*)(Args...)  f)

Definition at line 1981 of file numpy.h.

◆ vectorize_extractor()

template<typename Func , typename Return , typename... Args>
vectorize_helper<Func, Return, Args...> vectorize_extractor ( const Func &  f,
Return(*)(Args...)   
)

Definition at line 1945 of file numpy.h.

name
Annotation for function names.
Definition: attr.h:51
format
std::string format(const std::string &str, const std::vector< std::string > &find, const std::vector< std::string > &replace)
Definition: openglsupport.cpp:226
const_name
constexpr descr< N - 1 > const_name(char const (&text)[N])
Definition: descr.h:60
PYBIND11_FIELD_DESCRIPTOR_EX
#define PYBIND11_FIELD_DESCRIPTOR_EX(T, Field, Name)
Definition: numpy.h:1471
Eigen::Architecture::Type
Type
Definition: Constants.h:471
Eigen::Triplet< double >
PYBIND11_FIELD_DESCRIPTOR
#define PYBIND11_FIELD_DESCRIPTOR(T, Field)
Definition: numpy.h:1480
test_eigen_tensor.dtype
dtype
Definition: test_eigen_tensor.py:24
N
#define N
Definition: igam.h:9


gtsam
Author(s):
autogenerated on Sat Jun 1 2024 03:08:42