numarray - use of fromfunction

Alex Hunsley lard at tardis.ed.ac.molar.uk
Sun Jul 4 23:33:30 CEST 2004


I'm using numarray to deal with arrays of values in python.
In particular, I'm interested in the fromfunction facility, which lets 
you define an array in terms of a function on its coordinates, like this:

def dist(x,y):
     return (x-5)**2+(y-5)**2      # distance from (5,5) squared

m = fromfunction(dist, (10,10))
print m


Question is: is there any way to define my function such that it refers 
to some values in a different array (or an 'old' copy of this one, 
before all the new values are applied)?
For example, suppose I want the array integer at (x, y) to have the 
value of value(x-1, y-1)*2 (i.e. 2 times the value to the 'top left'), 
is there a way to do this?


alex



More information about the Python-list mailing list