kron
kron(A, B)
Kronecker tensor product of two vectors or two matrices.
Examples
julia> A = [1 2; 3 4];
julia> B = [5 6; 7 8];
julia> kron(A, B)
4×4 Array{Int64,2}:
5 6 10 12
7 8 14 16
15 18 20 24
21 24 28 32
In this example, kron
is used to compute the Kronecker tensor product of matrices A
and B
.
julia> x = [1, 2, 3];
julia> y = [4, 5, 6];
julia> kron(x, y)
9-element Array{Int64,1}:
4
5
6
8
10
12
12
15
18
Here, kron
is used to compute the Kronecker tensor product of vectors x
and y
.
Common mistake example:
julia> A = [1 2; 3 4];
julia> B = [5, 6, 7, 8];
julia> kron(A, B)
ERROR: DimensionMismatch("inputs to kron must be vectors or matrices")
In this example, the inputs to kron
are not valid. The function requires both inputs to be either vectors or matrices. Ensure that the inputs are of the correct dimensions and type.
See Also
User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.