Matrix 如何在Torch中复制矩阵行

Matrix 如何在Torch中复制矩阵行,matrix,lua,torch,Matrix,Lua,Torch,使用Torch,我将如何转动此矩阵: [1 2 3 4 5 6 7 8 9] 为此: [1 2 3 1 2 3 1 2 3 4 5 6 4 5 6 4 5 6 7 8 9 7 8 9 7 8 9] ? 在Matlab中,我会这样做: a = [1 2 3; 4 5 6; 7 8 9]; rows = repmat(1:size(a, 1), 1, 3); b = a(rows(:), :); 火炬中有类似的方法吗?这样可以: a = a:repeatTensor(1,

使用Torch,我将如何转动此矩阵:

[1 2 3
 4 5 6
 7 8 9]
为此:

[1 2 3
 1 2 3
 1 2 3
 4 5 6
 4 5 6
 4 5 6
 7 8 9
 7 8 9
 7 8 9]
?

在Matlab中,我会这样做:

a = [1 2 3; 4 5 6; 7 8 9];
rows = repmat(1:size(a, 1), 1, 3);
b = a(rows(:), :);
火炬中有类似的方法吗?

这样可以:

a = a:repeatTensor(1, 3):reshape(9, 3)