Skip to content

Commit 067e39d

Browse files
author
Egoscio
authored
Made Matrix equality comparison deep.
Solution to the issue TheAlgorithms#719
1 parent 5a934c1 commit 067e39d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

DataStructures/Matrix/Matrix.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,12 @@ public Matrix multiply(Matrix other) throws RuntimeException {
211211
* @return boolean
212212
*/
213213
public boolean equals(Matrix other) {
214-
return this == other;
214+
for (int i = 0; i < this.data.length; i++)
215+
for (int j = 0; j < this.data[0].length; j++)
216+
if (this.data[i][j] != other.data[i][j])
217+
return false;
218+
219+
return true;
215220
}
216221

217222
/**

0 commit comments

Comments
 (0)