Skip to content

Commit

Permalink
Remove type-converting primes from eachfactor
Browse files Browse the repository at this point in the history
  • Loading branch information
byhill committed Feb 23, 2024
1 parent fbbf6e1 commit fcae824
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name = "ModularSquareRoots"
uuid = "544cf62c-00ce-4949-a641-e1b79df66db1"
authors = ["byhill <[email protected]> and contributors"]
version = "0.1.2"
version = "0.1.3"

[deps]
Primes = "27ebfcd6-29c5-5fa9-bf4b-fb8fc14df3ae"

[compat]
Primes = "0.5"
Primes = "0.5.6"
julia = "1.8"
8 changes: 2 additions & 6 deletions src/ModularSquareRoots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,13 @@ function sqrtmod(n::T, m::T) where {T<:Integer}
newroots = T[]
mm = one(T)
for (p, e) in eachfactor(m)

# Unfortunately, `eachfactor` is not type-stable at the moment.
# Therefore, we need to wrap `p` to be of type `T`.
# See https://github.com/JuliaMath/Primes.jl/issues/151
for a1 in _sqrtmodq(n, T(p), e)
for a2 in roots
push!(newroots, crt([a1, a2], [T(p)^e, mm], T(p)^e * mm))
push!(newroots, crt([a1, a2], [p^e, mm], p^e * mm))
end
end

mm *= T(p)^e
mm *= p^e
roots, newroots = newroots, roots
empty!(newroots)
end
Expand Down

2 comments on commit fcae824

@byhill
Copy link
Owner Author

@byhill byhill commented on fcae824 Feb 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/101495

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.3 -m "<description of version>" fcae8246e96b331efea41286e82ff0591b58d79c
git push origin v0.1.3

Please sign in to comment.