I've been using something I wrote:
coef_from_function (function, delta, size)
which does (c++ code):
double center = double(size-1)/2;
for (int i = 0; i < size; ++i)
coef[i] = call
Perhaps you can do something along the following lines to get around
this limitation:
#################
# parameterizes the original function by delta, size.
def parameterized_function(delta, size, function):
center = (size-1)/2.0
return lambda i: function( (i-center)*delta )
# the function to which we want to apply "fromfunction".
def square(x): return x*x
# test script
from numpy import fromfunction
Delta = 0.1
Size = 9
print fromfunction( parameterized_function(Delta, Size, square), (Size,) )
###########
[ 0.16 0.09 0.04 0.01 0. 0.01 0.04 0.09 0.16]
On 2/3/09, Neal Becker
I've been using something I wrote:
coef_from_function (function, delta, size) which does (c++ code):
double center = double(size-1)/2; for (int i = 0; i < size; ++i) coef[i] = call
(func, double(i - center) * delta); I thought to translate this to np.fromfunction. It seems fromfunction is not as flexible, it uses only a fixed integer grid?
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
-- Not to laugh, not to lament, not to curse, but to understand. -- Spinoza
participants (2)
-
Neal Becker
-
Yakov Keselman