fixed a little bug and getting good results again. still will have problems if you try to simply get a linear interpolation

This commit is contained in:
Stephen Mardson McQuay 2010-01-31 21:10:37 -07:00
parent 2113abb8dc
commit 0f4daa9a9c
3 changed files with 21 additions and 6 deletions

View File

@ -100,9 +100,14 @@ if __name__ == '__main__':
S = [mesh_source.points[i] for i in indicies[3:] ]
Sq = [mesh_source.q[i] for i in indicies[3:] ]
s_mesh = grid.grid(S, Sq)
print len(S)
answer = baker.run_baker(X, r_mesh, s_mesh, options.extra, options.verbose)
answer = baker.run_baker(X, r_mesh, s_mesh, options.verbose)
print "]\n[".join([str(i) for i in [answer, r_mesh, s_mesh]])
print
print
print
exact = exact_func(X[0], X[1])
if np.abs(exact - answer['final']) < np.abs(exact - answer['qlin']):
success += 1

View File

@ -93,7 +93,7 @@ def qlinear_3D(X, R, q):
qlin = sum([q_i * phi_i for q_i, phi_i in zip(q, phis)])
return qlin
def run_baker(X, R, S, extra_points = 3, verbose = False):
def run_baker(X, R, S, verbose = False):
"""
This is the main function to call to get an interpolation to X from the tree
@ -107,10 +107,19 @@ def run_baker(X, R, S, extra_points = 3, verbose = False):
"""
# calculate values only for the triangle
phi = get_phis(X, S.points)
qlin = qlinear (X, S.points, S.q)
phi = get_phis(X, R.points)
qlin = qlinear (X, R.points, R.q)
if extra_points == 0: return qlin
if len(S.points) == 0:
answer = {
'a': None,
'b': None,
'c': None,
'qlin': qlin,
'error': None,
'final': None,
}
return answer
B = [] # baker eq 9
w = [] # baker eq 11

View File

@ -91,6 +91,7 @@ class TestSequenceFunctions(unittest.TestCase):
self.q[size_of_simplex:size_of_simplex + extra_points])
answer = baker.run_baker(self.X, R, S)
a = self.approx_fmt % answer['a']
b = self.approx_fmt % answer['b']
c = self.approx_fmt % answer['c']