public static Matrix Transpose(Matrix m) // Matrix transpose, for any rectangular matrix { Matrix t = new Matrix(m.cols, m.rows); for (int i = 0; i < m.rows; i++) for (int j = 0; j < m.cols; j++) t[j, i] = m[i, j]; return t; }