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

Commitcd60c39

Browse files
authored
Merge pull requestTheAlgorithms#722 from Egoscio/patch-1 tofixTheAlgorithms#719
Made Matrix equality comparison deep.
2 parents5a934c1 +10932cc commitcd60c39

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

‎DataStructures/Matrix/Matrix.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,15 @@ public Matrix multiply(Matrix other) throws RuntimeException {
211211
* @return boolean
212212
*/
213213
publicbooleanequals(Matrixother) {
214-
returnthis ==other;
214+
if (this.getRows() !=other.getRows() ||this.getColumns() !=other.getColumns())
215+
returnfalse;
216+
217+
for (inti =0;i <this.data.length;i++)
218+
for (intj =0;j <this.data[0].length;j++)
219+
if (this.data[i][j] !=other.data[i][j])
220+
returnfalse;
221+
222+
returntrue;
215223
}
216224

217225
/**

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp