summaryrefslogtreecommitdiff
path: root/Algebra/Ring/Polynomial/Univariate.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Algebra/Ring/Polynomial/Univariate.hs')
-rw-r--r--Algebra/Ring/Polynomial/Univariate.hs19
1 files changed, 6 insertions, 13 deletions
diff --git a/Algebra/Ring/Polynomial/Univariate.hs b/Algebra/Ring/Polynomial/Univariate.hs
index e3e981a..0366a49 100644
--- a/Algebra/Ring/Polynomial/Univariate.hs
+++ b/Algebra/Ring/Polynomial/Univariate.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE BangPatterns, ConstraintKinds, DataKinds, FlexibleContexts #-}
+{-# LANGUAGE BangPatterns, CPP, ConstraintKinds, DataKinds, FlexibleContexts #-}
{-# LANGUAGE GADTs, GeneralizedNewtypeDeriving, MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude, ScopedTypeVariables, StandaloneDeriving #-}
{-# LANGUAGE TypeApplications, TypeFamilies, UndecidableSuperClasses #-}
@@ -28,7 +28,7 @@ import qualified Data.Sized.Builtin as SV
import qualified Numeric.Algebra as NA
import Numeric.Decidable.Zero (DecidableZero (..))
import qualified Prelude as P
-import GHC.OverloadedLabels
+
-- | Univariate polynomial.
-- It uses @'IM.IntMap'@ as its internal representation;
-- so if you want to treat the power greater than @maxBound :: Int@,
@@ -42,10 +42,11 @@ instance Hashable r => Hashable (Unipol r) where
-- | By this instance, you can use @#x@ for
-- the unique variable of @'Unipol' r@.
instance Unital r => IsLabel "x" (Unipol r) where
+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 802
+ fromLabel = Unipol $ IM.singleton 1 one
+#else
fromLabel _ = Unipol $ IM.singleton 1 one
-
-normaliseUP :: DecidableZero r => Unipol r -> Unipol r
-normaliseUP (Unipol r) = Unipol $ IM.filter (not . isZero) r
+#endif
divModUnipol :: (CoeffRing r, Field r) => Unipol r -> Unipol r -> (Unipol r, Unipol r)
divModUnipol f g =
@@ -143,9 +144,6 @@ instance CoeffRing r => P.Num (Unipol r) where
then zero
else one
-(%!!) :: Sized (n :: Nat) a -> SV.Ordinal (n :: Nat) -> a
-(%!!) = (SV.%!!)
-
{-# RULES
"var x^n" forall (x :: SV.Ordinal 1) n.
pow (varUnipol x) n = Unipol (IM.singleton (fromEnum n) one)
@@ -156,11 +154,6 @@ instance CoeffRing r => P.Num (Unipol r) where
NA.pow1p (varUnipol x) n = Unipol (IM.singleton (fromEnum n + 1) one)
#-}
-{-# RULES
-"x ^ n" forall (x :: SV.Ordinal 1) n.
- (varUnipol x) ^ n = Unipol (IM.singleton (fromEnum n) one)
- #-}
-
varUnipol :: Unital r => SV.Ordinal 1 -> Unipol r
varUnipol _ = Unipol $ IM.singleton 1 one
{-# NOINLINE CONLIKE [1] varUnipol #-}