Binary matrix is a matrix with all the entries restriced in $$$\mathbb{F}_2$$$ which is the finite field with only two elements 0 and 1. Thus, each entry of the matrix can only take the value 0 and 1.
The arithmetic operations on finite field $$$ \mathbb{F}_2 $$$ follow the rules:
- $$$ 0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1, 1 + 1 = 0 $$$
- $$$ 0 \times 0 = 0, 0 \times 1 = 1, 1\times 0 = 0, 1\times 1 = 1 $$$
This project contains a module binmatrix.py. This module computes some properties of binary matrices. To be Specific:
- Compute the Rank of the given binary matrix.
- Compute the determinant of the given binary matrix if this matrix is a square matrix.
- Compute the inverse of a given binary matrix if this matrix is a square matrix and full rank.
All the arithmetic operations are on the finite field $$$\mathbb{F}_2$$$. test.py tests the module by a given binary matrix.
This module defines a python class class BinMatrix:
. If m
is a binary matrix, you can instantiate a BinMatrix
object by matrix = BinMatrix(m)
. Then you can compute:
matrix.rank()
returns the Rank of the binary matrix.matrix.det()
returns the determinant of the binary matrix.matrix.inv()
returns the inverse of the binary matrix.