Reshape
Reshape
在不更改其数据的情况下更改矩阵的形状。
void Reshape(
const ulong rows, // 新的行数。
const ulong cols // 新的列数。
);参数
- rows
[输入] 新的行数.
- cols
[输入] 新的列数.
- 注意
矩阵就地处理。 不会创建任何副本。 可以指定任何大小,即,rows_newcols_new!=rows_oldcols_old。 当矩阵缓冲区增加时,额外数值均未定义。
举例
matrix matrix_a={{1,2,3},{4,5,6},{7,8,9},{10,11,12}};
Print("matrix_a\n",matrix_a);
matrix_a.Reshape(2,6);
Print("Reshape(2,6)\n",matrix_a);
matrix_a.Reshape(3,5);
Print("Reshape(3,5)\n",matrix_a);
matrix_a.Reshape(2,4);
Print("Reshape(2,4)\n",matrix_a);
/*
matrix_a
[[1,2,3]
[4,5,6]
[7,8,9]
[10,11,12]]
Reshape(2,6)
[[1,2,3,4,5,6]
[7,8,9,10,11,12]]
Reshape(3,5)
[[1,2,3,4,5]
[6,7,8,9,10]
[11,12,0,3,0]]
Reshape(2,4)
[[1,2,3,4]
[5,6,7,8]]
*/