Skip to content

Commit d789490

Browse files
authored
Merge pull request #105 from JuliaMath/oscardssmith-use-IntegerMathUtils
use `IntegerMathUtils`
2 parents 72cb0cc + 6b9b404 commit d789490

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ version = "0.5.1"
44

55
[extras]
66
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
7+
IntegerMathUtils = "18e54dd8-cb9d-406c-a71d-865a43cbb235"
78
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
89

910
[targets]
10-
test = ["DataStructures", "Test"]
11+
test = ["DataStructures", "IntegerMathUtils", "Test"]
1112

1213
[compat]
1314
DataStructures = "0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17"
15+
IntegerMathUtils = "0.1"
1416
julia = "1"

src/Primes.jl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ using Base.Iterators: repeated
77
import Base: iterate, eltype, IteratorSize, IteratorEltype
88
using Base: BitSigned
99
using Base.Checked: checked_neg
10+
using IntegerMathUtils
1011

1112
export isprime, primes, primesmask, factor, ismersenneprime, isrieselprime,
1213
nextprime, nextprimes, prevprime, prevprimes, prime, prodfactors, radical, totient
@@ -176,11 +177,7 @@ julia> isprime(big(3))
176177
true
177178
```
178179
"""
179-
isprime(x::BigInt, reps=25) = ccall((:__gmpz_probab_prime_p,:libgmp),
180-
Cint, (Any, Cint), x, reps) > 0
181-
# TODO: Change `Any` to `Ref{BigInt}` when 0.6 support is dropped.
182-
# The two have the same effect but `Ref{BigInt}` won't be optimized on 0.6.
183-
180+
isprime(x::BigInt, reps=25) = is_probably_prime(x; reps=reps)
184181

185182
# Miller-Rabin witness choices based on:
186183
# http://mathoverflow.net/questions/101922/smallest-collection-of-bases-for-prime-testing-of-64-bit-numbers

0 commit comments

Comments
 (0)