This change introduces a new method called isIdentity to the Matrix class. Along with its static counterparts, this method efficiently checks whether the matrix or the 2D (two-dimensional) array represents an identity matrix. An identity matrix is defined as a square matrix where all diagonal elements are $1$ and all other elements are $0$. This addition enhances the functionality of the Matrix class, providing users with a convenient tool for matrix identity verification. The change also includes comprehensive Javadoc documentation for the newly added method, including details on its functionality, parameters, exceptions, and performance analysis (including time complexity and space complexity).
[!NOTE]
Please use the isDiagonal method if you just want to check whether the matrix or two-dimensional array represents a diagonal matrix. A diagonal matrix is a square matrix in which all the entries on the main diagonal is not equal to $0$ (it can be both negative and positive values, but not zero) and the entries outside of the main diagonal are $0$ (more precisely, it takes the absolute values and must be lower than Matrix.THRESHOLD).
Summary
This change introduces a new method called
isIdentity
to theMatrix
class. Along with its static counterparts, this method efficiently checks whether the matrix or the 2D (two-dimensional) array represents an identity matrix. An identity matrix is defined as a square matrix where all diagonal elements are $1$ and all other elements are $0$. This addition enhances the functionality of theMatrix
class, providing users with a convenient tool for matrix identity verification. The change also includes comprehensive Javadoc documentation for the newly added method, including details on its functionality, parameters, exceptions, and performance analysis (including time complexity and space complexity).An example of identity matrix: