Skip to content

Commit

Permalink
Added maximum(abs, x).
Browse files Browse the repository at this point in the history
  • Loading branch information
chriselrod committed Jul 20, 2020
1 parent 590c398 commit 14bba2f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/miscellaneous.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

function maximum(::typeof(abs), A::AbstractStrideArray{S,T}) where {S,T}
s = typemin(T)
@avx for i eachindex(A)
s = max(s, abs(A[i]))
end
s
end

9 changes: 9 additions & 0 deletions test/misc.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@


@testset "Miscellaneous" begin
x = @FixedSize rand(127);
@test maximum(abs, x) == maximum(abs, Array(x))
y = @FixedSize rand(3);
@test maximum(abs, y) == maximum(abs, Array(y))
end

1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ using Test
@test isempty(detect_unbound_args(PaddedMatrices))
@time include("matmul_tests.jl")
@time include("broadcast_tests.jl")
@time include("misc.jl")
end

2 comments on commit 14bba2f

@chriselrod
Copy link
Owner Author

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/18214

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.10 -m "<description of version>" 14bba2f22b0e787ae106402eb84114f9907e8798
git push origin v0.1.10

Please sign in to comment.