mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-09 03:59:38 +08:00
Made Matrix equality comparison deep.
This commit is contained in:
@ -211,7 +211,15 @@ public class Matrix {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public boolean equals(Matrix other) {
|
public boolean equals(Matrix other) {
|
||||||
return this == other;
|
if (this.getRows() != other.getRows() || this.getColumns() != other.getColumns())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (int i = 0; i < this.data.length; i++)
|
||||||
|
for (int j = 0; j < this.data[0].length; j++)
|
||||||
|
if (this.data[i][j] != other.data[i][j])
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user