|
- from scipy.weave import inline
- vec = 100
- code = """
- double sum = 0.0;
- int npts = Nvec[0];
- for (int i=0;i<npts;++i) {
- sum += vec[i];
- }
- return_val = sum;
- """
- print inline(code,['vec'])
- print vec.sum()
复制代码 /home/shihyu/.python26_compiled/sc_d6f219b85e9586396248b98781b97fd25.cpp: In function ‘PyObject* compiled_func(PyObject*, PyObject*)’:
/home/shihyu/.python26_compiled/sc_d6f219b85e9586396248b98781b97fd25.cpp:667: error: ‘Nvec’ was not declared in this scope
/home/shihyu/.python26_compiled/sc_d6f219b85e9586396248b98781b97fd25.cpp:669: error: invalid types ‘int[int]’ for array subscript
/home/shihyu/.python26_compiled/sc_d6f219b85e9586396248b98781b97fd25.cpp: In function ‘PyObject* compiled_func(PyObject*, PyObject*)’:
/home/shihyu/.python26_compiled/sc_d6f219b85e9586396248b98781b97fd25.cpp:667: error: ‘Nvec’ was not declared in this scope
/home/shihyu/.python26_compiled/sc_d6f219b85e9586396248b98781b97fd25.cpp:669: error: invalid types ‘int[int]’ for array subscript
Traceback (most recent call last):
File "test.py", line 12, in <module>
print inline(code,['vec'])
File "/usr/lib/python2.6/dist-packages/scipy/weave/inline_tools.py", line 335, in inline
**kw)
File "/usr/lib/python2.6/dist-packages/scipy/weave/inline_tools.py", line 462, in compile_function
verbose=verbose, **kw)
File "/usr/lib/python2.6/dist-packages/scipy/weave/ext_tools.py", line 365, in compile
verbose = verbose, **kw)
File "/usr/lib/python2.6/dist-packages/scipy/weave/build_tools.py", line 272, in build_extension
setup(name = module_name, ext_modules = [ext],verbose=verb)
File "/usr/lib/python2.6/dist-packages/numpy/distutils/core.py", line 184, in setup
return old_setup(**new_attr)
File "/usr/lib/python2.6/distutils/core.py", line 169, in setup
raise SystemExit, "error: " + str(msg)
scipy.weave.build_tools.CompileError: error: Command "g++ -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -fPIC -I/usr/lib/python2.6/dist-packages/scipy/weave -I/usr/lib/python2.6/dist-packages/scipy/weave/scxx -I/usr/lib/python2.6/dist-packages/numpy/core/include -I/usr/include/python2.6 -c /home/shihyu/.python26_compiled/sc_d6f219b85e9586396248b98781b97fd25.cpp -o /tmp/shihyu/python26_intermediate/compiler_2da6387b1d12110fba46fe47fea9326a/home/shihyu/.python26_compiled/sc_d6f219b85e9586396248b98781b97fd25.o" failed with exit status 1
請問是什麼原因造成?
謝謝 |
|