Been struggling with something for a while. I use a lot of arrays of matrices so I wanted to create a typealias for it like this:
typealias MatrixCell{T<:Number} Array{Matrix{T},1}
This way I can easily create an array of matrices of predefined length, for example
A=MatrixCell(2); A[1]=rand(4,4);A[2]=rand(2,2);
However, if I define a function like this:
function test{T<:Number}(A::MatrixCell{T})
println(typeof(A));
end
calling
test(A)
gives following error:
ERROR: MethodError: no method matching test(::Array{Array{T<:Number,2},1})
Closest candidates are:
test{T<:Number}(::Array{Array{T<:Number,2},1}) at REPL[3]:2
Now this is really confusing, since the methods match.
I can work around by removing T<:Number from both MatrixCell and function defintion, but then the function does not work with arrays defined as
B=[rand(4,3),rand(3,3)]
Any ideas? Thanks!