X-Git-Url: http://gitweb.michael.orlitzky.com/?p=numerical-analysis.git;a=blobdiff_plain;f=src%2FRoots%2FFast.hs;h=a879950556623fbcc1334fc133abc49ca7c6da30;hp=e5321c9fa82142c55b487104b5df1ec5d1fb9b70;hb=d2222aa1c04ba9c0eb80a03149abdf7d86eca032;hpb=5c0366134e8e1c12772cb685ac14b70d22d6ffed diff --git a/src/Roots/Fast.hs b/src/Roots/Fast.hs index e5321c9..a879950 100644 --- a/src/Roots/Fast.hs +++ b/src/Roots/Fast.hs @@ -1,4 +1,5 @@ {-# LANGUAGE RebindableSyntax #-} +{-# LANGUAGE ScopedTypeVariables #-} -- | The Roots.Fast module contains faster implementations of the -- 'Roots.Simple' algorithms. Generally, we will pass precomputed @@ -148,7 +149,7 @@ fixed_point_iterations = -- -- We also return the number of iterations required. -- -fixed_point_with_iterations :: (Normed a, +fixed_point_with_iterations :: forall a b. (Normed a, Additive.C a, RealField.C b, Algebraic.C b) @@ -165,12 +166,13 @@ fixed_point_with_iterations f epsilon x0 = abs_diff v w = norm (v - w) -- The nth entry in this list is the absolute value of x_{n} - - -- x_{n+1}. - differences = zipWith abs_diff xn xn_plus_one + -- x_{n+1}. They're of type "b" because we're going to compare + -- them against epsilon. + differences = zipWith abs_diff xn xn_plus_one :: [b] -- This produces the list [(n, xn)] so that we can determine -- the number of iterations required. - numbered_xn = zip [0..] xn + numbered_xn = zip [0..] xn :: [(Int,a)] -- A list of pairs, (xn, |x_{n} - x_{n+1}|). pairs = zip numbered_xn differences