Ask Your Question

Revision history [back]

You're almost there!

sage: a = matrix(3, 3, range(9))
sage: b = a[::-1,:]
sage: c = a[:,::-1]
sage: d = a[::-1,::-1]
sage: a, b, c, d
(
[0 1 2]  [6 7 8]  [2 1 0]  [8 7 6]
[3 4 5]  [3 4 5]  [5 4 3]  [5 4 3]
[6 7 8], [0 1 2], [8 7 6], [2 1 0]
)

You're almost there!

sage: a = matrix(3, 3, range(9))
sage: b = a[::-1,:]
a[::-1,:]      # reverse lines
sage: c = a[:,::-1]
a[:,::-1]      # reverse columns
sage: d = a[::-1,::-1]
a[::-1,::-1]   # reverse both
sage: a, b, c, d
(
[0 1 2]  [6 7 8]  [2 1 0]  [8 7 6]
[3 4 5]  [3 4 5]  [5 4 3]  [5 4 3]
[6 7 8], [0 1 2], [8 7 6], [2 1 0]
)