[C++-sig] boost numpy and boost python exported float128 / dd_real
Holger Brandsmeier
brandsmeier at gmx.de
Sun Nov 4 22:09:06 CET 2012
Dear list,
there is a C++ library that supports 128bit (and 256bit) floats:
libqd. In C++ that data type is called dd_real and I exported dd_real
to python via boost python.
Sometimes I send the same `dd_real` to python via a boost numpy by
creating and ndarray with the dtype given by
`np::dtype::get_builtin<dd_real>()`. In python that ends up beeing
`np.float128`. When I want to pass this `np.float128` back to a C++
functions expecting `dd_real` (exported via boost python), this
doesn't work (see below).
Can I somehow register an automatic converter in boost python so that
I can pass `np.float128` to a function that expects `dd_real`? How
would I do that? Note that for `np.float64` and `np.complex128` (where
there are buildin data types in python) these problems do not occur.
I also tried to avoid exporting `dd_real` from boost python, and I
wanted to always use `np.float128` from python, but that doesn't work
either:
No to_python (by-value) converter found for C++ type: dd_real
apparently `np.float128` is not in the boost python type registry.
-Holger
ArgumentError: Python argument types in
parfem.scalarPy.todouble(numpy.float128)
did not match C++ signature:
todouble(double)
todouble(dd_real)
More information about the Cplusplus-sig
mailing list