Using good method to produce a regular matrix

The matrixform is as follow, and how can I use good method to produce it?

H = {{1, 1, 0}, {2, 2, 0}, {0, 1, 1},
{0, 2, 2}, {1, 0, 1}, {2, 0, 2}}

• If the picture can't show,then here is the matrixform:H={{1,1,0},{2,2,0},{0,1,1},{0,2,2},{1,0,1},{2,0,2}} – KarryMa Apr 6 at 9:22
• KroneckerProduct[ MapThread[ ReplacePart[#1, #2 -> 0] &, {ConstantArray[1, {3, 3}], RotateRight[Range[3]]}], {{1}, {2}} ] – Henrik Schumacher Apr 6 at 9:25
• Great,thank you very much! – KarryMa Apr 6 at 9:26
• Or Normal@KroneckerProduct[ SparseArray[{Band[{1, 1}] -> 1, Band[{1, 2}] -> 1, Band[{3, 1}] -> 1}, {3, 3}], {{1}, {2}} ]. – Henrik Schumacher Apr 6 at 9:27
• Transpose@KroneckerProduct[Permutations[{1, 0, 1}], {1, 2}] – LouisB Apr 6 at 9:45

A nice tool for this job is ArrayFlatten[ ]

a = {{1}, {2}}


$$\left( \begin{array}{c} 1 \\ 2 \\ \end{array} \right)$$

Not sure why your rows are ordered the way they are. Are you trying to have a non-zero diagonal?

{{a,a,0},{0,a,a},{a,0,a}}// ArrayFlatten


$$\left( \begin{array}{ccc} 1 & 1 & 0 \\ 2 & 2 & 0 \\ 0 & 1 & 1 \\ 0 & 2 & 2 \\ 1 & 0 & 1 \\ 2 & 0 & 2 \\ \end{array} \right)$$

• This is not the exact result the OP is asking. The order of the elements is different. Also the "permutation" solution is already posted in my answer – J42161217 Apr 6 at 14:58
• My purpose was to introduce ArrayFlatten. Not enough info to algorithmically determine the order of perms. – MikeY Apr 6 at 15:27
• Actually,this is the answer I originally wanted,then I will use ''PauliMatrix'' and ''Map'' to get what I want.Thank you for your help! – KarryMa Apr 7 at 2:35
IntegerDigits[{12,24,4,8,10,20},3,3]


{{1,1,0},{2,2,0},{0,1,1},{0,2,2},{1,0,1},{2,0,2}}

also..

s = Transpose[Permutations /@ {{1, 1, 0}, {2, 2, 0}}];
Flatten[{{s[[1]]},Reverse@Rest@s},2]


{{1,1,0},{2,2,0},{0,1,1},{0,2,2},{1,0,1},{2,0,2}}

• I like the answer,thanks! – KarryMa Apr 6 at 9:55
• @KarryMa Alternatively to PadLeft you can add 3 as 3rd argument IntegerDigits[{12, 24, 4, 8, 10, 20}, 3, 3]. – Coolwater Apr 6 at 14:49
• yes, you are so right! – J42161217 Apr 6 at 14:51