Finding accurate inverse of binary circulant matrix

조회 수: 8 (최근 30일)
Corbin
Corbin 2024년 6월 10일
댓글: Corbin 2024년 6월 11일
I would like to find the inverse of a binary circulant matrix using MATLAB. I have the 24x24 binary circulant matrix stored in BCM and use the function inv(BCM) and I get a lot of garbage values. I have the inverse matrix that I am expecting to get, which is the multiplicative inverse of BCM. When I multiply them in MATLAB, I get the identity matrix which is correct. However, I'm going to need to calculate new inverses of new matrices and would like to do so with MATLAB instead of guessing over and over. How can I do this?
Both BCM and it's inverse are stored in the attached Excel spreadsheet. Thank you!
Garbage Values:
  댓글 수: 2
Steven Lord
Steven Lord 2024년 6월 11일
Are you trying to take the inverse mod 2 (or in GF(2))?
If so the gf function in Communications Toolbox may be of use to you.
Corbin
Corbin 2024년 6월 11일
I didn't know it then but from @Torsten's answer I know that's exactly what I need now, so thank you very much! You guys are very prompt and quick in your answers!

댓글을 달려면 로그인하십시오.

채택된 답변

Torsten
Torsten 2024년 6월 11일
BCM=readmatrix('MixingLayer.xlsx');
inv(gf(BCM,2))
ans = GF(2^2) array. Primitive polynomial = D^2+D+1 (7 decimal) Array elements = 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0
  댓글 수: 1
Corbin
Corbin 2024년 6월 11일
This is exactly what I was looking for! Thank you very much :)
You're absolutely correct about the 0 and 1. I forgot to mention that.
I didn't know that finite fields were used in the calculation, and I know that now! This is very helpful to know!

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Matt J
Matt J 2024년 6월 10일
편집: Matt J 2024년 6월 10일
We don't know what it is that you consider improper about the results of inv(). The test below indicates to me that everything is fine.
BCM=readmatrix('MixingLayer.xlsx');
[low,high]=bounds(BCM*inv(BCM)- eye(size(BCM)) ,'all')
low = -3.6082e-16
high = 2.7756e-16

John D'Errico
John D'Errico 2024년 6월 10일
편집: John D'Errico 2024년 6월 11일
Gosh. I thought that multiplying a matrix by its inverse gives an identity matrix. :)
A = readmatrix('MixingLayer.xlsx','sheet','BCM');
Ainv = readmatrix('MixingLayer.xlsx','sheet','inverseBCM');
A*Ainv
ans = 24x24
1 0 0 0 0 0 0 0 2 0 2 0 0 0 0 0 0 0 0 0 2 0 2 0 0 1 0 0 0 0 0 0 0 2 0 2 0 0 0 0 0 0 0 0 0 2 0 2 2 0 1 0 0 0 0 0 0 0 2 0 2 0 0 0 0 0 0 0 0 0 2 0 0 2 0 1 0 0 0 0 0 0 0 2 0 2 0 0 0 0 0 0 0 0 0 2 2 0 2 0 1 0 0 0 0 0 0 0 2 0 2 0 0 0 0 0 0 0 0 0 0 2 0 2 0 1 0 0 0 0 0 0 0 2 0 2 0 0 0 0 0 0 0 0 0 0 2 0 2 0 1 0 0 0 0 0 0 0 2 0 2 0 0 0 0 0 0 0 0 0 0 2 0 2 0 1 0 0 0 0 0 0 0 2 0 2 0 0 0 0 0 0 0 0 0 0 2 0 2 0 1 0 0 0 0 0 0 0 2 0 2 0 0 0 0 0 0 0 0 0 0 2 0 2 0 1 0 0 0 0 0 0 0 2 0 2 0 0 0 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
And, honestly, it does not look like an identity matrix. ;-) But then what do I know?
norm(A*Ainv - eye(24))
ans = 8
Norm tells us the product of the two is not even close to an identity. And yes, the actual inverse matrix is not the same as what you give. But it does have the properties of an inverse matrix, a good thing.
inv(A)
ans = 24x24
0.2540 0 -0.1270 0 0.0635 0 -0.0317 0 0.0159 0 -0.5079 0 0.2540 0 -0.1270 0 0.0635 0 -0.0317 0 0.0159 0 0.4921 0 0 0.2540 0 -0.1270 0 0.0635 0 -0.0317 0 0.0159 0 -0.5079 0 0.2540 0 -0.1270 0 0.0635 0 -0.0317 0 0.0159 0 0.4921 0.4921 0 0.2540 0 -0.1270 0 0.0635 0 -0.0317 0 0.0159 0 -0.5079 0 0.2540 0 -0.1270 0 0.0635 0 -0.0317 0 0.0159 0 0 0.4921 0 0.2540 0 -0.1270 0 0.0635 0 -0.0317 0 0.0159 0 -0.5079 0 0.2540 0 -0.1270 0 0.0635 0 -0.0317 0 0.0159 0.0159 0 0.4921 0 0.2540 0 -0.1270 0 0.0635 0 -0.0317 0 0.0159 0 -0.5079 0 0.2540 0 -0.1270 0 0.0635 0 -0.0317 0 0 0.0159 0 0.4921 0 0.2540 0 -0.1270 0 0.0635 0 -0.0317 0 0.0159 0 -0.5079 0 0.2540 0 -0.1270 0 0.0635 0 -0.0317 -0.0317 0 0.0159 0 0.4921 0 0.2540 0 -0.1270 0 0.0635 0 -0.0317 0 0.0159 0 -0.5079 0 0.2540 0 -0.1270 0 0.0635 0 0 -0.0317 0 0.0159 0 0.4921 0 0.2540 0 -0.1270 0 0.0635 0 -0.0317 0 0.0159 0 -0.5079 0 0.2540 0 -0.1270 0 0.0635 0.0635 0 -0.0317 0 0.0159 0 0.4921 0 0.2540 0 -0.1270 0 0.0635 0 -0.0317 0 0.0159 0 -0.5079 0 0.2540 0 -0.1270 0 0 0.0635 0 -0.0317 0 0.0159 0 0.4921 0 0.2540 0 -0.1270 0 0.0635 0 -0.0317 0 0.0159 0 -0.5079 0 0.2540 0 -0.1270
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
A quick check of the condition number of A shows a very small number. And since A is full rank, the inverse exists, and is unique.
cond(A)
ans = 3.0000
norm(A*inv(A) - eye(24))
ans = 9.9603e-16
I'm sorry, but we cannot know why you think that matrix is the inverse of the binary matrix you show. But it is not. Not even close.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by