qiskit_qec.linear.rref_complete

rref_complete(matrix)[source]

Computes the Row Reduced Echelon Form for a GF(2) matrix as well as pivots, transformation matrix and rank.

Parameters:

matrix (ndarray) – Input GF(2) matrix.

Return type:

Tuple[List[int], ndarray, ndarray, int]

Returns:

heads

A 0-1 list with value of position k being 1 if the kth column is a pivot

rref_mat

Row Reduced Echelon Form of input matrix

transform_mat

Transform used to tranform input matrix into RREF form

rank

rank of input matrix

Raises:
  • QiskitError – Not a suitable matrix input”)

  • QiskitError – Not a two dimensional matrix”)

Examples

>>> matrix = numpy.array([[1,0,0,1,0,0,1,0],
                          [0,1,1,1,0,0,0,1],
                          [1,1,1,0,1,0,0,0],
                          [1,0,0,1,0,1,0,1]], dtype=np.bool_)
>>> heads, rref_mat, transform_mat, rank_ = rref_complete(matrix)
>>> heads
[1, 1, 0, 0, 1, 1, 0, 0]
>>> rref_mat.astype(int)
array([[1, 0, 0, 1, 0, 0, 1, 0],
       [0, 1, 1, 1, 0, 0, 0, 1],
       [0, 0, 0, 0, 1, 0, 1, 1],
       [0, 0, 0, 0, 0, 1, 1, 1]])
>>> transform_mat.astype(int)
array([[1, 0, 0, 0],
       [0, 1, 0, 0],
       [1, 1, 1, 0],
       [1, 0, 0, 1]])
>>> rank_
4

See Also: _rref_complete, rref, _rref