qml.math.block_diag¶
- block_diag(values, like=None)[source]¶
Combine a sequence of 2D tensors to form a block diagonal tensor.
- Parameters
values (Sequence[tensor_like]) – Sequence of 2D arrays/tensors to form the block diagonal tensor.
- Returns
the block diagonal tensor
- Return type
tensor_like
Example
>>> t = [ ... np.array([[1, 2], [3, 4]]), ... torch.tensor([[1, 2, 3], [-1, -6, -3]]), ... torch.tensor([[5]]) ... ] >>> qml.math.block_diag(t) tensor([[ 1, 2, 0, 0, 0, 0], [ 3, 4, 0, 0, 0, 0], [ 0, 0, 1, 2, 3, 0], [ 0, 0, -1, -6, -3, 0], [ 0, 0, 0, 0, 0, 5]])
code/api/pennylane.math.block_diag
Download Python script
Download Notebook
View on GitHub