[Numpy-discussion] Indexing with weave
Barry Wark
barrywark at gmail.com
Mon Jan 8 15:58:26 CST 2007
Keith,
I think you want
y = x[0,i]
Remember that indexing in numpy/scipy is the python way (using []),
not the matlab way (using () )... I've been bitten by the distinction
many times.
Barry
On 1/8/07, Keith Goodman <kwgoodman at gmail.com> wrote:
> My first weave attempt weaves something to be desired.
>
> test() works, but test2() doesn't.
>
> It complains about the line "y = x(0,i);"
>
> In function 'PyObject* compiled_func(PyObject*, PyObject*)':
> blah.cpp:667: error: no match for call to '(py::object) (int, int&)'
>
> I am no match for that error message. What am I doing wrong?
>
> from scipy import weave
> from scipy.weave import converters
> import numpy.matlib as M
>
> def test(i):
> x = M.matrix([[1.0, 2.0, 3.0]]);
> code = """
> return_val = x(0,i);
> """
> y = weave.inline(code, ['x', 'i'], type_converters=converters.blitz)
> return y
>
> def test2(i):
> x = M.matrix([[1.0, 2.0, 3.0]]);
> code = """
> double y;
> y = x(0,i);
> return_val = y;
> """
> y = weave.inline(code, ['x', 'i'], type_converters=converters.blitz)
> return y
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
More information about the Numpy-discussion
mailing list