You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is somewhat tightly related to #22220, but I think a bit different:
julia> σ = [[0110],
[0-im
im 0],
[100-1]]
3-element Array{Array{Complex{Int64},2},1}:
[0+0im1+0im; 1+0im0+0im]
[0+0im0-1im; 0+1im0+0im]
[1+0im0+0im; 0+0im-1+0im]
julia> [123] * σ
1-element Array{Array{Complex{Int64},2},1}:
[3+0im1-2im; 1+2im-3+0im]
julia> [1,2,3]'* σ
ERROR:DimensionMismatch("x and y are of different lengths!")
Stacktrace:
[1] dot at /Users/mason/julia/usr/share/julia/stdlib/v1.4/LinearAlgebra/src/generic.jl:879 [inlined]
[2] dot(::Array{Int64,1}, ::Array{Array{Complex{Int64},2},1}) at /Users/mason/julia/usr/share/julia/stdlib/v1.4/LinearAlgebra/src/generic.jl:894
[3] *(::Adjoint{Int64,Array{Int64,1}}, ::Array{Array{Complex{Int64},2},1}) at /Users/mason/julia/usr/share/julia/stdlib/v1.4/LinearAlgebra/src/adjtrans.jl:245
[4] top-level scope at REPL[46]:1
Here we see that [1 2 3] * σ did something quite different from [1,2,3]'* σ: it essentially did what one should expect given the definitions you see in a linear algebra class, but [1,2,3]'* σ tries to recursively apply dot down to each level of the arrays which produces the above error.
To make matters worse, if I try to 'lift' my vector [1, 2, 3] to the same eltype as σ, I get a disastrously 'wrong' answer:
Perhaps even more strange is that transpose actually does the right thing here, but not adjoint, so maybe there is a path to arguing that this change would be a bug fix?
This is somewhat tightly related to #22220, but I think a bit different:
Here we see that
[1 2 3] * σ
did something quite different from[1,2,3]'* σ
: it essentially did what one should expect given the definitions you see in a linear algebra class, but[1,2,3]'* σ
tries to recursively applydot
down to each level of the arrays which produces the above error.To make matters worse, if I try to 'lift' my vector
[1, 2, 3]
to the same eltype asσ
, I get a disastrously 'wrong' answer:This seems to come down to the fact that
dot
is recursive, but I'd argue that even if we wantdot
to be recursive,*
should not be recursive.Perhaps the solution is a non-recursive
dot
that*
would lower to instead of the recursive form?This would be unfortunately breaking.
Thanks @ericphanson for making clear to me that the source of my issue is the recursive part.
The text was updated successfully, but these errors were encountered: