numarray - use of fromfunction

Discussion in 'Python' started by Alex Hunsley, Jul 4, 2004.

  1. Alex Hunsley

    Alex Hunsley Guest

    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
    Alex Hunsley, Jul 4, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RJS
    Replies:
    0
    Views:
    470
  2. Tim Rowe

    Numarray for Python 2.3

    Tim Rowe, Jul 16, 2003, in forum: Python
    Replies:
    2
    Views:
    329
    Tim Rowe
    Jul 16, 2003
  3. Thomas Heller

    Re: py2exe and numarray

    Thomas Heller, Aug 8, 2003, in forum: Python
    Replies:
    0
    Views:
    390
    Thomas Heller
    Aug 8, 2003
  4. Junkie Dolphin

    [Numpy]Can't make fromfunction() work

    Junkie Dolphin, Oct 6, 2003, in forum: Python
    Replies:
    1
    Views:
    903
    Scott David Daniels
    Oct 7, 2003
  5. Replies:
    1
    Views:
    308
Loading...

Share This Page