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

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to