inverse of randomly generated binary matrix in matlab

1.2k views Asked by At

I have generated binary non singular matrix of size 602*602

l = 602;
w = round (rand (l,l));

now I want to find the inverse of this matrix in binary form, I tried this command

 w_inv = mod(inv(w),2)

but the result is not in binary form. HELP!

2

There are 2 answers

0
Stefano M On BEST ANSWER

If you have the Communications Systems Toolbox installed inverse in GF(2) can be obtained as simply as

>> l = 602;
>> w = gf(round(rand (l,l)));
>> whos
  Name        Size               Bytes  Class     Attributes

  l           1x1                    8  double              
  w         602x602            1450156  gf                  

>> b = inv(w);
>> all(all(b*w == eye(l,l)))

ans =

     1

>> all(all(w*b == eye(l,l)))

ans =

     1

>> 

cfr. Galois Field Computations and Create Galois field array. BTW, over the real field the determinant of w is not infinite, just to big to be represented as an IEEE floating point number.

3
Luis Mendo On

Firstly, the way you generate the matrix w doesn't assure it will be non-singular; only that in most cases it will be.

Leaving that aside, the inverse of w is inv(w). That's the only matrix that multiplied by w will give the identity matrix. And of course, the inverse matrix will not be binary (or even integer-valued) in general. If you apply mod(,... ,2) to the inverse it ceases to be the inverse matrix.


A different question would be to find an inverse matrix in GF(2), that is, using modulo-2 addition. If that's your case, see here.