Skip to content
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

new norm, dot, and opnorm #577

Merged
merged 3 commits into from
Jun 19, 2018
Merged
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,10 @@ Currently, the `@compat` macro supports the following syntaxes:

* `Unicode.isnumeric` is now available as `isnumeric` ([#25479]).

* `vecnorm` and `vecdot` are now `Compat.norm` and `Compat.dot`, respectively, while the
old `norm(A::AbstractMatrix, p=2)` is now `Compat.opnorm` ([#27401]). `import Compat: ⋅`
to get `Compat.dot` as the binary operator `⋅`.

* `atan2` is now a 2-argument method of `atan` ([#27253]).

## New macros
Expand Down Expand Up @@ -644,3 +648,4 @@ includes this fix. Find the minimum version from there.
[#27253]: https://github.com/JuliaLang/julia/issues/27253
[#27258]: https://github.com/JuliaLang/julia/issues/27258
[#27298]: https://github.com/JuliaLang/julia/issues/27298
[#27401]: https://github.com/JuliaLang/julia/issues/27401
11 changes: 11 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1925,6 +1925,17 @@ if VERSION < v"0.7.0-DEV.5278"
export something
end

if !isdefined(LinearAlgebra, :opnorm) # julia#27401
opnorm(A::AbstractMatrix, p::Real=2) = LinearAlgebra.norm(A, p)
const norm = LinearAlgebra.vecnorm
const dot = LinearAlgebra.vecdot
else
const opnorm = LinearAlgebra.opnorm
const norm = LinearAlgebra.norm
const dot = LinearAlgebra.dot
end
const ⋅ = dot

# https://github.com/JuliaLang/julia/pull/27253
@static if VERSION < v"0.7.0-alpha.44"
Base.atan(x::Real, y::Real) = atan2(x, y)
Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1813,6 +1813,14 @@ let sep = Compat.Sys.iswindows() ? ';' : ':'
end
end

# julia#27401
import Compat: ⋅
@test Compat.opnorm([1 2;3 4]) ≈ 5.464985704219043
@test Compat.opnorm([1 2;3 4], 1) ≈ 6
@test Compat.norm([1 2;3 4]) ≈ 5.477225575051661
@test Compat.norm([1 2;3 4], 1) ≈ 10
@test Compat.dot([1 2;3 4], [5 6;7 8]) == [1 2;3 4] ⋅ [5 6;7 8] ≈ 70

# 0.7.0-alpha.44
@test atan(1, 2) == atan(0.5)
@test atan(1.0, 2.0) == atan(0.5)
Expand Down