pell 0.1.1.0 → 0.1.2.0
raw patch · 2 files changed
+58/−84 lines, 2 filesdep ~Cabaldep ~QuickCheckdep ~arithmoiPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: Cabal, QuickCheck, arithmoi, cabal-test-quickcheck, containers, primes
API changes (from Hackage documentation)
Files
- Math/NumberTheory/Moduli/SquareRoots.hs +4/−34
- pell.cabal +54/−50
Math/NumberTheory/Moduli/SquareRoots.hs view
@@ -11,41 +11,11 @@ ( sqrts ) where -import Data.List (sort)-import Math.NumberTheory.Primes.Factorisation (factorise)-import Math.NumberTheory.Moduli (chineseRemainder, sqrtModPPList)--chineseRemainders :: [([Integer], Integer)] -> [Integer]-chineseRemainders = fst . go where- go :: [([Integer], Integer)] -> ([Integer], Integer)- go [] = ([0], 1)- go xsm = foldr1 f xsm where- f (xs, m) (ys, n) = (xys, lcm m n) where- xys = do- x <- xs- y <- ys- case chineseRemainder [(x, m), (y, n)] of- Just z -> return z- Nothing -> []--sqrtsPP :: Integer -> (Integer, Int) -> [Integer]-sqrtsPP 1 (2, 1) = [1]-sqrtsPP 0 (p, e) = takeWhile (< p ^ e) $ map (* q) [0..] where- q = p ^ f- f = (if even e then e else succ e) `div` 2-sqrtsPP a (p, e)- | a `mod` p /= 0 = sqrtModPPList a (p, e)- | a `mod` (p * p) /= 0 = []- | otherwise = do- x <- sqrtsPP (a `div` (p * p)) (p, e - 2)- takeWhile (< m) [p * x + i * p ^ (e - 1) | i <- [0..]]- where- m = p ^ e+import Data.List (sort)+import Math.NumberTheory.Primes (factorise)+import Math.NumberTheory.Moduli (sqrtsModFactorisation) -- |@sqrts a m@ finds all square roots of @a@ modulo @m@, -- where @a@ is an arbitrary integer and @m@ is a positive integer. sqrts :: Integer -> Integer -> [Integer]-sqrts a m- | a < 0 = error $ "a must not be negative, but a == " ++ show a ++ " < 0."- | otherwise = sort $ chineseRemainders $ map f $ factorise m where- f (p, e) = (sqrtsPP (a `mod` p ^ e) (p, e), p ^ e)+sqrts a m = sort (sqrtsModFactorisation a (factorise m))
pell.cabal view
@@ -1,54 +1,58 @@--- Initial pell.cabal generated by cabal init. For further documentation, --- see http://haskell.org/cabal/users-guide/--name: pell-version: 0.1.1.0-synopsis: Package to solve the Generalized Pell Equation.-description: Finds all solutions of the generalized Pell Equation. -homepage: https://github.com/brunjlar/pell-license: MIT-license-file: LICENSE-author: Lars Bruenjes-maintainer: brunjlar@gmail.com-copyright: (c) 2016 by Dr. Lars Brünjes -category: Math, Algorithms, Number Theory-build-type: Simple-extra-source-files: README.md-cabal-version: >=1.20.0--library- exposed-modules: Math.NumberTheory.Pell- , Math.NumberTheory.Moduli.SquareRoots- other-modules: Math.NumberTheory.Pell.PQa- build-depends: base >=4.7 && <5- , arithmoi- , containers- default-language: Haskell2010- -Test-Suite test-pell- type: detailed-0.9- test-module: Math.NumberTheory.Pell.Test- other-modules: Math.NumberTheory.Moduli.SquareRoots- , Math.NumberTheory.Moduli.SquareRoots.Test- , Math.NumberTheory.Pell- , Math.NumberTheory.Pell.PQa- , Math.NumberTheory.Pell.Test.Reduced- , Math.NumberTheory.Pell.Test.Solve- , Math.NumberTheory.Pell.Test.Utils- build-depends: base >= 4.7 && <5- , arithmoi- , containers- , QuickCheck >= 2.8- , primes- , Cabal >= 1.20.0- , cabal-test-quickcheck- default-language: Haskell2010+cabal-version: 1.20+name: pell+version: 0.1.2.0+license: MIT+license-file: LICENSE+copyright: (c) 2016 by Dr. Lars Brünjes+maintainer: brunjlar@gmail.com+author: Lars Bruenjes+homepage: https://github.com/brunjlar/pell+synopsis: Package to solve the Generalized Pell Equation.+description:+ Finds all solutions of the generalized Pell Equation.+category: Math, Algorithms, Number Theory+build-type: Simple+extra-source-files:+ README.md source-repository head- type: git- location: https://github.com/brunjlar/pell+ type: git+ location: https://github.com/brunjlar/pell source-repository this- type: git- location: https://github.com/brunjlar/pell- tag: 0.1.1.0+ type: git+ location: https://github.com/brunjlar/pell+ tag: 0.1.2.0++library+ exposed-modules:+ Math.NumberTheory.Pell+ Math.NumberTheory.Moduli.SquareRoots+ other-modules:+ Math.NumberTheory.Pell.PQa+ default-language: Haskell2010+ build-depends:+ base >=4.7 && <5,+ arithmoi >=0.8 && <0.10,+ containers >=0.6.0.1 && <0.7++test-suite test-pell+ type: detailed-0.9+ test-module: Math.NumberTheory.Pell.Test+ other-modules:+ Math.NumberTheory.Moduli.SquareRoots+ Math.NumberTheory.Moduli.SquareRoots.Test+ Math.NumberTheory.Pell+ Math.NumberTheory.Pell.PQa+ Math.NumberTheory.Pell.Test.Reduced+ Math.NumberTheory.Pell.Test.Solve+ Math.NumberTheory.Pell.Test.Utils+ default-language: Haskell2010+ build-depends:+ base >=4.7 && <5,+ arithmoi >=0.8 && <0.10,+ containers >=0.6.0.1 && <0.7,+ QuickCheck >=2.8 && <2.14,+ primes >=0.2.1.0 && <0.3,+ Cabal >=1.20.0 && <2.5,+ cabal-test-quickcheck ==0.1.*