{-# LANGUAGE RebindableSyntax #-}
+{-# LANGUAGE ScopedTypeVariables #-}
-- | The Roots.Fast module contains faster implementations of the
-- 'Roots.Simple' algorithms. Generally, we will pass precomputed
--
-- 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)
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