generate a random rxr matrix over F_q with determinant 1

64 views
Skip to first unread message

Daniel Starin

unread,
Dec 9, 2011, 6:17:44 PM12/9/11
to sage-s...@googlegroups.com
Hi all,

How can I use sage to generate a random rxr matrix over F_q (q is a
prime power) with determinant 1?

Thanks!

Dan

Simon King

unread,
Dec 9, 2011, 6:41:41 PM12/9/11
to sage-support
Hi Daniel,

On 10 Dez., 00:17, Daniel Starin <dsta...@gmail.com> wrote:
> Hi all,
>
> How can I use sage to generate a random rxr matrix over F_q (q is a
> prime power) with determinant 1?

First, create the group of all matrices with determinant 1 (in the
example, q is 9 and r is 5)

sage: G = SL(5, GF(9,'z'))

Then, you can create random elements in the same way as for any other
object with elements (if it's implemented):

sage: G.random_element()
[ 0 1 z + 1 2 2]
[2*z + 1 2*z + 2 z 2*z + 2 2]
[2*z + 1 z + 1 2 z + 2 2*z + 2]
[ z z z + 2 0 2*z + 1]
[ 1 2*z + 2 2 z 2*z + 1]
sage: G.random_element()
[2*z + 2 2*z + 1 0 z + 2 z + 2]
[ 2*z 0 2*z + 2 z + 2 2]
[ 0 2*z + 1 2*z 1 z]
[ z + 1 2*z z + 2 z + 1 z]
[ z + 2 2*z + 2 2*z + 1 2*z + 2 z + 2]

Note that the return value is not a matrix, but an element of the
group G. It is easy to obtain the matrix, though:

sage: type(G.random_element())
<class
'sage.groups.matrix_gps.matrix_group_element.SpecialLinearGroup_finite_field_with_category.element_class'>
sage: type(G.random_element().matrix())
<type 'sage.matrix.matrix_generic_dense.Matrix_generic_dense'>

Just to be on the safe side, verify that the determinant of the
matrices is 1:

sage: G.random_element().matrix().determinant()
1
sage: G.random_element().matrix().determinant()
1

Cheers,
Simon

Reply all
Reply to author
Forward
0 new messages