transpose method
Transposes the matrix
Matrix a = Matrix([[1.0,2.0],[3.0,4.0],[5.0,6.0]])
print(a.transpose())
will print
[[1.0, 3.0, 5.0],[2.0,4.0,6.0]]
Implementation
Matrix transpose() {
Matrix toReturn = new Matrix.fill(n, m);
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
toReturn[j][i] = this[i][j];
}
}
return toReturn;
}