Reputation: 2640
Here is my question: How to calcul the Kernel of a Binary Matrix ??
To calcul the Kernel (or Null Space if you prefer) in Java, it's pretty simple in the Real Space, there is already a lot of classes, so don't need to invent the wheel again, we just have to use them !
double[][] data = new double[3][3];
// ... fill the Matrix
SimpleMatrix m = new SimpleMatrix(data);
SimpleSVD svd = m.svd();
SimpleMatrix nullSpace = svd.nullSpace();
nullSpace.print();
(Theses classes came from : http://efficient-java-matrix-library.googlecode.com/svn-history/r244/javadoc/ver0.14/org/ejml/data/package-summary.html )
The problem is : all theses classes work only in the Real space, and I need to do it in Z/2Z (or in the Binary space if you prefer) and I don't have the idea of how to do it ?
Do you know any good API in Java to work with Boolean Matrix ?
Or do you have any idea of how to do this kernel calcul with booleans and not real... ?
Thanks a lot in advance !
Cheers !
Upvotes: 1
Views: 1263
Reputation: 79581
The kernel of binary m-by-n matrix A is defined to be the set of binary vectors x such that Ax = 0.
Addition on the space is Boolean XOR: 0 + 0 = 1 + 1 = 0; 0 + 1 = 1 + 0 = 1.
Multiplication on the space is Boolean AND: 0 * 0 = 0 * 1 = 1 * 0 = 0; 1 * 1 = 1.
To compute the kernel basis for A, construct [A; I] and then perform elementary column operations to obtain [B; C] where B is in column echelon form. The columns of C underneath zero-columns of B are the kernel basis.
The process is described in more detail here: http://en.wikipedia.org/wiki/Kernel_(matrix)#Basis Note that the described algorithm will work for the binary case as well, even though it is not mentioned on the Wikipedia page.
I'd be surprised if you find a library that already does this, and it's trivial to implement, so I advise just coding it up yourself rather than looking for an existing solution.
Upvotes: 1