Ask Your Question

Revision history [back]

The usual way, which works for any field F, is to work with matrices:

sage: F = GF(7)
sage: M = Matrix(F, [[-1,5,1,2,4,1], [-3,2,1,4,2,1], [-6,6,1,6,1,6], [-5,2,1,1,1,1], [-4,2,1,3,2,6], [-2,4,1,5,4,6]])
sage: M
[6 5 1 2 4 1]
[4 2 1 4 2 1]
[1 6 1 6 1 6]
[2 2 1 1 1 1]
[3 2 1 3 2 6]
[5 4 1 5 4 6]
sage: M.parent()
Full MatrixSpace of 6 by 6 dense matrices over Finite Field of size 7
sage: v = vector(F, (3,1,-6,-5,6,6))
sage: v.parent()
Vector space of dimension 6 over Finite Field of size 7
sage: v
(3, 1, 1, 2, 6, 6)
sage: M.solve_right(v)
(1, 2, 2, 0, 4, 4)
sage: M * vector((1, 2, 2, 0, 4, 4))
(3, 1, 1, 2, 6, 6)
sage: M * vector((1, 2, 2, 0, 4, 4)) == v
True

For non-prime finite fields, you can access to the generator as follows:

sage: F = GF(49)
sage: F
Finite Field in z2 of size 7^2
sage: F.inject_variables()
Defining z2
sage: z2^6
2*z2 + 4
sage: z2^8
3

The usual way, which works for any field F, is to work with matrices:matrices, instead of symbolic expressions:

sage: F = GF(7)
sage: M = Matrix(F, [[-1,5,1,2,4,1], [-3,2,1,4,2,1], [-6,6,1,6,1,6], [-5,2,1,1,1,1], [-4,2,1,3,2,6], [-2,4,1,5,4,6]])
sage: M
[6 5 1 2 4 1]
[4 2 1 4 2 1]
[1 6 1 6 1 6]
[2 2 1 1 1 1]
[3 2 1 3 2 6]
[5 4 1 5 4 6]
sage: M.parent()
Full MatrixSpace of 6 by 6 dense matrices over Finite Field of size 7
sage: v = vector(F, (3,1,-6,-5,6,6))
sage: v.parent()
Vector space of dimension 6 over Finite Field of size 7
sage: v
(3, 1, 1, 2, 6, 6)
sage: M.solve_right(v)
(1, 2, 2, 0, 4, 4)
sage: M * vector((1, 2, 2, 0, 4, 4))
(3, 1, 1, 2, 6, 6)
sage: M * vector((1, 2, 2, 0, 4, 4)) == v
True

For non-prime finite fields, you can access to the generator as follows:

sage: F = GF(49)
sage: F
Finite Field in z2 of size 7^2
sage: F.inject_variables()
Defining z2
sage: z2^6
2*z2 + 4
sage: z2^8
3

The usual way, which works for any field F, is to work with matrices, instead of symbolic expressions:

sage: F = GF(7)
sage: F
Finite Field of size 7
sage: M = Matrix(F, [[-1,5,1,2,4,1], [-3,2,1,4,2,1], [-6,6,1,6,1,6], [-5,2,1,1,1,1], [-4,2,1,3,2,6], [-2,4,1,5,4,6]])
sage: M
[6 5 1 2 4 1]
[4 2 1 4 2 1]
[1 6 1 6 1 6]
[2 2 1 1 1 1]
[3 2 1 3 2 6]
[5 4 1 5 4 6]
sage: M.parent()
Full MatrixSpace of 6 by 6 dense matrices over Finite Field of size 7
sage: v = vector(F, (3,1,-6,-5,6,6))
sage: v
(3, 1, 1, 2, 6, 6)
sage: v.parent()
Vector space of dimension 6 over Finite Field of size 7
sage: v
(3, 1, 1, 2, 6, 6)
sage: M.solve_right(v)
(1, 2, 2, 0, 4, 4)
sage: M * vector((1, 2, 2, 0, 4, 4))
(3, 1, 1, 2, 6, 6)
sage: M * vector((1, 2, 2, 0, 4, 4)) == v
True

For non-prime finite fields, you can access to the generator as follows:

sage: F = GF(49)
sage: F
Finite Field in z2 of size 7^2
sage: F.inject_variables()
Defining z2
sage: z2^6
2*z2 + 4
sage: z2^8
3