12
$\begingroup$

I put
{TensorProduct[{1, 0}, {0, 1}, {0, 1}, {0, 1}, {0, 1}]}/Sqrt[2]//MatrixForm and I got $$ \left( \begin{array}{cc} \left( \begin{array}{cc} \left( \begin{array}{cc} 0 & 0 \\ 0 & 0 \\ \end{array} \right) & \left( \begin{array}{cc} 0 & 0 \\ 0 & 0 \\ \end{array} \right) \\ \left( \begin{array}{cc} 0 & 0 \\ 0 & 0 \\ \end{array} \right) & \left( \begin{array}{cc} 0 & 0 \\ 0 & \frac{1}{\sqrt{2}} \\ \end{array} \right) \\ \end{array} \right) & \left( \begin{array}{cc} \left( \begin{array}{cc} 0 & 0 \\ 0 & 0 \\ \end{array} \right) & \left( \begin{array}{cc} 0 & 0 \\ 0 & 0 \\ \end{array} \right) \\ \left( \begin{array}{cc} 0 & 0 \\ 0 & 0 \\ \end{array} \right) & \left( \begin{array}{cc} 0 & 0 \\ 0 & 0 \\ \end{array} \right) \\ \end{array} \right) \\ \end{array} \right) $$ as a result. I now would like to rewrite this as $$ \left( \begin{array}{cc} 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & \frac{1}{\sqrt{2}} & 0 & 0 & 0 & 0 \end{array} \right) $$ to calculate eigenvalues of this matrix above.

Could you tell me how?

$\endgroup$
10
$\begingroup$
mat = {TensorProduct[{1, 0}, {0, 1}, {0, 1}, {0, 1}, {0, 1}]/Sqrt[2]};

FixedPoint[ArrayFlatten, mat] // MatrixForm

$\left( \begin{array}{cccccccc} 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & \frac{1}{\sqrt{2}} & 0 & 0 & 0 & 0 \\ \end{array} \right)$

| improve this answer | |
$\endgroup$
8
$\begingroup$
mat = {TensorProduct[{1, 0}, {0, 1}, {0, 1}, {0, 1}, {0, 1}]/ Sqrt[2]};

ArrayFlatten[ArrayFlatten /@ mat] // MatrixForm

$\left( \begin{array}{cccccccc} 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & \frac{1}{\sqrt{2}} & 0 & 0 & 0 & 0 \\ \end{array} \right)$

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ Yes, it was a typo. Thanks for catching.. $\endgroup$ – OkkesDulgerci Jul 18 at 3:09
7
$\begingroup$
X = {TensorProduct[{1, 0}, {0, 1}, {0, 1}, {0, 1}, {0, 1}]/Sqrt[2]};

Flatten[X, {{1, 3, 5}, {2, 4, 6}}]

(*    {{0, 0, 0, 0, 0, 0, 0, 0},
       {0, 0, 0, 0, 0, 0, 0, 0},
       {0, 0, 0, 0, 0, 0, 0, 0},
       {0, 0, 0, 1/Sqrt[2], 0, 0, 0, 0}}    *)
| improve this answer | |
$\endgroup$
  • 2
    $\begingroup$ Side note: to understand this syntax of Flatten, one may read this answer. $\endgroup$ – xzczd Jul 17 at 12:12
5
$\begingroup$

Another option

(m = {TensorProduct[{1, 0}, {0, 1}, {0, 1}, {0, 1}, {0, 1}]}/Sqrt[2]) // MatrixForm

Mathematica graphics

And now

m1 = ArrayFlatten[m[[1, 1]], 2]
m2 = ArrayFlatten[m[[1, 2]], 2]
Join[m1, m2, 2] // MatrixForm

Mathematica graphics

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.