1
$\begingroup$

I want to get the tensor product of two column vectors, for example:

a = {1, 2, 3};
b = {2, 3, 1};
psi0 = ArrayFlatten[TensorProduct[a, b]];

The size of psi0 is $ 3 \times 3 $, but it should be a column vector with 9 components.

What am I doing wrong?

$\endgroup$
5
  • $\begingroup$ Use Flatten instead of ArrayFlatten? $\endgroup$
    – Roman
    Jun 28, 2019 at 15:17
  • 1
    $\begingroup$ Or maybe ArrayFlatten[...,1]? $\endgroup$ Jun 28, 2019 at 15:20
  • 2
    $\begingroup$ BTW there are no "column vectors" in Mathematica. See here and here for discussions. $\endgroup$
    – Roman
    Jun 28, 2019 at 15:25
  • $\begingroup$ thanks, ArrayFlatten[...,1] $\endgroup$
    – F.Mark
    Jun 28, 2019 at 18:26
  • $\begingroup$ First, a row/column vector is somewhat a redundant choice in Wolfram language, which can be uniformly represented by a List. Then please compare TensorProduct and KroneckerProduct. $\endgroup$ May 18, 2020 at 10:17

1 Answer 1

2
$\begingroup$

As already noted, what is wanted can be obtained using either of TensorProduct[{1, 2, 3}, {2, 3, 1}] or KroneckerProduct[{1, 2, 3}, {2, 3, 1}]. Additionally, consider the following evaluations:

KroneckerProduct[{{1, 2, 3}}, {{2, 3, 1}}]
   {{2, 3, 1, 4, 6, 2, 6, 9, 3}}

KroneckerProduct[{{1}, {2}, {3}}, {{2}, {3}, {1}}]
   {{2}, {3}, {1}, {4}, {6}, {2}, {6}, {9}, {3}}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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