Ah, I figured it out: you need to define a containertype
and getindex
for CartesianIndex
:
julia> Base.getindex(A::MyMatrix,kj::CartesianIndex{2}) = A[kj[1],kj[2]]
julia> Base.Broadcast.containertype(::MyMatrix) = Array
julia> A .= MyMatrix()
3×3 Array{Float64,2}:
5.0 5.0 5.0
5.0 5.0 5.0
5.0 5.0 5.0