[Matrix-SIG] Logical operations and fromfunction
David & Laura Beth Holz
lbda@earthlink.net
Fri, 14 May 1999 14:47:54 -0400
I just started using python and am intrigued by the fromfunction function
method of filling arrays as opposed to using nested loops like in Fortran.
However, I am having a problem and I just can't seem to follow the logic in
the NumPy user's guide.
The code I am trying to implement is as follows:
def awk_fill(j):
if j == 0:
fnj = float(nj[j])
return fn1 + one
else:
fnj = float(nj[j])
return awk[j1] + fnj
awk = fromfunction(awk_fill, (jm,))
where nj & awk is an 8 element vectors. I see on page 27 of the user's
guide that NumPy doesn't allow this operation, but I don't understand the
fix that the guide suggests at the bottom of the page. Has anyone run into
this before and how did you get around it? Or should I just be using some
next for loops.
Thanks for the help.
Dave Holz