0

Let A, B, and X be binary matrices (in F2 ) {0,1} positive values, where A and B are of size n×m with n>m (more equations than variables). X is an m×m matrix. Compute X such that AX=B.

Here, A is not a quadratic matrix.

I have A and B, and I am looking for X. What algorithm should I use to find X?

I have tried

X=pinv(A)*B; 
X=mod(X,2); 

but the results are real values and not binary (elements of finite field F2)

modou
  • 3
  • 3
  • binary form of inverse problem. search for "inverse problem" – user3528438 Feb 14 '16 at 16:52
  • 1
    This is your first post, so a bit if advice. This looks like a homework problem that you haven't put any effort into coding a solution for. Come back with any attempt at solving the problem on your own, then post a more specific question about the issues you are facing with that solution. Best of luck. – Juderb Feb 14 '16 at 16:54
  • @user3528438 i have tried X=pinv(A)*B; X=mod(X,2); but the results was not binary but real values !! – modou Feb 14 '16 at 17:00
  • @Juderb , i have looked for a solution, and i have tried X=pinv(A)*B; X=mod(X,2); but the results was not binary but real values !! – modou Feb 14 '16 at 17:01
  • You could just use `x=A\B`. The mldivide function will do the work for you, deciding which division technique works best. Using pinv is best reserved for solving least squares approximations to systems without an exact solution. If you don't get a binary matrix out, then I couldn't say why without seeing A and B. – Juderb Feb 14 '16 at 17:23
  • @Juderb, how would i contact you that i send you my A, B matrices !! – modou Feb 14 '16 at 17:29
  • @modou You don't contact people here. You post questions, and edit them to include more information if needed. –  Feb 15 '16 at 23:47

1 Answers1

1

Neither A\B nor pinv(A)*B help you any, because these commands treat matrix entries as real numbers, not as elements of finite field GF(2).

The command gflineq solves linear systems over the field GP(p) with x = gflineq(A,b,p); this command is a part of Communications System Toolbox. If you have the toolbox, then all you need to do is to put the matrix equation AX=B into the form Mx=B by stacking the columns of B, and then reshaping the solution back into matrix form. Like this:

[n, m] = size(A);
b = B(:);                 % stacked B
M = kron(eye(m), A);      % duplicated A to match
sol = gflineq(M, b, 2);   % solved Mx=b over GF(2)
X = reshape(sol, m, m);   % reshaped into matrix form X 

Now, if you don't have the Communications System Toolbox, you'll need to implement solution over GF(2) on your own. The method is standard: Gaussian elimination, and you can find lots of its implementation online. Specifically for binary matrices this algorithm is described in How can I find a solution of binary matrix equation AX = B?

Community
  • 1
  • 1