MacWilliams Matrices Over Finite Rings

by N. Gogin, ngiri@mail.lsi.ru

This Module recursively  generates the visual patterns of the MacWilliams matrices (Subscript[P, n]) ,  n≥ 3  modulo  odd integer m>1 according to formula
                                   (Subscript[P, n + 1])=( (UnderBar[(Subscript[P, n])])|  + |(UnderBar[(Subscript[P, n])])+  (OverBar[(Subscript[P, n])])| - |(OverBar[(Subscript[P, n])]))·(Subscript[B, n + 1])   ,  n≥ 2
where  

            (Subscript[P, 2])=(({{1, 1}, {1, -1}}))
            (Subscript[B, n + 1])= diag(1, (1/2) , ⋯ , (1/2) , 1) 
            (UnderBar[(Subscript[P, n])])| = (({{(Subscript[P, n]), 0}, {0, 0}}))= (Subscript[P, 11])  is obtained from (Subscript[P, n])  by the shown zeropadding ,  and also 
               |(UnderBar[(Subscript[P, n])]) = (Subscript[P, 12])  ,  (OverBar[(Subscript[P, n])])| = (Subscript[P, 21])  ,  |(OverBar[(Subscript[P, n])]) = (Subscript[P, 22])

         denote the correspondent zeropaddings of  (Subscript[P, n]) .

Making a Spectrum

a={{0,1,2,3,4,5,6,7,8,9,10}};

Show[Graphics[RasterArray[Table[Hue[1-a[[i,j]]/10],{i,1},{j,11}]]],AspectRatio->2/10]

hu[x_]:=If[0<=x<0.5,0.77,0.414];
br[x_]:=If[0<=x<0.1,5x+0.5,If[0.9<x<=1,-5x+5.5  , 1]];

Show[Graphics[RasterArray[Table[Hue[hu[a[[i,j]]/10](1-a[[i,j]]/10),1,br[a[[i,j]]/10]],{i,1},{j,11}]]],AspectRatio->2/9]

MacWilliams Matrices

NGI[n_, m_] := 
        Module[{G}, (hu[x_] := 
                If[0 ≤ x < 0.5, 0.77, 
                  0.414]; 
br[x_] := 
                If[0 ≤ x < 0.1, 5  x + 0.5, 
                  If[0.9 < x ≤ 1, -5 x + 5.5, 
                    1]]; 
fi = 
                Round[(m + 1)/2]; 
P = {{1, 
                    1}, {1, -1}}; s = {1, 1}; 
              q = 2; 
While[q < n, u = {q, q + 1}; 
                v = {q + 1, q + 1}; 
P11 = 
                  PadRight[PadRight[P, u], v]; 
P12 = 
                  PadRight[PadLeft[P, u], v]; 
P21 = 
                  PadLeft[PadRight[P, u], v]; 
P22 = 
                  PadLeft[PadLeft[P, u], v]; 
s = 
                  Insert[s, fi, 2]; 
                B = DiagonalMatrix[
                    s]; 
P = (P11 + P12 + P21 - P22) . 
                    B; 
P = 
                  Mod[P, m]; 
q = 
                  Length[s];]; 
(P = Reverse[P]) // 
                MatrixForm; 
G = 
                Graphics[
                  RasterArray[
                    Table[Hue[hu[P[[i, j]]/m] (1 - P[[i, j]]/m), 
                        1, br[P[[i, j]]/m]], {i, n}, {j, 
                        n}]]]; 
Show[G, 
                AspectRatio -> 1]);];

NGI[170, 17]

Module NGI can be included in any other program -
for example, with random choice of dimension "n" and module "m".
Not all of the resulting patterns will be very very picturesque,
but still I would recommend to try the following "n"-"m" pairs:
170-13 , 191-19 , 200-7 , 310-31 , 377-9 , 171-19 , 346-23 ,
400-5 , 171-17 , 312-13 , 289-29 , 327-25 , 296-27 , 230-23.