Open jishnub opened 1 year ago
Yeah, that's on purpose (well, not the error, but the intended behavior):
https://github.com/JuliaLang/julia/blob/c5e462137298a6876ca8bd0939f6e5ff79996d14/stdlib/LinearAlgebra/src/adjtrans.jl#L404-L410
Indeed, if the element type supports adjoint
(or transpose
), this seems useful, as it preserves the container being a row-vector instead of a (single-row) matrix, which are subtly different. But we make reasonably make this behavior dependent on whether the (output) element type supports adjoint
(transpose
) or not, and doing this unconditionally might not have been the best choice. I wonder how severe the breakage is if we unconditionally do NOT do this, i.e. always return a single-row matrix instead... Notably, the comment mentions broadcast which also gives a single-row matrix.
Notably, the comment mentions broadcast which also gives a single-row matrix.
Not only that, there is also code that's supposed to affect broadcast: https://github.com/JuliaLang/julia/blob/c5e462137298a6876ca8bd0939f6e5ff79996d14/stdlib/LinearAlgebra/src/adjtrans.jl#L413-L417 But apparently, that is ineffective:
julia> sqrt.([4.0; 9.0]')
1×2 Matrix{Float64}:
2.0 3.0
julia> map(sqrt, [4.0; 9.0]')
1×2 adjoint(::Vector{Float64}) with eltype Float64:
2.0 3.0
EDIT: ok, it works when explicitly calling broadcast
:
julia> broadcast(sqrt, [4.0; 9.0]')
1×2 adjoint(::Vector{Float64}) with eltype Float64:
2.0 3.0
The following is broken as a consequence
The broadcasted operation works as expected:
This error happens on v1.9 and 1.10 as well.