From 34876eea7adcea43ac4619f12f7d90edf3c3502a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B8rn=20Rustad?= Date: Thu, 29 Sep 2011 10:57:27 +0200 Subject: [PATCH] Fix int division error in functions --- function.py | 4 ++-- surf.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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 -- 2.47.3