Fix: Correct dichotimie
This commit is contained in:
5
ex3.py
5
ex3.py
@@ -72,11 +72,8 @@ def relaxation(A, b, omega=1.0, epsilon=1e-6, max_iter=100_000):
|
||||
# Pré-calculer (D - ωL)^(-1) une seule fois
|
||||
inv_D_omega_L = np.linalg.inv(D - omega * L)
|
||||
|
||||
if omega == 1:
|
||||
return gauss_seidel(A, b)
|
||||
|
||||
for _ in range(max_iter):
|
||||
x_new = inv_D_omega_L @ ((1 - omega) * D @ x + omega * (U @ x + b))
|
||||
x_new = inv_D_omega_L @ (omega * (b - U @ x) - omega * L @ x + (1 - omega) * D @ x)
|
||||
if np.linalg.norm(x_new - x, ord=2) < epsilon:
|
||||
return x_new
|
||||
x = x_new
|
||||
|
||||
Reference in New Issue
Block a user