[SciPy-user] returning an array from weave inline

Flavio Coelho fccoelho@gmail....
Wed Mar 28 12:57:06 CDT 2007


I get a compilation error when  I try to return an array from weave.inline

here is my test code ( a simple matrix multplication)

from scipy import weave
from scipy.weave import converters

def Dot(a1,a2):
    """
    multiplicação de matrizes em C
    """
    #print a1.shape,a2.shape
    d1,d2,d3 = a1.shape[0],a2.shape[1], a1.shape[1]
    a3 = zeros((d1,d2))
    code = """
    {
    int i, j, k;
    for( i = 0; i < d1; i++)
           for( j = 0; j < d2; j++)
               for( k = 0; k < d3; k++)
                 a3(i,j) +=  a1(i,k)*a2(k,j);
    }
    return_val = a3;
    """
    return weave.inline
(code,['a1','a2','a3','d1','d2','d3'],type_converters=converters.blitz
,compiler='gcc')

this is the compilation error I get::

<weave: compiling>
/home/flavio/.python24_compiled/sc_80afed445639e2098f517fccd0b436f93.cpp: In
function 'PyObject* compiled_func(PyObject*, PyObject*)':
/home/flavio/.python24_compiled/sc_80afed445639e2098f517fccd0b436f93.cpp:738:
error: no match for 'operator=' in 'return_val = a3'
/usr/lib/python2.4/site-packages/scipy/weave/scxx/object.h:179: note:
candidates are: py::object& py::object::operator=(const py::object&)
/home/flavio/.python24_compiled/sc_80afed445639e2098f517fccd0b436f93.cpp: In
function 'PyObject* compiled_func(PyObject*, PyObject*)':
/home/flavio/.python24_compiled/sc_80afed445639e2098f517fccd0b436f93.cpp:738:
error: no match for 'operator=' in 'return_val = a3'
/usr/lib/python2.4/site-packages/scipy/weave/scxx/object.h:179: note:
candidates are: py::object& py::object::operator=(const py::object&)
Traceback (most recent call last):
  File "DengueRJdin_01.py", line 314, in ?
    mainMeld(K,L)
  File "DengueRJdin_01.py", line 221, in mainMeld
    phi,q1theta = Rep(K, tmax,**para)
  File "DengueRJdin_01.py", line 22, in Rep
    res,inc = simEpid(tmax,q1theta[0][i],q1theta[1][i],q1theta[2][i],**args)
  File "DengueRJdin_01.py", line 143, in simEpid
    yant[:,j] = Dot(D,l)
  File "DengueRJdin_01.py", line 120, in Dot
    return weave.inline
(code,['a1','a2','a3','d1','d2','d3'],type_converters=converters.blitz
,compiler='gcc')
  File "/usr/lib/python2.4/site-packages/scipy/weave/inline_tools.py", line
338, in inline
    auto_downcast = auto_downcast,
  File "/usr/lib/python2.4/site-packages/scipy/weave/inline_tools.py", line
447, in compile_function
    verbose=verbose, **kw)
  File "/usr/lib/python2.4/site-packages/scipy/weave/ext_tools.py", line
365, in compile
    verbose = verbose, **kw)
  File "/usr/lib/python2.4/site-packages/scipy/weave/build_tools.py", line
269, in build_extension
    setup(name = module_name, ext_modules = [ext],verbose=verb)
  File "/usr/lib/python2.4/site-packages/numpy-1.0.1-py2.4-linux-i686.egg/numpy/distutils/core.py",
line 174, in setup
    return old_setup(**new_attr)
  File "/usr/lib/python2.4/distutils/core.py", line 166, in setup
    raise SystemExit, "error: " + str(msg)
scipy.weave.build_tools.CompileError: error: Command "i686-pc-linux-gnu-g++
-pthread -fno-strict-aliasing -DNDEBUG -fPIC
-I/usr/lib/python2.4/site-packages/scipy/weave
-I/usr/lib/python2.4/site-packages/scipy/weave/scxx
-I/usr/lib/python2.4/site-packages/scipy/weave/blitz
-I/usr/lib/python2.4/site-packages/numpy-1.0.1-py2.4-linux-i686.egg/numpy/core/include
-I/usr/include/python2.4 -c
/home/flavio/.python24_compiled/sc_80afed445639e2098f517fccd0b436f93.cpp -o
/tmp/flavio/python24_intermediate/compiler_060e323e3e036dd7c46bf6c968ae89ac/home/flavio/.python24_compiled/sc_80afed445639e2098f517fccd0b436f93.o"
failed with exit status 1

any help will be greatly appreciated.


-- 
Flávio Codeço Coelho
registered Linux user # 386432
get counted at http://counter.li.org
---------------------------
"software gets slower faster than hardware gets faster"
Niklaus Wirth's law
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20070328/e6a9cbe3/attachment.html 


More information about the SciPy-user mailing list