4
$\begingroup$

$$ \bigotimes_{i=1}^n A_i $$

where $ A_i $ is a $ m \times m $ matrix.

I want to do above operation, however KroneckerProduct in Mathematica must list all $ A_i $s I need to use.

I have a function $ A_i $ where $ i\in \mathbb{Z} $, and I want to write a program which doesn't depend on specific $ n $. I know I can write a recursion, but I want to know whether there is more clever method.

$\endgroup$
5
  • 5
    $\begingroup$ Something like KroneckerProduct @@ Table[A[i], {i, n}]? $\endgroup$
    – Carl Woll
    Sep 12, 2018 at 20:33
  • $\begingroup$ @CarlWoll Nice, thank you. $\endgroup$
    – maplemaple
    Sep 12, 2018 at 20:36
  • 2
    $\begingroup$ also Array[A, {n}, 1, KroneckerProduct]? $\endgroup$
    – kglr
    Sep 12, 2018 at 20:41
  • $\begingroup$ @kglr {n} can be just n here. $\endgroup$ Sep 13, 2018 at 2:56
  • $\begingroup$ @ΑλέξανδροςΖεγγ, right; thank you. $\endgroup$
    – kglr
    Sep 13, 2018 at 3:33

1 Answer 1

5
$\begingroup$
kP[a_, n_Integer] := Array[a, n, 1, KroneckerProduct]
kP[a_, 1] := a[1]

kP[A, 5]

KroneckerProduct[A[1], A[2], A[3], A[4], A[5]]

$\endgroup$
2
  • 1
    $\begingroup$ Note, that for $n=1$ a special case is required or Unprotect@KroneckerProduct; KroneckerProduct[m_] := m. $\endgroup$
    – Johu
    Sep 12, 2018 at 21:58
  • $\begingroup$ @Johu, good point; added the special case. $\endgroup$
    – kglr
    Sep 12, 2018 at 23:29

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.