Skip to content

Upstream #47

Open
Open
@blegat

Description

@blegat

Some implementations in Base/LinearAlgebra/SparseArrays have the following assumption:

  1. zero(T) isa T
  2. one(T) isa T
  3. -(::T) isa T
  4. +(::T, ::T) isa T
  5. *(::T, ::T) isa T
  6. x * y = y * x
  7. Implements ==
  8. *(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.

The following are the issues in SparseArrays.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions