c
! www.simula.no/˜hpl
Array initialization from a Python f u n ction
>>> def myfunc(i, j):
... return (i+1)
*
(j+4-i)
...
>>> # make 3x6 array where a[i,j] = myfunc(i,j):
>>> a = fromfunction(myfunc, (3,6))
>>> a
array([[ 4., 5., 6., 7., 8., 9.],
[6., 8.,10.,12.,14.,16.],
[6., 9.,12.,15.,18.,21.]])
Numerical Python – p. 248/728
Komentarze do niniejszej Instrukcji