Null Space Binary Matrix : Java

最后都变了- 提交于 2019-12-08 04:49:58

问题


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 !


回答1:


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.



来源:https://stackoverflow.com/questions/25098015/null-space-binary-matrix-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!