arithmoi 0.12.0.0 → 0.12.0.1
raw patch · 10 files changed
+60/−35 lines, 10 filesdep −vector-sizeddep ~basedep ~transformersPVP ok
version bump matches the API change (PVP)
Dependencies removed: vector-sized
Dependency ranges changed: base, transformers
API changes (from Hackage documentation)
Files
- Math/NumberTheory/ArithmeticFunctions/Inverse.hs +3/−1
- Math/NumberTheory/DirichletCharacters.hs +3/−2
- Math/NumberTheory/Euclidean/Coprimes.hs +2/−1
- Math/NumberTheory/Prefactored.hs +3/−3
- Math/NumberTheory/Primes/Counting/Impl.hs +0/−1
- Math/NumberTheory/Primes/Factorisation/Montgomery.hs +11/−2
- Math/NumberTheory/Primes/Small.hs +7/−7
- arithmoi.cabal +3/−4
- changelog.md +6/−0
- test-suite/Math/NumberTheory/Moduli/EquationsTests.hs +22/−14
Math/NumberTheory/ArithmeticFunctions/Inverse.hs view
@@ -31,7 +31,8 @@ import Prelude hiding (rem, quot) import Data.Bits (Bits) import Data.Euclidean-import Data.List (foldl', partition, mapAccumL, sortOn)+import Data.Foldable+import Data.List (partition, sortOn) import Data.Map (Map) import qualified Data.Map as M import Data.Maybe@@ -42,6 +43,7 @@ import Data.Semiring (Semiring(..), Mul(..)) import Data.Set (Set) import qualified Data.Set as S+import Data.Traversable import Numeric.Natural import Math.NumberTheory.ArithmeticFunctions
Math/NumberTheory/DirichletCharacters.hs view
@@ -64,10 +64,10 @@ #endif import Data.Bits (Bits(..)) import Data.Constraint-import Data.Foldable (for_)+import Data.Foldable import Data.Functor.Identity (Identity(..)) import Data.Kind-import Data.List (mapAccumL, foldl', sort, find, unfoldr)+import Data.List (sort, unfoldr) import Data.Maybe (mapMaybe, fromJust, fromMaybe) import Data.Mod #if MIN_VERSION_base(4,12,0)@@ -76,6 +76,7 @@ import Data.Proxy (Proxy(..)) import Data.Ratio ((%), numerator, denominator) import Data.Semigroup (Semigroup(..),Product(..))+import Data.Traversable import qualified Data.Vector as V import qualified Data.Vector.Mutable as MV import Data.Vector (Vector, (!))
Math/NumberTheory/Euclidean/Coprimes.hs view
@@ -21,12 +21,13 @@ import Prelude hiding (gcd, quot, rem) import Data.Coerce import Data.Euclidean-import Data.List (tails, mapAccumL)+import Data.List (tails) import Data.Maybe #if __GLASGOW_HASKELL__ < 803 import Data.Semigroup #endif import Data.Semiring (Semiring(..), isZero)+import Data.Traversable -- | A list of pairwise coprime numbers -- with their multiplicities.
Math/NumberTheory/Prefactored.hs view
@@ -29,7 +29,7 @@ import Math.NumberTheory.Primes import Math.NumberTheory.Primes.Types --- | A container for a number and its pairwise coprime (but not neccessarily prime)+-- | A container for a number and its pairwise coprime (but not necessarily prime) -- factorisation. -- It is designed to preserve information about factors under multiplication. -- One can use this representation to speed up prime factorisation@@ -78,7 +78,7 @@ { prefValue :: a -- ^ Number itself. , prefFactors :: Coprimes a Word- -- ^ List of pairwise coprime (but not neccesarily prime) factors,+ -- ^ List of pairwise coprime (but not necessarily prime) factors, -- accompanied by their multiplicities. } deriving (Eq, Show) @@ -90,7 +90,7 @@ fromValue a = Prefactored a (singleton a 1) -- | Create 'Prefactored' from a given list of pairwise coprime--- (but not neccesarily prime) factors with multiplicities.+-- (but not necessarily prime) factors with multiplicities. -- -- >>> fromFactors (splitIntoCoprimes [(140, 1), (165, 1)]) -- Prefactored {prefValue = 23100, prefFactors = Coprimes {unCoprimes = [(28,1),(33,1),(5,2)]}}
Math/NumberTheory/Primes/Counting/Impl.hs view
@@ -399,7 +399,6 @@ then accumulate 2 (i-2) else do unsafeWrite ar i d accumulate (d+1) (i-1)- | otherwise = return ar note 2 0 note 6 3 note 10 5
Math/NumberTheory/Primes/Factorisation/Montgomery.hs view
@@ -368,7 +368,11 @@ | i >= smallPrimesLength = ([], Just (NatJ# m)) | otherwise- = let p# = indexWord16OffAddr# smallPrimesAddr# i# in+ = let p# =+#if MIN_VERSION_base(4,16,0)+ word16ToWord#+#endif+ (indexWord16OffAddr# smallPrimesAddr# i#) in case m `quotRemBigNatWord` p# of (# mp, 0## #) -> let (# k, r #) = splitOff 1 mp in@@ -386,7 +390,12 @@ = if isTrue# (m# `leWord#` 4294967295##) -- 65536 * 65536 - 1 then ([(NatS# m#, 1)], Nothing) else ([], Just (NatS# m#))- goWord m# i@(I# i#) = let p# = indexWord16OffAddr# smallPrimesAddr# i# in+ goWord m# i@(I# i#)+ = let p# =+#if MIN_VERSION_base(4,16,0)+ word16ToWord#+#endif+ (indexWord16OffAddr# smallPrimesAddr# i#) in if isTrue# (m# `ltWord#` (p# `timesWord#` p#)) then ([(NatS# m#, 1)], Nothing) else case m# `quotRemWord#` p# of
Math/NumberTheory/Primes/Small.hs view
@@ -21,12 +21,12 @@ import GHC.Word smallPrimesFromTo :: Word16 -> Word16 -> [Word16]-smallPrimesFromTo (W16# from#) (W16# to#) = go k0#+smallPrimesFromTo from to = go k0# where !(Ptr smallPrimesAddr#) = smallPrimesPtr- fromD# = word2Double# from#+ !(D# fromD#) = fromIntegral from k0#- | isTrue# (from# `leWord#` 5##)+ | from <= 5 = 0# | otherwise = double2Int# (fromD# /## logDouble# fromD#)@@ -34,14 +34,14 @@ go k# | I# k# >= smallPrimesLength = []- | isTrue# (p# `gtWord#` to#)+ | p > to = []- | isTrue# (p# `ltWord#` from#)+ | p < from = go (k# +# 1#) | otherwise- = W16# p# : go (k# +# 1#)+ = p : go (k# +# 1#) where- p# = indexWord16OffAddr# smallPrimesAddr# k#+ p = W16# (indexWord16OffAddr# smallPrimesAddr# k#) -- length smallPrimes smallPrimesLength :: Int
arithmoi.cabal view
@@ -1,5 +1,5 @@ name: arithmoi-version: 0.12.0.0+version: 0.12.0.1 cabal-version: 2.0 build-type: Simple license: MIT@@ -39,7 +39,7 @@ integer-roots >=1.0, mod, random >=1.0 && <1.3,- transformers >=0.4 && <0.6,+ transformers >=0.4 && <0.7, semirings >=0.5.2, vector >=0.12 exposed-modules:@@ -124,8 +124,7 @@ tasty-rerun >=1.1.17, tasty-smallcheck >=0.8 && <0.9, transformers >=0.5,- vector,- vector-sized+ vector other-modules: Math.NumberTheory.ArithmeticFunctionsTests Math.NumberTheory.ArithmeticFunctions.InverseTests
changelog.md view
@@ -1,5 +1,11 @@ # Changelog +## 0.12.0.1++### Fixed++* Compatibility patches for GHC 9.2.+ ## 0.12.0.0 ### Added
test-suite/Math/NumberTheory/Moduli/EquationsTests.hs view
@@ -19,28 +19,36 @@ import GHC.TypeNats (KnownNat, SomeNat(..), someNatVal) import Numeric.Natural +import Math.NumberTheory.Moduli (SomeMod(..)) import Math.NumberTheory.Moduli.Equations import Math.NumberTheory.Moduli.Singleton import Math.NumberTheory.TestUtils -solveLinearProp :: KnownNat m => Mod m -> Mod m -> Bool-solveLinearProp a b = sort (solveLinear a b) ==- filter (\x -> a * x + b == 0) [minBound .. maxBound]+wrapSome :: KnownNat m => ([Mod m], [Mod m]) -> ([SomeMod], [SomeMod])+wrapSome (xs, ys) = (map SomeMod xs, map SomeMod ys) -solveLinearProperty1 :: Positive Natural -> Integer -> Integer -> Bool-solveLinearProperty1 (Positive m) a b = case someNatVal m of- SomeNat (_ :: Proxy t) -> solveLinearProp (fromInteger a :: Mod t) (fromInteger b)+solveLinearProp :: KnownNat m => Mod m -> Mod m -> ([Mod m], [Mod m])+solveLinearProp a b =+ ( sort (solveLinear a b)+ , filter (\x -> a * x + b == 0) [minBound .. maxBound]+ ) -solveQuadraticProp :: KnownNat m => Mod m -> Mod m -> Mod m -> Bool-solveQuadraticProp a b c = sort (solveQuadratic sfactors a b c) ==- filter (\x -> a * x * x + b * x + c == 0) [minBound .. maxBound]+solveLinearProperty1 :: (Positive Natural, Integer, Integer) -> ([SomeMod], [SomeMod])+solveLinearProperty1 (Positive m, a, b) = case someNatVal m of+ SomeNat (_ :: Proxy t) -> wrapSome $ solveLinearProp (fromInteger a :: Mod t) (fromInteger b) -solveQuadraticProperty1 :: Positive Natural -> Integer -> Integer -> Integer -> Bool-solveQuadraticProperty1 (Positive m) a b c = case someNatVal m of- SomeNat (_ :: Proxy t) -> solveQuadraticProp (fromInteger a :: Mod t) (fromInteger b) (fromInteger c)+solveQuadraticProp :: KnownNat m => Mod m -> Mod m -> Mod m -> ([Mod m], [Mod m])+solveQuadraticProp a b c =+ ( sort (solveQuadratic sfactors a b c)+ , filter (\x -> a * x * x + b * x + c == 0) [minBound .. maxBound]+ ) +solveQuadraticProperty1 :: (Positive Natural, Integer, Integer, Integer) -> ([SomeMod], [SomeMod])+solveQuadraticProperty1 (Positive m, a, b, c) = case someNatVal m of+ SomeNat (_ :: Proxy t) -> wrapSome $ solveQuadraticProp (fromInteger a :: Mod t) (fromInteger b) (fromInteger c)+ testSuite :: TestTree testSuite = testGroup "Equations"- [ testSmallAndQuick "solveLinear" solveLinearProperty1- , testSmallAndQuick "solveQuadratic" solveQuadraticProperty1+ [ testEqualSmallAndQuick "solveLinear" solveLinearProperty1+ , testEqualSmallAndQuick "solveQuadratic" solveQuadraticProperty1 ]