@ggggg Sorry, I guess I didn't state my intent that clearly. While your
example does enforce the Matrix/eltype constraint that is only part of what
I am after. Having a type parameter for each block is a main thing that I
am interested in. The reason is that I can write methods that dispatch on
those types. An example of such a method with an explicit 4-ary structure
would be
#generic fallback
det(A::Matrix,B::Matrix,C::Matrix,D::Matrix) = det([A B; C D])
#specialized method, should actually, check for A invertible, but you get
the idea
det(A::Diagonal,B::Diagonal,C::Diagonal,D::Diagonal) =
det(A)*det(D-C*inv(A)*B)
#etc...
In my applications there are at least a dozen situations where certain
block structure allow for significantly more efficient implementations than
the generic fallback. One would like to make the calls to these methods
(det,inv,trace, and so on) with the normal 1-ary argument, that matrix M
itself. This would be possible if the type information of the blocks could
be read out of the type of M. I hope this clear up my motivation for the
above question.
On Thursday, March 12, 2015 at 8:49:05 PM UTC+1, ggggg wrote:
>
> BlockMatrix only needs one type parameter to fully specify the type, so
> you should probably only use one type parameter. Like so:
>
> *type BlockMatrix{S} <: AbstractMatrix{S}*
>>
>> * A::AbstractMatrix{S}*
>>
>> * B::AbstractMatrix{S}*
>>
>> * C::AbstractMatrix{S}*
>>
>> * D::AbstractMatrix{S}*
>>
>> *end*
>>
>>
> I'm sure someone else can explain in more detail why yours didn't work.
>