mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-08 10:15:51 +08:00
Made Matrix equality comparison deep.
This commit is contained in:
@ -211,7 +211,15 @@ public class Matrix {
|
||||
* @return boolean
|
||||
*/
|
||||
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