Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for negative indices in
display
methods
* Enhanced the `display(int index)` method in the `Matrix` class to support negative indices. Negative indices are now interpreted as counting from the end of the matrix. For instance, an index of `-1` refers to the last row, `-2` refers to the second-to-last row, and so on. * Adjusted the index calculation to convert negative indices into valid positive indices. * Added checks to ensure that the adjusted index is within valid bounds for the matrix rows. * Improved error handling to raise an `InvalidIndexException` with a clear message if the adjusted index is out of bounds. * Updated the static `display(double[][] arr, int index)` method to support negative indices similarly. These updates provide greater flexibility for accessing rows in matrices and 2D arrays using negative indices, aligning with common conventions and improving usability.
- Loading branch information