Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

If you define your matrices containing elements of the field $\mathbb Z/p\mathbb Z$, solve_right does what you need.

sage: A = matrix(GF(17), [[6,3], [3,8]])
sage: b = matrix(GF(17), [1, 2]).transpose()
sage: A.solve_right(b)


If for some reason you need matrices over (say) $\mathbb Z$ but still need to solve modulo some prime $p$, you can use change_ring.

sage: A = matrix(ZZ, [[1,2], [3,4]])
sage: b = matrix(ZZ, [5, 6]).transpose()
sage: A.change_ring(GF(17)).solve_right(b.change_ring(GF(17)))