Skip to content

Commit c7028f5

Browse files
bors[bot]Sleort
andauthored
Merge #227
227: Properly handle reducing complex numbers with abs2 r=maleadt a=Sleort Just imitating what is done with `abs`... Co-authored-by: Troels Arnfred Bojesen <[email protected]>
2 parents 8d14f4e + b363578 commit c7028f5

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/mapreduce.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ gpu_promote_type(::typeof(Base.mul_prod), ::Type{T}) where {T<:Number} = typeof(
5858
gpu_promote_type(::typeof(max), ::Type{T}) where {T<: WidenReduceResult} = T
5959
gpu_promote_type(::typeof(min), ::Type{T}) where {T<: WidenReduceResult} = T
6060
gpu_promote_type(::typeof(abs), ::Type{Complex{T}}) where {T} = T
61+
gpu_promote_type(::typeof(abs2), ::Type{Complex{T}}) where {T} = T
6162

6263
import Base.Broadcast: Broadcasted, ArrayStyle
6364
const GPUSrcArray = Union{Broadcasted{ArrayStyle{AT}}, GPUArray{T, N}} where {T, N, AT<:GPUArray}

test/testsuite/mapreduce.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ function test_mapreduce(AT)
3030
@test compare(prod, AT, rand(range, dims))
3131
@test compare(x -> sum(abs, x), AT, rand(range, dims))
3232
@test compare(x -> prod(abs, x), AT, rand(range, dims))
33+
@test compare(x -> sum(abs2, x), AT, rand(range, dims))
34+
@test compare(x -> prod(abs2, x), AT, rand(range, dims))
3335
ET <: Complex || @test compare(maximum, AT,rand(range, dims))
3436
ET <: Complex || @test compare(minimum, AT,rand(range, dims))
3537
end

0 commit comments

Comments
 (0)