-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Milestone
Description
Some implementations in Base/LinearAlgebra/SparseArrays have the following assumption:
zero(T) isa Tone(T) isa T-(::T) isa T+(::T, ::T) isa T*(::T, ::T) isa Tx * y = y * x- Implements
== *(x::T, y::S) = *(promote(x, y)...)
However, these assumptions are violated for the following types where MP stands for MultivariatePolynomials and MOI stand for MathOptInterface.
| Type | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|
Bool |
x | x | ||||||
JuMP.VariableRef |
x | x | x | x | x | x | ||
MOI.VariableRef |
x | x | x | x | x | x | ||
MOI.ScalarAffineExpression |
x | x | x | |||||
MP.AbstractVariable |
x | x | x | x | x | |||
MP.AbstractMonomial |
x | x | x | x | ||||
MP.AbstractTerm |
x | |||||||
AbstractArray |
x | |||||||
Non-commutative MP.AbstractVariable |
x | x | x | x | x | x |
The current approach is to create an AbstractMutable type and redefine methods for the methods defined in Base for these types.
The long term solution would be to fix the issue upstream. In the short term, as Julia v1.5 might be an LTS, that would allow the package to be simplified once we drop Julia v1.0 for all the fixes that are merged before Julia v1.5.
The following are the issues in LinearAlgebra.
-
Matrix(::Tridiagonal),Matrix(::SymTridiagonal),Matrix(::LowerTriangular),Matrix(::UpperTriangular),Matrix(::UnitLowerTriangular),Matrix(::UnitUpperTriangular)assumes 1: Fix Matrix on diagonal and triangular matrices for types without zero JuliaLang/julia#36256
Current workaround:
https://github.com/JuliaOpt/MutableArithmetics.jl/blob/407a8fdfb5ef1810f3785a88e490291d37b9fb03/src/dispatch.jl#L231-L241 -
LinearAlgebra._iszeroassumes 7: Replace LinearAlgebra._iszero by Base.iszero JuliaLang/julia#36194
Current workaround:
https://github.com/JuliaOpt/MutableArithmetics.jl/blob/407a8fdfb5ef1810f3785a88e490291d37b9fb03/src/dispatch.jl#L267-L272 -
convert(::Type{<:UniformScaling}, ::UniformScaling)is not defined: Define convert for UniformScaling JuliaLang/julia#36193
Current workaround:
https://github.com/JuliaOpt/MutableArithmetics.jl/blob/407a8fdfb5ef1810f3785a88e490291d37b9fb03/src/MutableArithmetics.jl#L60-L64 -
LinearAlgebra.diagm_containerassumes 1. : Fix diagm_container for types without zero JuliaLang/julia#35743
Current workaround:
https://github.com/JuliaOpt/MutableArithmetics.jl/blob/407a8fdfb5ef1810f3785a88e490291d37b9fb03/src/dispatch.jl#L27-L31 -
-(::LinearAlgebra.Symmetric)assumes 3. : Fix -Symmetric for Bool or JuMP.VariableRef JuliaLang/julia#32375
Current workaround:
https://github.com/JuliaOpt/MutableArithmetics.jl/blob/407a8fdfb5ef1810f3785a88e490291d37b9fb03/src/dispatch.jl#L204-L212 -
LinearAlgebra.luassumes 4. and 5. : Make LU factorization work for more types JuliaLang/julia#26344 -
*(::AbstractArray, ::AbstractArray)assumes 4. : Make matrix multiplication work for more types JuliaLang/julia#18218
The following are the issues in SparseArrays.
-
*(::AbstractSparseArray, ::AbstractSparseArray)assumes 8.
Beginning of current workaround (many more follows):
https://github.com/JuliaOpt/MutableArithmetics.jl/blob/407a8fdfb5ef1810f3785a88e490291d37b9fb03/src/dispatch.jl#L105-L116
akondrahman
Metadata
Metadata
Assignees
Labels
No labels