We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 05efd17 commit 2ae4930Copy full SHA for 2ae4930
Data Structures/Matrix/Matrix.java
@@ -221,4 +221,20 @@ public String toString() {
221
222
return str;
223
}
224
+
225
+ /**
226
+ * Returns transposed matrix of this matrix.
227
+ *
228
+ * @return transposed Matrix.
229
+ */
230
+ public Matrix transpose() {
231
232
+ int[][] newData = new int[this.data[0].length][this.data.length];
233
234
+ for (int i = 0; i < this.getColumns(); ++i)
235
+ for(int j = 0; j < this.getRows(); ++j)
236
+ newData[i][j] = this.data[j][i];
237
238
+ return new Matrix(newData);
239
+ }
240
0 commit comments