From: Michael Orlitzky Date: Fri, 7 Dec 2018 15:33:43 +0000 (-0500) Subject: src/Roots/Fast.hs: fix monomorphism restriction warnings. X-Git-Url: http://gitweb.michael.orlitzky.com/?p=numerical-analysis.git;a=commitdiff_plain;h=d2222aa1c04ba9c0eb80a03149abdf7d86eca032 src/Roots/Fast.hs: fix monomorphism restriction warnings. --- 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