Welcome to Hearing aid Software

Convert Msor To Sor -

MSOR allows a different relaxation parameter ( \omega_i ) for each equation (or for blocks). The iteration becomes:

[ x_i^(k+1) = (1-\omega_i) x_i^(k) + \frac\omega_ia_ii \left( b_i - \sum_j=1^i-1 a_ij x_j^(k+1) - \sum_j=i+1^n a_ij x_j^(k) \right) ]

If ( \omega_i = \omega ) for all ( i ), MSOR collapses to standard SOR. convert msor to sor


To convert an existing MSOR implementation to SOR, follow these steps:

| Step | Action | |------|--------| | 1 | Identify the array or function that stores ( \omega_i ) for ( i = 1, \dots, n ). | | 2 | Replace all instances of ( \omega_i ) with a single global variable ( \omega ). | | 3 | Remove any logic that updates ( \omega_i ) per iteration or per equation. | | 4 | (Optional) Choose ( \omega ) in the optimal range ( (0, 2) ), typically ( \omega = 1 ) for Gauss-Seidel or an estimated spectral radius value. | MSOR allows a different relaxation parameter ( \omega_i

Algorithmic change in pseudocode:

MSOR version:
for i = 1 to n
    x_new[i] = (1 - omega[i]) * x_old[i] + (omega[i]/A[i][i]) * (b[i] - sum)
end

SOR version (after conversion): omega_const = 1.5 (example) for i = 1 to n x_new[i] = (1 - omega_const) * x_old[i] + (omega_const/A[i][i]) * (b[i] - sum) end To convert an existing MSOR implementation to SOR,


If you don’t have a heuristic, run a small calibration loop:

def find_equivalent_sor(A, b, omega1, omega2, test_omegas=np.linspace(1.0, 1.9, 10)):
    x_msor = msor_solve(A, b, omega1, omega2, tol=1e-8)
    best_omega = 1.0
    best_error = float('inf')
    for omega in test_omegas:
        x_sor = sor_solve(A, b, omega, tol=1e-8)
        err = np.linalg.norm(x_sor - x_msor)
        if err < best_error:
            best_error = err
            best_omega = omega
    return best_omega

Solve ( 2x_1 - x_2 = 1, ; -x_1 + 2x_2 = 1 ) starting from ( x^(0) = (0,0) ).

  • Convert to SOR with ( \omega = 1.0 ) (Gauss-Seidel):
  • The converted SOR uses a single ( \omega ) instead of two distinct values.


    Go to Top