Skip to content

commutation_matrix

linear-algebra · scripts/linear-algebra/commutation_matrix.m

COMMUTATION_MATRIX  Permutation matrix for vec(A.') == K * vec(A).
  K = COMMUTATION_MATRIX(M, N) returns the mn-by-mn permutation matrix
  satisfying K * A(:) == A.'(:) for every M-by-N matrix A.
  K = COMMUTATION_MATRIX(M) equals COMMUTATION_MATRIX(M, M).

  Octave-compatible public name. MATLAB has no public
  commutation_matrix; portable code builds the same sparse/dense
  index map locally. Unmarked MATLAB-mode scripts that never call
  this name are unaffected.

  See also DUPLICATION_MATRIX, VECH, RESHAPE.