Linear equations over Zmod(m).

50 views
Skip to first unread message

Frithjof Schulze

unread,
Feb 23, 2012, 5:53:39 AM2/23/12
to sage-s...@googlegroups.com
Hi,

in Maple I can do something like

> A := Matrix([[1,2,3],[1,3,0],[1,4,3]]);
> b := Vector([1,2,3]);
> x := Linsolve(A,b) mod 6;

to solve a system of linear equations modulo 6 but the obvious
Sage code only works over integral domains:

sage: A = matrix(Zmod(6), [[1,2,3],[1,3,0],[1,4,3]])
sage: b = vector(Zmod(6), [1,2,3])
sage: A.solve_right(b)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
...
TypeError: base ring must be an integral domain

Is this implemented somewhere in Sage (or Pari, Singular, ...)?

Best,
Frithjof

achrzesz

unread,
Feb 23, 2012, 10:34:59 AM2/23/12
to sage-support


On 23 Lut, 11:53, Frithjof Schulze <schu...@math.uni-hannover.de>
wrote:
sage: gp('matsolvemod([1,2,3;1,3,0;1,4,3],6,[1,2,3]~,1)')
[[-1, 1, 0]~, [0, 3, -3; 0, -3, -3; 2, 1, 1]]

If flag = 1, all solutions are returned in the form of a two-component
row vector [x,u], where x is a small integer solution to the system of
congruences and u is a matrix whose columns give a basis of the
homogeneous system (so that all solutions can be obtained by adding x
to any linear combination of columns of u). If no solution exists,
returns zero.

Andrzej Chrzeszczyk
Reply all
Reply to author
Forward
0 new messages