Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I convert my list of lists to fixed size matrix?

I want to create Hemming Matrix. I have just built Galois field like multiplicative group. That's what I got:

MultiplicativeGroup = DeleteDuplicates[
   NestList[
    PolynomialMod[
      PolynomialMod[(generating*#), irreducablePolynomial], 2] &, 1, 
    n]];

{1, a, a^2, 1 + a^2, 1 + a + a^2, 1 + a, a + a^2}

After that I converted it into binary form which look like this one:

CoefficientList[MultiplicativeGroup, a]

{{1}, {0, 1}, {0, 0, 1}, {1, 0, 1}, {1, 1, 1}, {1, 1}, {0, 1, 1}} But I stuck with converting it into binary matrix form. It's have to look like this one:

(0  0   1   1   1   0   1
0   1   0   0   1   1   1
1   0   0   1   1   1   0)

But I actually don't know how to do it. I can't transpose it or do anything else. Could you help me?

like image 940
Joseph Katzman Avatar asked May 06 '16 08:05

Joseph Katzman


People also ask

How do I create a fixed size list in Python?

You can use this: [None] * 10 . But this won't be "fixed size" you can still append, remove ... This is how lists are made. You could make it a tuple ( tuple([None] * 10) ) to fix its width, but again, you won't be able to change it (not in all cases, only if the items stored are mutable).

Do lists have a fixed size Python?

Although Python lists are not fixed-size and constrained like arrays in C++ or Java, they are still array type data structures where the items contained are stored in memory sequentially and accessed by an index number representing the memory block for a specific element. A list object can contain duplicate elements.


2 Answers

array = {{1}, {0, 1}, {0, 0, 1}, {1, 0, 1}, {1, 1, 1}, {1, 1}, {0, 1, 1}}

PadLeft[#, 3] & /@ Reverse[array, 2] // Transpose

enter image description here

like image 76
Kuba Avatar answered Oct 29 '22 19:10

Kuba


I did it in this way:

generating = a^Mod[(2^m - 1)/n, m];

MultiplicativeGroup = DeleteDuplicates@
   NestList[
    PolynomialMod[
      PolynomialMod[(generating*#), irreducablePolynomial], 2] &, 1, 
    n];

Print[MatrixForm[Reverse[Transpose[CoefficientList[MG, a, m]]]]];
like image 41
Joseph Katzman Avatar answered Oct 29 '22 19:10

Joseph Katzman