Convex.jl
Convex.jl copied to clipboard
Scalar indexing of row of matrix creates row vector, causing incorrect `dot`
julia> x = Variable(2,2)
Variable
size: (2, 2)
sign: real
vexity: affine
id: 936…769
julia> set_value!(x, ones(2,2))
2×2 Matrix{Float64}:
1.0 1.0
1.0 1.0
julia> evaluate(x[2, :])
1×2 Matrix{Float64}:
1.0 1.0
julia> evaluate(x)[2, :]
2-element Vector{Float64}:
1.0
1.0
In particular this causes dot
to be incorrect: https://discourse.julialang.org/t/convex-jl-constraints-not-enforced/102439/2.
The proper fix for this I think is to respect the difference between e.g. a 1x1 matrix and an scalar, but Convex.jl still has the MATLABism of conflating those all over the codebase, treating everything as a matrix.
That is a pretty big lift though. But this bug is pretty bad, it would be good to find a quicker fix, maybe restricted to getindex
.