# Revision history [back]

The problem is just with printing elements of the ring; the function is_atomic_repr is just used to determine whether or not to write parentheses around the coefficients of a polynomial (e.g. the elements of ZZ are atomic, but elements of a polynomial ring are not).

Matrix_space doesn't have one, but you can give it one easily:

sage: A = MatrixSpace(QQ, 2)
sage: PA.<x> = PolynomialRing(A)
sage: def iar():
...    return True
...
sage: A.is_atomic_repr = iar
sage: x
[1 0]
[0 1]*x


Note that things will still print in silly ways, because matrices always print a linebreak after printing the top row:

sage: f = PA.random_element()
sage: f
[   1    1]
[-1/2    0]*x^2 + [1/2 1/2]
[  0  -2]*x + [-1/2    0]
[  -1    0]
sage: f[0]
[-1/2    0]
[  -1    0]
sage: f[1]
[1/2 1/2]
[  0  -2]


You can still work with polynomials and print their coefficients without defining is_atomic_repr:

sage: B = MatrixSpace(ZZ, 2)
sage: PB.<x> = PolynomialRing(B)
sage: f = x - 1
sage: (f^2).coeffs()
[
[1 0]  [-2  0]  [1 0]
[0 1], [ 0 -2], [0 1]
]
sage: (f^2+1).dict()
{0: [2 0]
[0 2], 1: [-2  0]
[ 0 -2], 2: [1 0]
[0 1]}