Thread Subject: binary matrix inversion

Subject: binary matrix inversion

From: Mostafa

Date: 27 Sep, 2009 18:58:03

Message: 1 of 8

How to find the inverse of a binary Matrix A ,
Note that the summation is replaced by xor operation.
searching for another matrix B such that A*B=I ( with xor instead of summation) is not efficient, is there another solutions ???

Subject: binary matrix inversion

From: Stefano

Date: 27 Sep, 2009 19:16:03

Message: 2 of 8

"Mostafa " <mmmedra@yahoo.com> wrote in message <h9ocjr$9ai$1@fred.mathworks.com>...
> How to find the inverse of a binary Matrix A ,
> Note that the summation is replaced by xor operation.
> searching for another matrix B such that A*B=I ( with xor instead of summation) is not efficient, is there another solutions ???

if you have to solve the general problem, use forward and backward gauss elimination (no pivoting is needed, very easy to code) on the matrix [A, I] obtaining [I, invA]
else, if you are looking for efficient encoding of ldpc codes... google for some paper

Subject: binary matrix inversion

From: Mostafa

Date: 29 Sep, 2009 19:54:02

Message: 3 of 8

"Stefano " <s.mangione@gmail.com> wrote in message <h9odlj$itj$1@fred.mathworks.com>...
> "Mostafa " <mmmedra@yahoo.com> wrote in message <h9ocjr$9ai$1@fred.mathworks.com>...
> > How to find the inverse of a binary Matrix A ,
> > Note that the summation is replaced by xor operation.
> > searching for another matrix B such that A*B=I ( with xor instead of summation) is not efficient, is there another solutions ???
>
> if you have to solve the general problem, use forward and backward gauss elimination (no pivoting is needed, very easy to code) on the matrix [A, I] obtaining [I, invA]
> else, if you are looking for efficient encoding of ldpc codes... google for some paper


you are speaking about the inversion of the normal matrix , I am speaking about the binary one.

Subject: binary matrix inversion

From: Stefano

Date: 29 Sep, 2009 20:33:01

Message: 4 of 8

No, I'm really speaking about the binary one :)
Don't use the xor() function, it's very slow, use mod( ,2) instead.

Stefano

"Mostafa " <mmmedra@yahoo.com> wrote in message <h9tokq$ir6$1@fred.mathworks.com>...

> you are speaking about the inversion of the normal matrix , I am speaking about the binary one.

Subject: binary matrix inversion

From: Mostafa

Date: 4 Oct, 2009 15:33:01

Message: 5 of 8

"Stefano " <s.mangione@gmail.com> wrote in message <h9tqtt$njm$1@fred.mathworks.com>...
> No, I'm really speaking about the binary one :)
> Don't use the xor() function, it's very slow, use mod( ,2) instead.
>
> Stefano
>
> "Mostafa " <mmmedra@yahoo.com> wrote in message <h9tokq$ir6$1@fred.mathworks.com>...
>
> > you are speaking about the inversion of the normal matrix , I am speaking about the binary one.


How then ?

could you write a some code?

Subject: binary matrix inversion

From: Stefano

Date: 4 Oct, 2009 16:12:02

Message: 6 of 8

% Gauss elimination to invert A
temp = [A,eye(N)];

% forward
for i = 1:N
   % if the current row does not have a 1 in column i, find a row j >
   % i with a 1 in column i and add it to row i
   if temp(i,i) == 0
      % some code here
   end
   % forward gauss elimination
   for j=i+1:N
      if temp(j,i)
         % code here...
      end
   end
end
% backward
for i=N:-1:2
   for j=i-1:-1:1
      if temp(j,i)
         % some more code here...
      end
   end
end
invA = temp(:,N+1:end);

OK?



