computational-algebra 0.1.0.0 → 0.1.0.1
raw patch · 3 files changed
+58/−8 lines, 3 files
Files
- Algebra/Algorithms/Groebner/Monomorphic.hs +51/−0
- computational-algebra.cabal +1/−1
- examples/bench.hs +6/−7
Algebra/Algorithms/Groebner/Monomorphic.hs view
@@ -9,6 +9,9 @@ , divModPolynomialWith, divPolynomialWith, modPolynomialWith -- * Groebner basis , calcGroebnerBasis, calcGroebnerBasisWith+ , syzygyBuchberger, syzygyBuchbergerWith+ , primeTestBuchberger, primeTestBuchbergerWith+ , simpleBuchberger, simpleBuchbergerWith -- * Ideal operations , isIdealMember, intersection, thEliminationIdeal, eliminate , quotIdeal, quotByPrincipalIdeal@@ -124,6 +127,54 @@ Ideal vec -> case singInstance (Poly.sDegree (head $ toList vec)) of SingInstance -> map (renameVars vars . polyn . demote . Monomorphic) $ Gr.calcGroebnerBasisWith ord ideal+ where+ vars = nub $ sort $ concatMap buildVarsList j++simpleBuchberger :: (Groebnerable r) => [Polynomial r] -> [Polynomial r]+simpleBuchberger = simpleBuchbergerWith Grevlex++simpleBuchbergerWith :: forall ord r. (Groebnerable r, IsMonomialOrder ord)+ => ord -> [Polynomial r] -> [Polynomial r]+simpleBuchbergerWith _ ps | any (== zero) ps = []+simpleBuchbergerWith ord j =+ case uniformlyPromote j :: Monomorphic (Ideal :.: Poly.OrderedPolynomial r ord) of+ Monomorphic (Comp ideal) ->+ case ideal of+ Ideal vec ->+ case singInstance (Poly.sDegree (head $ toList vec)) of+ SingInstance -> map (renameVars vars . polyn . demote . Monomorphic) $ Gr.simpleBuchberger ideal+ where+ vars = nub $ sort $ concatMap buildVarsList j++primeTestBuchberger :: (Groebnerable r) => [Polynomial r] -> [Polynomial r]+primeTestBuchberger = primeTestBuchbergerWith Grevlex++primeTestBuchbergerWith :: forall ord r. (Groebnerable r, IsMonomialOrder ord)+ => ord -> [Polynomial r] -> [Polynomial r]+primeTestBuchbergerWith _ ps | any (== zero) ps = []+primeTestBuchbergerWith ord j =+ case uniformlyPromote j :: Monomorphic (Ideal :.: Poly.OrderedPolynomial r ord) of+ Monomorphic (Comp ideal) ->+ case ideal of+ Ideal vec ->+ case singInstance (Poly.sDegree (head $ toList vec)) of+ SingInstance -> map (renameVars vars . polyn . demote . Monomorphic) $ Gr.primeTestBuchberger ideal+ where+ vars = nub $ sort $ concatMap buildVarsList j++syzygyBuchberger :: (Groebnerable r) => [Polynomial r] -> [Polynomial r]+syzygyBuchberger = syzygyBuchbergerWith Grevlex++syzygyBuchbergerWith :: forall ord r. (Groebnerable r, IsMonomialOrder ord)+ => ord -> [Polynomial r] -> [Polynomial r]+syzygyBuchbergerWith _ ps | any (== zero) ps = []+syzygyBuchbergerWith ord j =+ case uniformlyPromote j :: Monomorphic (Ideal :.: Poly.OrderedPolynomial r ord) of+ Monomorphic (Comp ideal) ->+ case ideal of+ Ideal vec ->+ case singInstance (Poly.sDegree (head $ toList vec)) of+ SingInstance -> map (renameVars vars . polyn . demote . Monomorphic) $ Gr.syzygyBuchberger ideal where vars = nub $ sort $ concatMap buildVarsList j
computational-algebra.cabal view
@@ -2,7 +2,7 @@ -- further documentation, see http://haskell.org/cabal/users-guide/ name: computational-algebra-version: 0.1.0.0+version: 0.1.0.1 synopsis: Well-kinded computational algebra library, currently supporting Groebner basis. description: Dependently-typed computational algebra libray for Groebner basis. homepage: https://github.com/konn/computational-algebra
examples/bench.hs view
@@ -9,9 +9,8 @@ import qualified Numeric.Algebra as NA import Progression.Main -x, y, z, w, s, a, b, c :: Polynomial Rational-[x, y, z, w, s, a, b, c] =- map (injectVar . flip Variable Nothing) "xyzwSabc"+x, y, z, w, s, a, b, c :: Polynomial Rational (S (S (S Three)))+[x, y, z, w, s, a, b, c] = genVars (sS (sS (sS Three))) instance NFData Variable where rnf (Variable x y) = rnf x `seq` rnf y `seq` ()@@ -24,12 +23,12 @@ ideal2 = [x^2 * y - 2*x*y - 4*z - 1, z-y^2, x^3 - 4*z*y] ideal3 = [ 2 * s - a * y, b^2 - (x^2 + y^2), c^2 - ( (a-x) ^ 2 + y^2) ]-ideal4 = [ x^5 + y^4 + z^3 - 1, x^3 + y^3 + z^2 - 1]+ideal4 = [ z^5 + y^4 + x^3 - 1, z^3 + y^3 + x^2 - 1] main :: IO () main = defaultMain $ bgroup "groebner"- [ bench "grevlex" $ nf calcGroebnerBasis ideal4- , bench "grlex" $ nf (calcGroebnerBasisWith Grlex) ideal4- , bench "lex" $ nf (calcGroebnerBasisWith Lex) ideal4+ [ bench "simple" $ nf (simpleBuchberger Lex) ideal3+ , bench "relprime" $ nf (primeTestBuchberger Lex) ideal3+ , bench "relprime" $ nf (syzygyBuchberger Lex) ideal3 ]