[SciPy-user] Matrix Operation with index dependencies

Maik Trömel maik.troemel at maitro.net
Fri Aug 18 03:57:29 CDT 2006


Hello list!

I've got a question concerning matrix operations.

I'd like to fill a numpy-array (A) with values.

for j in range(maxj):
   for i in range(maxi):
       y = i / 4
       x = j / 4
       index = (j - j / 4 * 4) * 4 + (i - i / 4 * 4)
       if index == xyz:
            C = C1
       elif index == xyz +1:
            C = C2
       elif .......
            .......
       A[j,i] = sum( sum( B[ x-r:x+2 , y-s:y+2 ] * C ) )

C, s, r are depending on index; x and y are depending on i and j.
The problem is that it takes to long this way. Is it possible to do this 
without iterarting with numpy?

Thanks for your help!

Greetings Maik


More information about the SciPy-user mailing list