[Numpy-discussion] Improvement of performance
gerardob
gberbeglia at gmail.com
Tue May 4 16:06:52 EDT 2010
Hello, I have written a very simple code that computes the gradient by finite
differences of any general function. Keeping the same idea, I would like
modify the code using numpy to make it faster.
Any ideas?
Thanks.
def grad_finite_dif(self,x,user_data = None):
assert len(x) == self.number_variables
points=[]
for j in range(self.number_variables):
points.append(x.copy())
points[len(points)-1][j]=points[len(points)-1][j]+0.0000001
delta_f = []
counter=0
for j in range(self.number_variables):
delta_f.append((self.eval(points[counter])-self.eval(x))/0.0000001)
counter = counter + 1
return array(delta_f)
--
View this message in context: http://old.nabble.com/Improvement-of-performance-tp28452458p28452458.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.
More information about the NumPy-Discussion
mailing list