'Resize matrix in Julia
How do I convert a matrix A
A = [a b c
d e f
g h i]
To matrix B?
B = [a a b b c c
a a b b c c
d d e e f f
d d e e f f
g g h h i i
g g h h i i]
Solution 1:[1]
It's slightly slower than repeat, but for a numeric array, you can also use kron:
julia> A = permutedims(reshape(1:9, 3, 3))
3×3 Matrix{Int64}:
1 2 3
4 5 6
7 8 9
julia> kron(A, ones(Int, 2, 2))
6×6 Matrix{Int64}:
1 1 2 2 3 3
1 1 2 2 3 3
4 4 5 5 6 6
4 4 5 5 6 6
7 7 8 8 9 9
7 7 8 8 9 9
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | sethaxen |
