Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > numarray - use of fromfunction

Thread Tools

numarray - use of fromfunction

Alex Hunsley
Posts: n/a
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?

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Easy way to make Numarray Bool use 1 bit? Python 1 02-07-2006 10:11 PM
[Numpy]Can't make fromfunction() work Junkie Dolphin Python 1 10-07-2003 12:07 AM
Re: py2exe and numarray Thomas Heller Python 0 08-08-2003 07:41 PM
Numarray for Python 2.3 Tim Rowe Python 2 07-16-2003 10:42 PM
problem w/ numarray & py2exe... RJS Python 0 07-01-2003 06:44 AM