[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-cpp-sig
Subject:    [C++-sig] boost numpy and boost python exported float128 / dd_real
From:       Holger Brandsmeier <brandsmeier () gmx ! de>
Date:       2012-11-04 21:09:06
Message-ID: CAFP7zVsgG-rSNuvFy4Qg=rtWsFRR3j-vkw1=gPFvUH8cwQnKKA () mail ! gmail ! com
[Download RAW message or body]

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)
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic