JuliaLang / LinearAlgebra.jl

Julia Linear Algebra standard library
Other
17 stars 4 forks source link

Change in backslash between adjoined arrays. #1057

Closed KristofferC closed 8 months ago

KristofferC commented 9 months ago

Is this an intended change on 1.11?

julia> A = [1.0;;]
1×1 Matrix{Float64}:
 1.0

julia> x = [1.0]
1-element Vector{Float64}:
 1.0

# 1.10
julia> adjoint(A) \ adjoint(x)
1×1 adjoint(::Vector{Float64}) with eltype Float64:
 1.0

# 1.11
julia> adjoint(A) \ adjoint(x)
1×1 Matrix{Float64}:
 1.0

It causes https://s3.amazonaws.com/julialang-reports/nanosoldier/pkgeval/by_hash/0520b80_vs_997b49f/PDMats.primary.log

division of vectors (size (1, 1)): Test Failed at /home/pkgeval/.julia/packages/PDMats/cAM9h/test/pdmtypes.jl:132
  Expression: typeof(z) === typeof(y)
   Evaluated: Vector{Float64} === Matrix{Float64}

Stacktrace:
 [1] macro expansion
   @ /opt/julia/share/julia/stdlib/v1.11/Test/src/Test.jl:679 [inlined]
 [2] macro expansion
   @ ~/.julia/packages/PDMats/cAM9h/test/pdmtypes.jl:132 [inlined]

No idea what is right.

oscardssmith commented 9 months ago

I think they're both about equally right.

jishnub commented 9 months ago

Thinking of the matrix as a linear operator on a vector space, the 1.10 behavior makes more sense (i.e. A' maps a dual vector to another).

jishnub commented 9 months ago

The change seems to arise from the fact that

julia> similar(x')
1×1 adjoint(::Vector{Float64}) with eltype Float64:
 0.0

julia> similar(x', size(x'))
1×1 Matrix{Float64}:
 0.0

and v1.11 changed to calling similar with the size specified to allocate the destination.