Containment check in a LinearMap can fail with SingularException
schillic opened this issue · 0 comments
schillic commented
The containment check in a LinearMap
(and also AffineMap
) uses the left-division operator (\
), which fails for singular matrices. I suggest to fall back to the concrete linear_map
(resp. affine_map
) in these cases.
LazySets.jl/src/LazyOperations/LinearMap.jl
Lines 343 to 345 in 97c91fc
julia> M = [-1.0 -2.0; 1.0 2.0];
julia> X = Hyperrectangle([4.0, 0.0], [3.0, 0.0]);
julia> x = [-6.0, -4.0];
julia> x in M * X # or `x in M * X + zeros(2)`
ERROR: LinearAlgebra.SingularException(2)
Stacktrace:
[1] checknonsingular
@ julia-1.9.4/share/julia/stdlib/v1.9/LinearAlgebra/src/factorization.jl:19 [inlined]
[2] checknonsingular
@ julia-1.9.4/share/julia/stdlib/v1.9/LinearAlgebra/src/factorization.jl:22 [inlined]
[3] #lu!#170
@ julia-1.9.4/share/julia/stdlib/v1.9/LinearAlgebra/src/lu.jl:82 [inlined]
[4] lu!
@ julia-1.9.4/share/julia/stdlib/v1.9/LinearAlgebra/src/lu.jl:80 [inlined]
[5] #lu#176
@ julia-1.9.4/share/julia/stdlib/v1.9/LinearAlgebra/src/lu.jl:299 [inlined]
[6] lu (repeats 2 times)
@ julia-1.9.4/share/julia/stdlib/v1.9/LinearAlgebra/src/lu.jl:298 [inlined]
[7] \(A::Matrix{Float64}, B::Vector{Float64})
@ LinearAlgebra julia-1.9.4/share/julia/stdlib/v1.9/LinearAlgebra/src/generic.jl:1115
[8] in(x::Vector{Float64}, lm::LinearMap{Float64, Hyperrectangle{Float64, Vector{Float64}, Vector{Float64}}, Float64, Matrix{Float64}})
@ LazySets ~/.julia/dev/LazySets/src/LazyOperations/LinearMap.jl:344