Ask Your Question

Iterating over finite structures

asked 2017-06-10 02:33:41 -0500

Jason Polak gravatar image

I am trying to use sage for some algebra computations involving finite rings. Since the structures are finite, I would like to iterate over all the elements of the structure. I know how to iterate in some cases for polynomials in polynomial rings of a certain degree (not necessarily finite):

S.<x> = PolynomialRing(Zmod(9))

Then I could do

for i in S.polynomials(of_degree = 2):

To iterate over all quadratics. What I'd like to do is iterate over all elements of a structure like the finite ring:

R = GroupAlgebra( GL(2, Zmod(2)), Zmod(2))

Is there a way to do this in Sage easily?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-06-10 10:00:16 -0500

updated 2017-06-15 10:37:59 -0500

"Easily"? I don't know if this counts, but it works:

sage: R = GroupAlgebra( GL(2, Zmod(2)), Zmod(2))
sage: V = GF(2)**6  # R is 6-dimensional as a vector space
sage: [R.from_vector(v) for v in V]
[0, [0 1]
 [1 0], [0 1]
 [1 1], [0 1]
 [1 0] + [0 1]
 [1 1], [1 0]

So you could do

sage: for r in (R.from_vector(v) for v in V): ...

(Or just iterate over V, calling R.from_vector(...) each time.)

edit flag offensive delete link more


Thank you for the answer. What you do works for V = GF(2)**6, but I already can do that because "for v in V" works here. "for v in V" does not work if "V = GroupAlgebra( GL(2, Zmod(2)), Zmod(2))". My question is precisely for those structures that are finite, and yet don't work with "for v in V".

Jason Polak gravatar imageJason Polak ( 2017-06-14 22:40:47 -0500 )edit

The second line in my Sage block involves precisely your R. The point is that it converts between elements of V, where you can iterate, to elements of R.

John Palmieri gravatar imageJohn Palmieri ( 2017-06-15 10:37:41 -0500 )edit

I've edited it to make the definition of R explicit.

John Palmieri gravatar imageJohn Palmieri ( 2017-06-15 10:38:16 -0500 )edit

Thank you John. I didn't understand your answer at first but I get it now. It works well seems to be the easiest way to do computations of this nature!

Jason Polak gravatar imageJason Polak ( 2017-07-05 02:58:47 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-06-10 02:33:41 -0500

Seen: 52 times

Last updated: Jun 15