Convex.jl defines an abstract type AbstractExpr, from which all important 
concrete types in the package are descended. We've defined a bunch of 
functions that allow users to treat AbstractExprs as though they were 
matrices: indexing, hcat, vcat, multiplication, addition, subtraction, etc. 
Can we use these to automatically get more advanced functions, like (for 
example) kron?

The code for kron 
<https://github.com/JuliaLang/julia/blob/master/base/linalg/dense.jl#L134> 
uses only indexing and multiplication operators. But I'm not sure how to 
make AbstractExpr (and its subtypes) subtype AbstractMatrix{Float64} or 
subtype AbstractArray{Float64,2} to make this transition seamless.

Simply defining

abstract AbstractExpr <: AbstractArray{Float64,2} 

results in a method error: (Variable is defined as a subtype of 
AbstractExpr)

julia> kron(A,B)
ERROR: MethodError: `kron` has no method matching kron(::Array{Float64,2}, 
::Convex.Variable)
Closest candidates are:
  kron(::Any, ::Any, ::Any, ::Any...)
  kron{T,S}(::Array{T,2}, ::Array{S,2})
  kron(::Union{Array{T,1},Array{T,2}}, ::Number)

1) Is it possible to have Convex's AbstractExpr inherit from AbstractArray? 
What other methods would we need to implement to make this work?
2) Is it a terrible idea, for reasons I haven't thought of?

Thanks!
Madeleine

Reply via email to