def __getitem__(self, indices):
r"""
+ Override the usual ``__getitem__`` to support retrieving
+ the entries of the matrix when only two indices are
+ supplied. The three-index form is still needed for e.g.
+ constructing submodules.
SETUP::
sage: from mjo.matrix_algebra import MatrixAlgebra
- EXAMPLES::
+ EXAMPLES:
+
+ In this case the entries and the coordinates are the same,
+ but we can retrieve them both ways::
sage: M = MatrixAlgebra(2,ZZ,ZZ)([[1,2],[3,4]])
sage: M[0,0]
1
+ sage: M[0,0,1]
+ 1
sage: M[0,1]
2
+ sage: M[0,1,1]
+ 2
sage: M[1,0]
3
+ sage: M[1,0,1]
+ 3
sage: M[1,1]
4
-
+ sage: M[1,1,1]
+ 4
"""
+ if len(indices) == 3:
+ return super().__getitem__(indices)
+
+ # If only two coordinates are given, return the matrix
+ # entry at the given position.
i,j = indices
d = self.monomial_coefficients()
A = self.parent().entry_algebra()