Walsh permutation; nimber multiplication
Walsh permutation |
Sets of consecutive integers from 0 are closed under nim-multiplication when their cardinalities are Fermat 2-powers 2, 4, 16, 256, 65536... ( A001146)
So useful nim-multiplication tables are square matrices of size .
Their rows are -bit Walsh permutations, and the corresponding compression vectors give a matrix.
The columns of this matrix are again Walsh permutations.
Their compression vectors give a square matrix of size , which is thus a compression of the multiplication table.
(Of course there is no Walsh permutation wp(zeros), but here it makes sense to write it that way.)
There is another -bit Walsh permutation corresponding to each multiplication table, which is the bitwise XOR of the other ones.
Its compression vector is the bitwise XOR of their compression vectors.
Multiplication tables and compression vectors
edit1 | ||||||
0 | 1 | CM | CV | |||
---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | |||
1 | 0 | 1 | 1 |
1 | 2 | 3 | |||||||||
2 | 3 | 1 | |||||||||
0 | 1 | 2 | 3 | CM | CV | X | |||||
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ||||
1 | 0 | 1 | 2 | 3 | 1 | 2 | 3 | ||||
2 | 0 | 2 | 3 | 1 | 2 | 3 | 1 | ||||
3 | 0 | 3 | 1 | 2 | 3 | 1 | 2 |
wp(2,3,8,12) and wp(3,1,12,4) appear also in section Bent functions as (P0)2 and (P0T)2 |
Matrices |
---|
Nim-multiplication table: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 2 3 1 8 10 11 9 12 14 15 13 4 6 7 5 0 3 1 2 12 15 13 14 4 7 5 6 8 11 9 10 0 4 8 12 6 2 14 10 11 15 3 7 13 9 5 1 0 5 10 15 2 7 8 13 3 6 9 12 1 4 11 14 0 6 11 13 14 8 5 3 7 1 12 10 9 15 2 4 0 7 9 14 10 13 3 4 15 8 6 1 5 2 12 11 0 8 12 4 11 3 7 15 13 5 1 9 6 14 10 2 0 9 14 7 15 6 1 8 5 12 11 2 10 3 4 13 0 10 15 5 3 9 12 6 1 11 14 4 2 8 13 7 0 11 13 6 7 12 10 1 9 2 4 15 14 5 3 8 0 12 4 8 13 1 9 5 6 10 2 14 11 7 15 3 0 13 6 11 9 4 15 2 14 3 8 5 7 10 1 12 0 14 7 9 5 11 2 12 10 4 13 3 15 1 8 6 0 15 5 10 1 14 4 11 2 13 7 8 3 12 6 9 Compression vectors: 0 0 0 0 1 2 4 8 2 3 8 12 3 1 12 4 8 12 5 10 9 14 1 2 10 15 13 6 11 13 9 14 12 4 10 15 13 6 14 7 14 7 2 3 15 5 6 11 4 8 15 5 5 10 11 13 6 11 7 9 7 9 3 1 |
In the table above it can be seen that all rows (in the nim-multiplication table and in the table of compression vectors) are bit-XORs of 2-power rows.
(So both columns and rows of the beige square matrix appear as compression vectors.)
Further it can be seen that the nim-products of 2-powers are related to the compression vectors on the right.
(Read the compression matrices on the right row by row instead of column by column.)
So in the end all the information in the table of nim-products is compressed in the table of nim-products of 2-powers.
Demonstration in Matlab |
---|
Two calculations of the 256x256 nim-multiplication table, here called WP: >> B
B =
1 2 4 8 16 32 64 128
2 3 8 12 32 48 128 192
8 12 5 10 128 192 80 160
12 4 10 15 192 64 160 240
192 64 160 240 17 34 68 136
64 128 240 80 34 51 136 204
240 80 96 176 136 204 85 170
80 160 176 208 204 68 170 255
>> %%%%% Calculation of WP1:
>>
>> tic
CV = zeros(256,8) ;
for m=1:8
CV(1:256,m) = cv2wp( B(:,m)' )' ; % Take the columns of B as compression vectors and turn them into Walsh permutations, which go to the columns of CV.
end
WP1 = zeros(256) ;
for m=2:256
WP1(m,1:256) = cv2wp( CV(m,:) ) ; % Take the rows of CV as compression vectors and turn them into Walsh permutations, which go to the rows of WP1.
end
toc
Elapsed time is 0.688750 seconds.
>>
>> %%%%% Extract of the 256x8 matrix CV:
>>
>> [ num2str( [0:17]' ) repmat(' ',18,10) num2str( CV(1:18,:) ) ]
ans =
0 0 0 0 0 0 0 0 0
1 1 2 4 8 16 32 64 128 % Row 0 of B (Would be called B(1,:) in Matlab.)
2 2 3 8 12 32 48 128 192 % Row 1 of B
3 3 1 12 4 48 16 192 64
4 8 12 5 10 128 192 80 160 % Row 2 of B
5 9 14 1 2 144 224 16 32
6 10 15 13 6 160 240 208 96
7 11 13 9 14 176 208 144 224
8 12 4 10 15 192 64 160 240 % Row 3 of B
9 13 6 14 7 208 96 224 112
10 14 7 2 3 224 112 32 48
11 15 5 6 11 240 80 96 176
12 4 8 15 5 64 128 240 80
13 5 10 11 13 80 160 176 208
14 6 11 7 9 96 176 112 144
15 7 9 3 1 112 144 48 16
16 192 64 160 240 17 34 68 136 % Row 4 of B
17 193 66 164 248 1 2 4 8
>> %%%%% Calculation of WP2:
>>
>>
>> tic
WP2 = zeros(256) ;
for m=1:256
for n=1:256
WP2(m,n) = nimprod(m-1,n-1) ;
end
end
toc
Elapsed time is 730.700629 seconds.
>>
>> %%%%% Compare:
>>
>> isequal(WP1,WP2) % Are WP1 and WP2 equal?
ans =
1 % Yes.
|
The multiplication table of the nimbers 0..255 is here.
The 8 elements of the dual matrix are here.
Infinite arrays
editMatrices | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Here is a closer look at the nim-products of the first 16 powers of 2 ( A223541).
It shows the binary representation of the entries and the dual matrix where bits with the same position are shown together:
Representation as binary tensors | |||
---|---|---|---|
Although it is hard to see, each tensor can be produced from the other one by rotation. | |||
|
|
The compressed multiplication table of the first 256 nimbers ( A223537):
Read by rows these are the compression vectors of rows 1,2,4,8,...,128.
The diagonal is A001317 (Sierpinski triangle rows read like binary numbers).