Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Iterate over Elements of Finite Quotient (of a Polynomial Ring)

Consider the following, which works:

sage: R.<x> = Integers(4)[]
sage: Q.<a> = R.quotient(x^2)
sage: for q in Q:
....:     q
....:     
0
1
2
3
a
a + 1
a + 2
a + 3
2*a
2*a + 1
2*a + 2
2*a + 3
3*a
3*a + 1
3*a + 2
3*a + 3

Now if I add a generator to the ideal and execute

sage: Q.<a> = R.quotient((x^2,2*x))
sage: for q in Q:
....:     q
....:

I get an error:

NotImplementedError: object does not support iteration

How can I make it work?

Iterate over Elements of Finite Quotient (of a Polynomial Ring)

Consider the following, which works:

sage: R.<x> = Integers(4)[]
sage: Q.<a> = R.quotient(x^2)
sage: for q in Q:
....:     q
....:     
0
1
2
3
a
a + 1
a + 2
a + 3
2*a
2*a + 1
2*a + 2
2*a + 3
3*a
3*a + 1
3*a + 2
3*a + 3

Now if I add a generator to the ideal (which should yield a quotient with 8 elements) and execute

sage: Q.<a> = R.quotient((x^2,2*x))
sage: for q in Q:
....:     q
....:

I get an error:

NotImplementedError: object does not support iteration

How can I make it work?

Iterate over Elements of Finite Quotient (of a Polynomial Ring)

Consider the following, which works:

sage: R.<x> = Integers(4)[]
sage: Q.<a> = R.quotient(x^2)
sage: for q in Q:
....:     q
....:     
0
1
2
3
a
a + 1
a + 2
a + 3
2*a
2*a + 1
2*a + 2
2*a + 3
3*a
3*a + 1
3*a + 2
3*a + 3

Now if I add a generator to the ideal (which should yield a quotient with 8 elements) and execute

sage: Q.<a> = R.quotient((x^2,2*x))
sage: for q in Q:
....:     q
....:

, which should yield a quotient with 8 elements, I get an error:

NotImplementedError: object does not support iteration

How can I make it work?

Iterate over Elements of Finite Quotient (of a Polynomial Ring)

Consider the following, which works:

sage: R.<x> = Integers(4)[]
sage: Q.<a> = R.quotient(x^2)
sage: for q in Q:
....:     q
....:     
0
1
2
3
a
a + 1
a + 2
a + 3
2*a
2*a + 1
2*a + 2
2*a + 3
3*a
3*a + 1
3*a + 2
3*a + 3

Now if I add a generator to the ideal and execute

sage: Q.<a> = R.quotient((x^2,2*x))
sage: for q in Q:
....:     q
....:

, which should yield a quotient with 8 elements, I get an error:

NotImplementedError: object does not support iteration

How can I make it work?

Iterate over Elements of Finite Quotient (of a Polynomial Ring)

Consider the following, which works:

sage: R.<x> = Integers(4)[]
sage: Q.<a> = R.quotient(x^2)
sage: for q in Q:
....:     q
....:     
0
1
2
3
a
a + 1
a + 2
a + 3
2*a
2*a + 1
2*a + 2
2*a + 3
3*a
3*a + 1
3*a + 2
3*a + 3

Now if I add a generator to the ideal and execute

sage: Q.<a> = R.quotient((x^2,2*x))
sage: for q in Q:
....:     q
....:

which should yield a quotient with 8 elements, I get an error:

NotImplementedError: object does not support iteration

How can I make it work?work? Sage doesn't seem to be able to deal with finite rings that aren't principal ideal rings.