mirror of
https://gitlab.com/sheaf/metabrush.git
synced 2024-11-27 09:24:08 +00:00
Add some commentary to Gauss-Seidel function
This commit is contained in:
parent
a59f1695fb
commit
32ce7c38bb
|
@ -115,7 +115,7 @@ bisect x@( 𝕀 x_inf x_sup )
|
|||
where x_mid = midpoint x
|
||||
|
||||
infixl 6 ⊖
|
||||
(⊖) :: ( Ring a, Ord a ) => 𝕀 a -> 𝕀 a -> 𝕀 a
|
||||
(⊖) :: ( AbelianGroup a, Ord a ) => 𝕀 a -> 𝕀 a -> 𝕀 a
|
||||
(⊖) a@( 𝕀 lo1 hi1 ) b@( 𝕀 lo2 hi2 )
|
||||
| width a >= width b
|
||||
= 𝕀 ( lo1 - lo2 ) ( hi1 - hi2 )
|
||||
|
|
|
@ -202,7 +202,13 @@ gaussSeidelStep
|
|||
-> [ ( T ( 𝕀ℝ n ), Bool ) ]
|
||||
gaussSeidelStep as b ( T x0 ) = coerce $
|
||||
forEachCoord @n ( x0, True ) $ \ i ( x, contraction ) -> do
|
||||
-- For each i, we have an equation: sum_j a_ij * x_j = b_i
|
||||
--
|
||||
-- Re-arrange this with x_i on the left to get an iteration:
|
||||
-- x_i' = ( b_i - sum { j /= i } a_ij * x_j ) / a_ii
|
||||
--
|
||||
-- We perform each iteration in turn (for i = 1, ..., n),
|
||||
-- **using the latest updated value of each x_j** in each iteration.
|
||||
let s = b `index` i - sum [ ( as ! j ) `index` i * x `index` j
|
||||
| j <- toList ( universe @n ), j /= i ]
|
||||
x_i = x `index` i
|
||||
|
|
Loading…
Reference in a new issue