5

I need an efficient algorithm or a known way to determine the mathematical rank of a matrix A with coefficients in a field of positive characteristic.

For example, in the finite field of 5 elements I have the following matrix:

import numpy
A=[[2,3],[3,2]]
print numpy.linalg.matrix_rank(A)

This method gives me the result of 2, but in characteristic 5 this matrix has rank 1 since [2,3]+[3,2]=[0,0].

Andy K
  • 4,944
  • 10
  • 53
  • 82

1 Answers1

3

Numpy doesn't have built-in support for finite fields. The matrix A in your code is treated as a matrix of real numbers, and hence has rank 2.

If you really need to support finite fields with Numpy, you'll have to define your own data type along with the arithmetic operations yourself, as shown here. There are of course the concerns about proper error handling (like divide by zero).

Even then, many common routines will have to be rewritten to support your field data types. For example, from the numpy.linalg.matrix_rank documentation, the routine uses Singular Value Decomposition (SVD), which is not well defined for finite fields, so you'll have to code the rank finding algorithm yourself.

As for the algorithm itself, you could try implementing plain old Gaussian Elimination along these lines, but this can be a pain in the neck and really slow, so you will likely be better off with other tools/packages like Sage.

Community
  • 1
  • 1