For sparse arrays, you can use `blkdiag()`.

For v0.3, the method David posted is probably the best approach.

Starting in v0.4, you can call `cat([1,2], matrices...)` where the 
`matrices` variable is your array of arrays. Note that the splat is 
undesirable if this container is quite large.

On Wednesday, June 3, 2015 at 12:07:19 PM UTC-5, Marc Gallant wrote:
>
> If I have an array of square matrices of different sizes; e.g.,
>
> 3-element Array{Array{Float64,2},1}:
>  2x2 Array{Float64,2}:
>  0.539932  0.429322
>  0.623487  0.0397795
>  2x2 Array{Float64,2}:
>  0.35508   0.700551
>  0.768214  0.954056
>  3x3 Array{Float64,2}:
>  0.953354  0.453831   0.991583
>  0.159975  0.116518   0.355275
>  0.791447  0.0104295  0.151609
>
>
> Where the number of elements may be much larger than 3 (e.g., 1000), how 
> do I construct a block diagonal matrix, where the blocks are the matrices 
> in the array? For the array above, this would be
>
> 7x7 Array{Float64,2}:
>  0.539932  0.429322   0.0       0.0       0.0       0.0        0.0
>  0.623487  0.0397795  0.0       0.0       0.0       0.0        0.0
>  0.0       0.0        0.35508   0.700551  0.0       0.0        0.0
>  0.0       0.0        0.768214  0.954056  0.0       0.0        0.0
>  0.0       0.0        0.0       0.0       0.953354  0.453831   0.991583
>  0.0       0.0        0.0       0.0       0.159975  0.116518   0.355275
>  0.0       0.0        0.0       0.0       0.791447  0.0104295  0.151609
>
>

Reply via email to