[SciPy-user] returning an array from weave inline

Flavio Coelho fccoelho@gmail....
Wed Mar 28 17:18:49 CDT 2007


Thanks Fernando,

I thought variables converted to C were copies, so that there could not be
an in place operation on a Python variable.

Flávio



On 3/28/07, Fernando Perez <fperez.net@gmail.com> wrote:
>
> On 3/28/07, Flavio Coelho <fccoelho@gmail.com> wrote:
> > 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')
>
> Don't return anything.  Your code has already filled in a3, so there's
> no need for you to return.
>
> Cheers,
>
> f
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>



-- 
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/e0cf02b5/attachment.html 


More information about the SciPy-user mailing list