numarray - use of fromfunction

A

Alex Hunsley

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top