# scipy.linalg.block_diag¶

scipy.linalg.block_diag(*arrs)

Create a block diagonal matrix from the provided arrays.

Given the inputs A, B and C, the output will have these arrays arranged on the diagonal:

```[[A, 0, 0],
[0, B, 0],
[0, 0, C]]
```

If all the input arrays are square, the output is known as a block diagonal matrix.

Parameters : A, B, C, ... : array-like, up to 2D Input arrays. A 1D array or array-like sequence with length n is treated as a 2D array with shape (1,n). D : ndarray Array with A, B, C, ... on the diagonal. D has the same dtype as A.

References

 [R13] Wikipedia, “Block matrix”, http://en.wikipedia.org/wiki/Block_diagonal_matrix

Examples

```>>> A = [[1, 0],
...      [0, 1]]
>>> B = [[3, 4, 5],
...      [6, 7, 8]]
>>> C = [[7]]
>>> print(block_diag(A, B, C))
[[1 0 0 0 0 0]
[0 1 0 0 0 0]
[0 0 3 4 5 0]
[0 0 6 7 8 0]
[0 0 0 0 0 7]]
>>> block_diag(1.0, [2, 3], [[4, 5], [6, 7]])
array([[ 1.,  0.,  0.,  0.,  0.],
[ 0.,  2.,  3.,  0.,  0.],
[ 0.,  0.,  0.,  4.,  5.],
[ 0.,  0.,  0.,  6.,  7.]])
```

#### Previous topic

scipy.linalg.funm

#### Next topic

scipy.linalg.circulant