Skip to content

Add vectorized mod2pi #15797

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ function mod2pi(x::Int64)
fx == x || throw(ArgumentError("Int64 argument to mod2pi is too large: $x"))
mod2pi(fx)
end
@vectorize_1arg Number mod2pi

# generic fallback; for number types, promotion.jl does promotion
muladd(x,y,z) = x*y+z
Expand Down
1 change: 1 addition & 0 deletions test/mod2pi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,4 @@ testModPi()
@test_approx_eq mod2pi(355.0f0) 3.1416228f0
@test mod2pi(Int64(2)^60) == mod2pi(2.0^60)
@test_throws ArgumentError mod2pi(Int64(2)^60-1)
@test_approx_eq maximum(abs(mod2pi(testCases[:,1]).-testCases[:,2])) 0.0