Drake
Drake C++ Documentation
default_scalars_pybind.h File Reference

Detailed Description

Helpers for defining scalars and values.

Include dependency graph for default_scalars_pybind.h:

Namespaces

 drake
 
 drake::pydrake
 For more high-level information, see the Python Bindings technical notes.
 

Typedefs

using CommonScalarPack = type_pack< double, AutoDiffXd, symbolic::Expression >
 Type pack defining common scalar types. More...
 
using NonSymbolicScalarPack = type_pack< double, AutoDiffXd >
 Type pack for non-symbolic common scalar types. More...
 

Functions

template<typename T , typename PyClass , typename UPack = typename internal::CastUPack<T>::Pack>
void DefCast (PyClass *cls, const char *doc, UPack U_pack={})
 Binds cast<T>() explicitly. More...
 
Handling special non-POD scalar types.

Because we use dtype=object in NumPy, we cannot alias (share references to) the data underlying matrix objects when passing data between NumPy and Eigen (see #8116).

The simple policy these functions help enforce:

  • When T is double, allow referencing (do not require copying).
  • When T is not double (i.e., AutoDiffXd, Expression), copy data (do not reference the data).
template<typename T >
py::return_value_policy return_value_policy_for_scalar_type ()
 Permits referencing for builtin dtypes (e.g., T == double), but then switches to copying for custom dtypes (T ∈ {AutoDiffXd, Expression}). More...
 
template<typename SomeBlock >
decltype(auto) CopyIfNotPodType (const SomeBlock &x)
 A no-op for builtin dtypes (e.g., T == double), but then switches to copying for custom dtypes (T ∈ {AutoDiffXd, Expression}). More...