arithmoi 0.13.0.1 → 0.13.1.0
raw patch · 4 files changed
+25/−6 lines, 4 filesdep ~QuickCheckdep ~tasty-benchPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: QuickCheck, tasty-bench
API changes (from Hackage documentation)
Files
- Math/NumberTheory/Primes/Counting/Impl.hs +15/−4
- arithmoi.cabal +2/−2
- changelog.md +6/−0
- test-suite/Math/NumberTheory/Primes/CountingTests.hs +2/−0
Math/NumberTheory/Primes/Counting/Impl.hs view
@@ -431,10 +431,10 @@ countToNth !n (PS v0 bs : more) = go n 0 where wa :: UArray Int Word- wa = unsafeCoerce bs+ wa = coerceArray bs go !k i- | i == snd (bounds wa)+ | i > snd (bounds wa) = countToNth k more | otherwise = let w = unsafeAt wa i@@ -450,13 +450,24 @@ countAll (PS _ bs) = go 0 0 where wa :: UArray Int Word- wa = unsafeCoerce bs+ wa = coerceArray bs go !ct i- | i == snd (bounds wa)+ | i > snd (bounds wa) = ct | otherwise = go (ct + popCount (unsafeAt wa i)) (i+1)++-- This is dangerous: we rely on the fact that reading a whole word+-- at the end of ByteArray is permissible, even if its length+-- is not aligned with word boundaries.+coerceArray :: UArray Int Bool -> UArray Int Word+coerceArray (UArray 0 u n ba)+ | u + 1 == n, n' > 0 = UArray 0 (n' - 1) n' ba+ where+ n' = (n + rMASK) `shiftR` wSHFT+coerceArray (UArray l u n _) =+ error $ "Cannot coerce array of Bool to array of Word: " ++ show (l, u, n) -- Find the j-th highest of bc set bits in the Word w. top :: Word -> Int -> Int -> Int
arithmoi.cabal view
@@ -1,5 +1,5 @@ name: arithmoi-version: 0.13.0.1+version: 0.13.1.0 cabal-version: 2.0 build-type: Simple license: MIT@@ -17,7 +17,7 @@ powers (integer roots and tests, modular exponentiation). category: Math, Algorithms, Number Theory author: Andrew Lelechenko, Daniel Fischer-tested-with: GHC ==9.0.2 GHC ==9.2.8 GHC ==9.4.8 GHC ==9.6.6 GHC ==9.8.4 GHC ==9.10.1 GHC ==9.12.1+tested-with: GHC ==9.0.2 GHC ==9.2.8 GHC ==9.4.8 GHC ==9.6.7 GHC ==9.8.4 GHC ==9.10.1 GHC ==9.12.2 extra-doc-files: changelog.md
changelog.md view
@@ -1,5 +1,11 @@ # Changelog +## 0.13.1.0++### Fixed++* Fix a grave bug in prime counting, lurking since `arithmoi-0.11.0.0`.+ ## 0.13.0.1 ### Fixed
test-suite/Math/NumberTheory/Primes/CountingTests.hs view
@@ -36,6 +36,8 @@ , (10^10, 455052511) , (10^11, 4118054813) , (10^12, 37607912018)+ -- Enable tests below to validate any changes to 'primeCount' implementation:+ -- certain routines are not triggered until very large numbers. -- , (10^13, 346065536839) -- , (10^14, 3204941750802) -- , (10^15, 29844570422669)