Week3: fixed error in the Conjugate Gradient Method
This commit is contained in:
parent
0b5dc4864e
commit
217d4a2f5d
1 changed files with 2 additions and 2 deletions
|
@ -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
|
||||||
|
|
Reference in a new issue