交换矩阵定义在以下链接中:
https://en.wikipedia.org/wiki/Commutation_matrix
假设我有一个矩阵:
如何在MATLAB中获得置换矩阵?
A = [1,2,3;4,5,6];
如何在MATLAB中获得置换矩阵?
A = [1,2,3;4,5,6];
不确定这是否算“作弊”,但你可以尝试:
[m, n] = size(A);
I = reshape(1:m*n, [m, n]); % initialize a matrix of indices of size(A)
I = I'; % Transpose it
I = I(:); % vectorize the required indices
Y = eye(m*n); % Initialize an identity matrix
Y = Y(I,:); % Re-arrange the rows of the identity matrix
接着,交换矩阵就是 Y。
eye(m*n)
,是否可以减少内存占用问题? - jason