]> gitweb.michael.orlitzky.com - numerical-analysis.git/commitdiff
src/Polynomials/Orthogonal.hs: fix monomorphism restriction warnings.
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 7 Dec 2018 15:22:48 +0000 (10:22 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 7 Dec 2018 15:22:48 +0000 (10:22 -0500)
src/Polynomials/Orthogonal.hs

index 8fb777fcb103741a65a404046c28226cde723620..13ffa995b379600336a68780d44c49532300dd55 100644 (file)
@@ -1,3 +1,5 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+
 -- | The polynomials over [a,b] form a basis for L_2[a,b]. But often
 --   the \"obvious\" choice of a basis {1, x, x^2,...} is not
 --   convenient, because its elements are not orthogonal.
 -- | The polynomials over [a,b] form a basis for L_2[a,b]. But often
 --   the \"obvious\" choice of a basis {1, x, x^2,...} is not
 --   convenient, because its elements are not orthogonal.
@@ -63,7 +65,7 @@ import Prelude ()
 --   >>> actual == expected
 --   True
 --
 --   >>> actual == expected
 --   True
 --
-legendre :: (RealField.C a)
+legendre :: forall a. (RealField.C a)
          => Integer -- ^ The degree (i.e. the number of) the polynomial you want.
          -> a -- ^ The dependent variable @x@.
          -> a
          => Integer -- ^ The degree (i.e. the number of) the polynomial you want.
          -> a -- ^ The dependent variable @x@.
          -> a
@@ -72,5 +74,5 @@ legendre 1 x = x
 legendre n x =
   (c1*x * (legendre (n-1) x) - c2*(legendre (n-2) x)) / (fromInteger n)
   where
 legendre n x =
   (c1*x * (legendre (n-1) x) - c2*(legendre (n-2) x)) / (fromInteger n)
   where
-    c1 = fromInteger $ 2*n - 1
-    c2 = fromInteger $ n - 1
+    c1 = fromInteger $ 2*n - 1 :: a
+    c2 = fromInteger $ n - 1 :: a