I need to create Boolean/Binary arrays with rows representing the binary form of each number in given a range. Each column hold values for a given bit position. The range is determined by the bit-width and binary encoding scheme. Then I need to count the number of cells in a column that do not match the preceding cell.
I believe the counting process is simply XORing the array with itself shifted down one row. The sum of each column in the XOR result is my transition count.
I need to do this for each combination of [signed, unsigned] values encoded as [hexadecimal, octal, decimal]. Mismatches between the encoding scheme and available bits results in unusable bits.
e.g. A 4-bit unsigned octal array would still only have 8 rows. However, if it is signed then that 4th bit is used for sign and the array is the full 16 rows.
The ultimate goal is to create labeled set of summary n-grams for the number of transitions at each bit position for various bit widths, encoding, and use of sign. The summary n-gram for example 1 would be {3-bit, octal, unsigned, [1, 3, 7]}. The summary n-gram for example 3 is {4-bit, octal, signed, [1, 2, 6, 13]}. Example 4 is {4-bit, hexadecimal, signed, [1, 2, 6, 13]}.
Examples:
1) 8x3 Binary array of all possible 3-bit unsigned octal values:
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
2) 8x4 Binary array of all possible 4-bit unsigned octal values:
Same as #1 except with an additional leftmost column of all zeros
3) 16x4 Binary array of all possible 4-bit signed octal values:
Note: It's ok to double count zero (-0 and +0)
1 1 1 1
1 1 1 0
1 1 0 1
1 1 0 0
1 0 1 1
1 0 1 0
1 0 0 1
1 0 0 0
0 0 0 0
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
0 1 0 1
0 1 1 0
0 1 1 1
4) 16x4 Binary array of all possible 4-bit signed hexadecimal values:
Same as #3