-
Notifications
You must be signed in to change notification settings - Fork 205
Closed
Labels
enhancementnew feature requests (or implementation)new feature requests (or implementation)
Milestone
Description
from mpmath import matrix
# Create a 3x3 matrix
A = matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
# Access the last element of the first row
print(A[0, -1])I expect negative index -n to indicate last n element, like in Python list or numpy array. But I got 0.
After some digging, I found the related code:
mpmath/mpmath/matrices/matrices.py
Lines 499 to 505 in cf98bcf
| # single element extraction | |
| if key[0] >= self._rows or key[1] >= self._cols: | |
| raise IndexError('matrix index out of range') | |
| if key in self._data: | |
| return self._data[key] | |
| else: | |
| return self.ctx.zero |
The same goes for index of columns, such as A[-1,:] returns [0.0 0.0 0.0].
Are negative indices for other purposes? Can Python-like negative indices be supported?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementnew feature requests (or implementation)new feature requests (or implementation)