I have a matrix, G (size PxN), and I would like to make the first N/2 columns of G form the N/2×N/2 identity matrix by row operations. Any idea how I could write code for this? (not using sympy.rref).
Note P is a prime number slightly larger than N.
The matrix itself is a vandermonde matrix over the field of P i.e. all values are modulo P.
def ReedSolomon(k,p):
rr = np.arange(k).reshape((-1, 1))
cc = np.arange(p)
return cc**rr % p
An example would be:
ReedSolomon(4,5)
= [[1, 1, 1, 1, 1],
[0, 1, 2, 3, 4],
[0, 1, 4, 4, 1],
[0, 1, 3, 2, 4]]
And i would like to produce the following:
= [[1, 0, -1, -2, -3],
[0, 1, 2, 3, 4],
[0, 1, 4, 4, 1],
[0, 1, 3, 2, 4]]
In this case the N/2 x N/2 submatrix is the identity.
Using sympy.rref would lead to some rows being swapped around and for more rows to be reduced. I would like to stop once the N/2 columns have been turned into the identity. Hence writing custom code is preferred.
Thanks!