3
$\begingroup$

Using the formula given in this math.stackexchange answer by the user greg

$$\eqalign{ vec(M\otimes dK) &= \left(\pmatrix{I_T\otimes (M \cdot e_1)\cr I_T\otimes (M \cdot e_2)\cr \vdots \cr I_T \otimes (M \cdot e_T)}\otimes I_T\right) \cdot vec(dK)\cr }$$

how come when I run the following code, I get False?

T = 5;
dim = 3;

dKmat = Array[dKm, {T, T}];
M1mat = Array[M1m, {dim, dim}];
Kron3 = KroneckerProduct[M1mat, dKmat];

ArrayReshape[Kron3, {Times @@ Dimensions[Kron3], 1}] === 
 KroneckerProduct[
   Flatten[Table[
     KroneckerProduct[IdentityMatrix[T, SparseArray], 
      Transpose[{M1mat[[;; , i]]}]], {i, dim}], 1], 
   IdentityMatrix[T, SparseArray]].ArrayReshape[
   dKmat, {Times @@ Dimensions[dKmat], 1}]

However, if instead of the columns of M1mat in M1mat[[;; , i]], I use the rows of M1mat, as M1mat[[i]], then I get True...

Using the rows instead of the columns doesn't make mathematical sense to me. How is that correct?

$\endgroup$
2
$\begingroup$

Because you use the "wrong" $vec$: Usually columns of a matrix are stacked by $vec$, not rows. You effectively use

vec[x_?MatrixQ] := Flatten[x];

but you should use

vec[x_?MatrixQ] := Flatten[Transpose[x]];

Now,

id = IdentityMatrix[T, SparseArray];
LHS = vec[KroneckerProduct[M1mat, dKmat]];
RHS = Dot[
   KroneckerProduct[
    Flatten[
     Table[
      KroneckerProduct[
       id,
       M1mat[[;; , {i}]]
       ],
      {i, dim}],
     1
     ],
    id
    ],
   vec[dKmat]
   ];
LHS == RHS

True

$\endgroup$
2
  • $\begingroup$ yes, my mistake. Many thanks Henrik. ;) $\endgroup$ Jan 21 '19 at 14:12
  • $\begingroup$ No problem, You're always welcome. $\endgroup$ Jan 21 '19 at 14:13

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.