[SciPy-user] scipy 0.4.4 problems with converters.blitz

Christian Kristukat ckkart at hoc.net
Mon Jan 30 04:08:33 CST 2006

Stefan van der Walt wrote:
> On Sun, Jan 29, 2006 at 03:29:03PM +0100, Christian Kristukat wrote:
>>Thanks! That works.
>>Unfortunately the inline code that used to work before still doesn't compile. It
>>seems to be related to the support code I'm using. In the error message below
>>dist(double, double, int, double) is a function of the support code. Have there
>>been changes to weave that I'm not aware of?
>>/home/ck/.python24_compiled/sc_9824b12a96792c10b5fdb725f9caa3c44.cpp: In
>>function ‘PyObject* compiled_func(PyObject*, PyObject*)’:
>>/home/ck/.python24_compiled/sc_9824b12a96792c10b5fdb725f9caa3c44.cpp:837: error:
>>ISO C++ says that these are ambiguous, even though the worst conversion for the
>>first is better than the worst conversion for the second:
>>note: candidate 1: typename blitz::SliceInfo<P_numtype, T1, T2,
>>blitz::nilArraySection, blitz::nilArraySection, blitz::nilArraySection,
>>blitz::nilArraySection, blitz::nilArraySection, blitz::nilArraySection,
>>blitz::nilArraySection, blitz::nilArraySection, blitz::nilArraySection>::T_slice
>>blitz::Array<T, N>::operator()(T1, T2) const [with T1 = long int, T2 = int,
>>P_numtype = double, int N_rank = 2]
>>note: candidate 2: P_numtype& __restrict__ blitz::Array<T, N>::operator()(int,
>>int) [with P_numtype = double, int N_rank = 2]
>>/home/ck/.python24_compiled/sc_9824b12a96792c10b5fdb725f9caa3c44.cpp:837: error:
>>cannot convert ‘blitz::Array<double, 0>’ to ‘double’ for argument ‘2’ to ‘double
>>dist(double, double, int, double)’
> Don't you just love C++'s clear and descriptive compiler error's?
> This error also popped up in my code after a compiler upgrade (to
> GCC4, IIRC).  Seems that GCC4 is a lot more pedantic than 3.2.  You
> should be able to work around the problem by casting the value before
> passing it to your function, i.e.
> dist(static_cast<double>(whatever_you_had_here), ...)
> I had the problem with a function being called like
> dist(3, 4, 1, 1);
> which would only compile if I did
> dist(3.0, 4.0, 1, 1.0);
> in order to explicitly make the parameters doubles.
> Or maybe I'm totally off track, but it was worth a try!

Good idea! But it seems like I have to cast to a different type. Can you help me
with that error message?  I've no idea of C++. For me it looks like he's trying
to convert a 0-dim array (=scalar ?)  to a double, right?

error: invalid static_cast from type `blitz::Array<double, 0>' to type `double'

Regards, Christian

More information about the SciPy-user mailing list