Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2ae4930

Browse files
committed
Updated Matrix.java, added Transpose of a Matrix
1 parent05efd17 commit2ae4930

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎Data Structures/Matrix/Matrix.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,20 @@ public String toString() {
221221

222222
returnstr;
223223
}
224+
225+
/**
226+
* Returns transposed matrix of this matrix.
227+
*
228+
* @return transposed Matrix.
229+
*/
230+
publicMatrixtranspose() {
231+
232+
int[][]newData =newint[this.data[0].length][this.data.length];
233+
234+
for (inti =0;i <this.getColumns(); ++i)
235+
for(intj =0;j <this.getRows(); ++j)
236+
newData[i][j] =this.data[j][i];
237+
238+
returnnewMatrix(newData);
239+
}
224240
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp