using with with blitz: errors
Hi, I am trying to use weave to speed up my code with inline c++ code, but I can't find any working sample. I found a very simple one [1] to return the trace of a matrix, but I can't find how to incorporate the c++ code. I attached the compile errors. I also tried to remove the "type_converters" parameter in inline and change the array parentheses () into brackets [], then it compiles but gives wrong results... I am running on Ubuntu with python2.4-scipy-core=0.3.2-2ubuntu1 python2.4-scipy=0.3.2-3ubuntu2 python2.4-numeric=23.8-4 python2.4-numeric-ext=23.8-4 blitz++=1:0.8-4 (just in case) gcc version is 4.0.2 Any ideas? Evan [1] http://amath.colorado.edu/faculty/fperez/python/weave_examples.html ps: here is the code that I ran ---- import scipy from weave import converters, inline def trace(mat): """Return the trace of a matrix. """ nrow,ncol = mat.shape code = \ """ double tr=0.0; for(int i=0;i<nrow;++i) tr += mat(i,i); return_val = tr; """ return inline(code,['mat','nrow','ncol'], type_converters = converters.blitz) M = scipy.rand(3,3) trace(M) ----
Evan Monroig wrote:
Hi,
I am trying to use weave to speed up my code with inline c++ code, but I can't find any working sample.
I found a very simple one [1] to return the trace of a matrix, but I can't find how to incorporate the c++ code. I attached the compile errors. I also tried to remove the "type_converters" parameter in inline and change the array parentheses () into brackets [], then it compiles but gives wrong results...
I am running on Ubuntu with python2.4-scipy-core=0.3.2-2ubuntu1 python2.4-scipy=0.3.2-3ubuntu2 python2.4-numeric=23.8-4 python2.4-numeric-ext=23.8-4 blitz++=1:0.8-4 (just in case)
gcc version is 4.0.2 ^^^^^^^^^^^^^^^^^^^^
This is your problem: only blitz 0.9 compiles with gcc4. You need to download the newer blitz, and put it by hand in the /usr/lib/python2.4/site-packages/weave/blitz-20001213/blitz directory.
Any ideas?
Evan
[1] http://amath.colorado.edu/faculty/fperez/python/weave_examples.html
On Dec.30 23h58, Fernando Perez wrote :
Evan Monroig wrote:
Hi,
I am trying to use weave to speed up my code with inline c++ code, but I can't find any working sample. [snip]
gcc version is 4.0.2 ^^^^^^^^^^^^^^^^^^^^
This is your problem: only blitz 0.9 compiles with gcc4. You need to download the newer blitz, and put it by hand in the
/usr/lib/python2.4/site-packages/weave/blitz-20001213/blitz
directory.
Thanks ! In fact after I checked my gcc version I just installed gcc-3.4 and changed the link in /usr/bin and it worked ^^. So I will get the newer blitz :). By the way, is there a way to specify the version of gcc to use with weave? Evan
Evan Monroig wrote:
Thanks !
In fact after I checked my gcc version I just installed gcc-3.4 and changed the link in /usr/bin and it worked ^^.
good.
So I will get the newer blitz :).
By the way, is there a way to specify the version of gcc to use with weave?
there is (use compiler='franken-gcc' in your weave call), but it's NOT a good idea to try to build extension modules (what weave is doing for you under the hood) with a different compiler than python itself was built, unless the two compilers are known to be extremely compatible. gcc3 and gcc4 (what I assume ubuntu built python with) won't play well together: the C++ ABI changed with gcc4. Cheers, f
participants (2)
-
Evan Monroig -
Fernando Perez