diff --git a/base/linalg/rowvector.jl b/base/linalg/rowvector.jl index ac4541ff39123..dfdb874d0ff57 100644 --- a/base/linalg/rowvector.jl +++ b/base/linalg/rowvector.jl @@ -144,12 +144,12 @@ end @inline to_vec(x::Number) = x @inline to_vecs(rowvecs...) = (map(to_vec, rowvecs)...) -# map -@inline map(f, rowvecs::RowVector...) = RowVector(map(f, to_vecs(rowvecs...)...)) +# map: Preserve the RowVector, but note that `f` expects transposed elements +@inline map(f, rowvecs::RowVector...) = RowVector(map(transpose∘f∘transpose, to_vecs(rowvecs...)...)) # broacast (other combinations default to higher-dimensional array) @inline broadcast(f, rowvecs::Union{Number,RowVector}...) = - RowVector(broadcast(f, to_vecs(rowvecs...)...)) + RowVector(broadcast(transpose∘f∘transpose, to_vecs(rowvecs...)...)) # Horizontal concatenation # diff --git a/test/linalg/rowvector.jl b/test/linalg/rowvector.jl index f188a3082c000..84ee28f29118e 100644 --- a/test/linalg/rowvector.jl +++ b/test/linalg/rowvector.jl @@ -249,3 +249,13 @@ end @test A'*x' == A'*y == B*x' == B*y == C' end end + +@testset "issue #20979" begin + f20979(z::Complex) = [z.re -z.im; z.im z.re] + v = [1+2im]' + @test (f20979.(v))[1] == f20979(v[1]) + @test f20979.(v) == f20979.(collect(v)) + + w = rand(Complex128, 3) + @test f20979.(v') == f20979.(collect(v')) == (f20979.(v))' +end