qml.math.binary_matrix_rank¶
- binary_matrix_rank(binary_matrix)[source]¶
Find the rank of a matrix over \(\mathbb{Z}_2\).
- Parameters:
binary_matrix (np.ndarray) – Matrix of binary entries.
- Returns:
Rank of
binary_matrixover the finite field \(\mathbb{Z}_2\).- Return type:
int
Note that the ranks of a matrix over \(\mathbb{Z}_2\) and over \(\mathbb{Z}\) (or \(\mathbb{R}\)) may differ.
This function does not modify the input.
Warning
This function is currently not compatible with JAX.
Example
Consider the following binary matrix of shape
(4, 4):>>> binary_matrix = np.array([ ... [0, 1, 1, 0], ... [0, 1, 0, 1], ... [1, 0, 1, 1], ... [1, 0, 0, 0], ... ]) >>> print(binary_matrix.shape) (4, 4)
We may compute its rank over \(\mathbb{Z}_2\) and find that it does not have full rank:
>>> print(qml.math.binary_matrix_rank(binary_matrix)) 3
Note that it would have full rank over the real numbers \(\mathbb{R}\):
>>> print(qml.math.linalg.matrix_rank(binary_matrix)) 4
code/api/pennylane.math.binary_matrix_rank
Download Python script
Download Notebook
View on GitHub