For a 2d array the following works:

type mytype{T}
    var :: AbstractMatrix{T}
end

julia> t = mytype(zeros(4, 3))
mytype{Float64}(4x3 Array{Float64,2}:
 0.0  0.0  0.0
 0.0  0.0  0.0
 0.0  0.0  0.0
 0.0  0.0  0.0)



But how do I extend this to a 3d array?

julia> t = mytype(zeros(2, 4, 3))
ERROR: MethodError: `convert` has no method matching convert(::Type{mytype{T
}}, ::Array{Float64,3})
This may have arisen from a call to the constructor mytype{T}(...),
since type constructors fall back to convert methods.
Closest candidates are:
  call{T}(::Type{T}, ::Any)
  convert{T}(::Type{T}, ::T)
  mytype{T}(::AbstractArray{T,2})
 in call at essentials.jl:56




Reply via email to