qiskit_qec.linear.augment_mat

augment_mat(matrix, pos='right')[source]

Augments a given matrix with the identify matrix. The position of the identity matrix is given by the optional position argument left -> [M | I]

right -> [I | M]

top -> [I]

[M]

bottom -> [M]

[I]

Parameters:
  • matrix (ndarray) – Matrix to agument

  • pos (str) – Position of augmentation. One of “top”, “bottom” “left” or “right”

Raises:
  • QiskitError – Input array must have two dimensions

  • QiskitError – Unknown position

Return type:

ndarray

Returns:

Matrix augmented with identity

Examples

>>> matrix = numpy.array([[0,1,0],[0,0,1],[1,1,0]], dtype=numpy.bool_)
>>> x = augment_mat(matrix)
>>> x
array([[False,  True, False,  True, False, False],
    [False, False,  True, False,  True, False],
    [ True,  True, False, False, False,  True]])
>>> matrix = numpy.array([[0,1,0],[0,0,1],[1,1,0]], dtype=numpy.bool_)
>>> x = augment_mat(matrix, pos="bottom")
>>> x
array([[False,  True, False],
    [False, False,  True],
    [ True,  True, False],
    [ True, False, False],
    [False,  True, False],
    [False, False,  True]])

See Also: _augment_mat