1
0
Fork 0

Week3: fixed error in the Conjugate Gradient Method

This commit is contained in:
Eric Teunis de Boone 2020-02-27 15:33:08 +01:00
parent 0b5dc4864e
commit 217d4a2f5d

View file

@ -81,7 +81,7 @@ def conjugate_gradient(A, b, eps):
r_i = r_f - t * np.dot(A, v_f) r_i = r_f - t * np.dot(A, v_f)
s = np.dot(r_i, r_i) / np.dot(r_f, r_f) s = np.dot(r_i, r_i) / np.dot(r_f, r_f)
v_i = r_i - s*v_f v_i = r_i + s*v_f
# Set r and v vectors for next loop # Set r and v vectors for next loop
r_f = r_i r_f = r_i
@ -101,7 +101,7 @@ def conjugate_gradient(A, b, eps):
r_i = r_f - t * np.dot(A, v_f) r_i = r_f - t * np.dot(A, v_f)
s = np.dot(r_i, r_i) / np.dot(r_f, r_f) s = np.dot(r_i, r_i) / np.dot(r_f, r_f)
v_i = r_i - s*v_f v_i = r_i + s*v_f
# Save r and v vectors for next loop # Save r and v vectors for next loop
r_f = r_i r_f = r_i