"Mostafa " <mmmedra@yahoo.com> wrote in message <haaf7d$edk$1@fred.mathworks.com>...
> "Stefano " <s.mangione@gmail.com> wrote in message <h9tqtt$njm$1@fred.mathworks.com>...
> > No, I'm really speaking about the binary one :)
> > Don't use the xor() function, it's very slow, use mod( ,2) instead.
> >
> > Stefano
> >
> > "Mostafa " <mmmedra@yahoo.com> wrote in message <h9tokq$ir6$1@fred.mathworks.com>...
> >
> > > you are speaking about the inversion of the normal matrix , I am speaking about the binary one.
>
>
> How then ?
>
> could you write a some code?

Subject: binary matrix inversion

From: Mostafa

Date: 9 Dec, 2009 22:12:06

Message: 7 of 8

"Stefano " <s.mangione@gmail.com> wrote in message <haahgi$etg$1@fred.mathworks.com>...
> % Gauss elimination to invert A
> temp = [A,eye(N)];
>
> % forward
> for i = 1:N
> % if the current row does not have a 1 in column i, find a row j >
> % i with a 1 in column i and add it to row i
> if temp(i,i) == 0
> % some code here
> end
> % forward gauss elimination
> for j=i+1:N
> if temp(j,i)
> % code here...
> end
> end
> end
> % backward
> for i=N:-1:2
> for j=i-1:-1:1
> if temp(j,i)
> % some more code here...
> end
> end
> end
> invA = temp(:,N+1:end);
>
> OK?
>
>
>
> "Mostafa " <mmmedra@yahoo.com> wrote in message <haaf7d$edk$1@fred.mathworks.com>...
> > "Stefano " <s.mangione@gmail.com> wrote in message <h9tqtt$njm$1@fred.mathworks.com>...
> > > No, I'm really speaking about the binary one :)
> > > Don't use the xor() function, it's very slow, use mod( ,2) instead.
> > >
> > > Stefano
> > >
> > > "Mostafa " <mmmedra@yahoo.com> wrote in message <h9tokq$ir6$1@fred.mathworks.com>...
> > >
> > > > you are speaking about the inversion of the normal matrix , I am speaking about the binary one.
> >
> >
> > How then ?
> >
> > could you write a some code?


Thanks , it worked very nice.

Subject: binary matrix inversion

From: Weizheng

Date: 8 Feb, 2010 03:40:07

Message: 8 of 8

Hello Stefano,
Can you give more details of your code? I am new with Matlab and I'm not familiar with backward Gaussian elimination. Thank you very much!

Hunter

"Stefano " <s.mangione@gmail.com> wrote in message <haahgi$etg$1@fred.mathworks.com>...
> % Gauss elimination to invert A
> temp = [A,eye(N)];
>
> % forward
> for i = 1:N
> % if the current row does not have a 1 in column i, find a row j >
> % i with a 1 in column i and add it to row i
> if temp(i,i) == 0
> % some code here
> end
> % forward gauss elimination
> for j=i+1:N
> if temp(j,i)
> % code here...
> end
> end
> end
> % backward
> for i=N:-1:2
> for j=i-1:-1:1
> if temp(j,i)
> % some more code here...
> end
> end
> end
> invA = temp(:,N+1:end);
>
> OK?
>
>
>
> "Mostafa " <mmmedra@yahoo.com> wrote in message <haaf7d$edk$1@fred.mathworks.com>...
> > "Stefano " <s.mangione@gmail.com> wrote in message <h9tqtt$njm$1@fred.mathworks.com>...
> > > No, I'm really speaking about the binary one :)
> > > Don't use the xor() function, it's very slow, use mod( ,2) instead.
> > >
> > > Stefano
> > >
> > > "Mostafa " <mmmedra@yahoo.com> wrote in message <h9tokq$ir6$1@fred.mathworks.com>...
> > >
> > > > you are speaking about the inversion of the normal matrix , I am speaking about the binary one.
> >
> >
> > How then ?
> >
> > could you write a some code?

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
binary matrix i... Mostafa 27 Sep, 2009 14:59:05
rssFeed for this Thread

Contact us at files@mathworks.com