This resource function is obsolete. Use the built-in symbol BlockDiagonalMatrix instead.

Function Repository Resource:

BlockDiagonalMatrix

Source Notebook

Create a block-diagonal matrix from submatrices

Contributed by: Bob Sandheinrich

ResourceFunction["BlockDiagonalMatrix"][m1,m2,]

constructs a matrix with submatrices mi on the diagonal.

Details and Options

The submatrices mi are included in the specified order.
The submatrices need not be square.
{} and {{}} are treated as 0×0 submatrices.

Examples

Basic Examples (2) 

Create a block-diagonal matrix from three matrices:

In[1]:=
ResourceFunction[
  "BlockDiagonalMatrix"][{{1, 2}, {3, 4}}, {{5}}, {{6}}] // MatrixForm
Out[1]=

Use non-square matrices:

In[2]:=
ResourceFunction[
  "BlockDiagonalMatrix"][{{1, 2}}, {{3}, {4}}] // MatrixForm
Out[2]=

Scope (1) 

Empty lists are treated as zero-dimensional matrices:

In[3]:=
ResourceFunction["BlockDiagonalMatrix"][{}, DiagonalMatrix[{1, 2, 3}]] // MatrixForm
Out[3]=

Properties and Relations (1) 

The dimensions of the result are the sum of the dimensions of the submatrices:

In[4]:=
m1 = {{1, 2, 3}, {4, 5, 6}};
m2 = DiagonalMatrix[{a, b, c}]; block = ResourceFunction["BlockDiagonalMatrix"][m1, m2]
Out[5]=
In[6]:=
Dimensions[block]
Out[6]=
In[7]:=
Plus @@ Dimensions /@ {m1, m2}
Out[7]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.0 – 13 December 2018

License Information