Hello!
I am struggling to find a way to “automate” this type of function call:
using LinearAlgebra
x = [rand() rand(); rand() rand()]
kron(x, x) #n=2
kron(x, x, x) #n=3
kron(x, x, x, x) #n=4
Basically, having a 2x2 matrix “x” I would like to use the kronecker product of x with itself n times.
Is there a way to achieve this, perhaps in a manner like:
kron(repeat(x, n))
Of course not with the repeat function, but perhaps with something else.
Hey @Zackyzz , glad you got your question answered! Also, welcome to the Julia Community – saw it was your first post here on Discourse! Hope you enjoy your time here!
Yea, this syntax is interesting – it is called splatting and you can learn more about it here: Essentials · The Julia Language… (I am a fan of it but sometimes, it is not as efficient as maps or otherwise).
In the case of kron and other associative operations, you can also do reduce(kron, fill(x, n)). That’s useful to know for many other associative functions like hcat, union etc.