[C++-sig] ANN: PyUblas -- Numpy+Boost.Ublas = happy

Andreas Klöckner lists at informa.tiker.net
Wed May 14 17:14:08 CEST 2008


Hi Ger,

On Mittwoch 14 Mai 2008, Ger van Diepen wrote:
> [snip] Unfortunately the compiler complained about ambiguous constructors
> when using that for std::complex (e.g. double, complex<float> and
> complex<double> for complex<double>). I have to see if I can work around
> that problem, but I'm afraid the problem is fundamental.

I don't quite see what's going wrong--please post code if you need help.

> Furthermore we have the possibility to convert a Python sequence to
> std::vector. I still have to add the code to accept numpy array scalars in
> such python sequences, so one can do in python something like: obj.func
> ([arr1[0], arr2[0]])

Hmm--I don't quite understand. It sounds like you already have scalar 
conversion in place. Why wouldn't that automatically help with converting the 
vector elements? (Also, b::p::stl_input_iterator<ValueType> is easy to 
overlook, but good to know about, if you don't already)

> Note that using int64 numpy on a 32 bit system gives the same problem as
> int32 on a 64 bit system. The same problems arise for int16, float32, etc.
> I was wondering if your solution can convert a numpy int16 to a C++ int (on
> a 32 or 64 bit system) as it looks to me that only one PyTypeObject matches
> a C++ type.

In PyUblas, the types need to match exactly, by design. But numpy also has 
PyArray_CastScalarToCtype, so this is doable without declaring O(n^2) 
implicit conversion rules. That function might, however, be too lenient in 
what it accepts (floats, etc.). Depends on what you want.

Andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20080514/5390f883/attachment.pgp>


More information about the Cplusplus-sig mailing list