From: Bjørn Rustad Date: Thu, 29 Sep 2011 08:57:27 +0000 (+0200) Subject: Fix int division error in functions X-Git-Url: http://git.rustad.me/?a=commitdiff_plain;h=34876eea7adcea43ac4619f12f7d90edf3c3502a;p=nummat1 Fix int division error in functions --- diff --git a/function.py b/function.py index 6a4dafe..480ceb9 100644 --- a/function.py +++ b/function.py @@ -2,7 +2,7 @@ import numpy as np # Calculate function value in point x def function_g(x, H, b, c): - return -b.T.dot(x) + 0.5 * x.T.dot(H.dot(x)) + (1/12) * x.T.dot(_C(x,c).dot(x)) + return -b.T.dot(x) + 0.5 * x.T.dot(H.dot(x)) + (1.0/12.0) * x.T.dot(_C(x,c).dot(x)) # Create matrix C(x) def _C(x, c): @@ -13,7 +13,7 @@ def _C(x, c): # Calculate gradient of g in point x def gradient_g(x, H, b, c): - return -b.T + 0.5 * H.dot(x) + 0.5 * H.T.dot(x) + (1/3) * x.T.dot(_C(x,c)) + return -b.T + 0.5 * H.dot(x) + 0.5 * H.T.dot(x) + (1.0/3.0) * x.T.dot(_C(x,c)) # Calculate hessian of g in point x def hessian_g(x, H, b, c): diff --git a/surf.py b/surf.py index 27ccde9..1c1f2f4 100644 --- a/surf.py +++ b/surf.py @@ -13,6 +13,6 @@ def surf(H, b, c, xmin, xmax, ymin, ymax, zmin, zmax): for i in xrange(dim): for j in xrange(dim): Z[i][j] = function.function_g(np.array([X[i][j],Y[i][j]]), H, b, c) - if Z[i][j] > zmax: - Z[i][j] = NaN +# if Z[i][j] > zmax: +# Z[i][j] = NaN return X, Y, Z