[SciPy-user] returning an array from weave inline

Fernando Perez fperez.net@gmail....
Wed Mar 28 13:05:45 CDT 2007


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


More information about the SciPy-user mailing list