ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 21 Jul 2017 14:39:09 +0200iterating over quotient ring and polynomial ringhttps://ask.sagemath.org/question/38324/iterating-over-quotient-ring-and-polynomial-ring/Hello
I have been studied some finite algebraic structure as follows:
P.<v> = PolynomialRing(GF(2))
R.<v> = P.quotient((v^2-v))
T.<x> = PolynomialRing(R)
R is a quotient ring with elements : 0,1,v,1+v.
I want to list all of the polynomials with degree 2. So I write:
for r in T.polynomials(of_degree=2): r
but the error is "object does not support iteration".
And also the same problem arises when I want to list the elements of R.
Is there any solution to this problem?
How can I iterate over this structure?
thank youWed, 19 Jul 2017 13:12:25 +0200https://ask.sagemath.org/question/38324/iterating-over-quotient-ring-and-polynomial-ring/Answer by vdelecroix for <p>Hello</p>
<p>I have been studied some finite algebraic structure as follows:</p>
<pre><code>P.<v> = PolynomialRing(GF(2))
R.<v> = P.quotient((v^2-v))
T.<x> = PolynomialRing(R)
</code></pre>
<p>R is a quotient ring with elements : 0,1,v,1+v.
I want to list all of the polynomials with degree 2. So I write:</p>
<pre><code>for r in T.polynomials(of_degree=2): r
</code></pre>
<p>but the error is "object does not support iteration".</p>
<p>And also the same problem arises when I want to list the elements of R.</p>
<p>Is there any solution to this problem?
How can I iterate over this structure?</p>
<p>thank you</p>
https://ask.sagemath.org/question/38324/iterating-over-quotient-ring-and-polynomial-ring/?answer=38325#post-id-38325This is something that is indeed missing in Sage. Thanks for your report! I proposed a fixed on [ticket #23467](https://trac.sagemath.org/ticket/23467). If this ticket is positively reviewed, then the changes will be incorporated into later versions of Sage. And then you will be able to use the exact command you wrote.
In the mean time you can use the following to make the list of nonzero elements in R
sage: P.<v> = PolynomialRing(GF(2))
sage: R.<v> = P.quotient((v^2-v))
sage: T.<x> = PolynomialRing(R)
sage: R_nonzero = [R(p) for i in range(3) for p in P.polynomials(of_degree=i)]
from there it is not hard to build polynomials with coefficients in R.Wed, 19 Jul 2017 15:48:19 +0200https://ask.sagemath.org/question/38324/iterating-over-quotient-ring-and-polynomial-ring/?answer=38325#post-id-38325Comment by tugba for <p>This is something that is indeed missing in Sage. Thanks for your report! I proposed a fixed on <a href="https://trac.sagemath.org/ticket/23467">ticket #23467</a>. If this ticket is positively reviewed, then the changes will be incorporated into later versions of Sage. And then you will be able to use the exact command you wrote.</p>
<p>In the mean time you can use the following to make the list of nonzero elements in R</p>
<pre><code>sage: P.<v> = PolynomialRing(GF(2))
sage: R.<v> = P.quotient((v^2-v))
sage: T.<x> = PolynomialRing(R)
sage: R_nonzero = [R(p) for i in range(3) for p in P.polynomials(of_degree=i)]
</code></pre>
<p>from there it is not hard to build polynomials with coefficients in R.</p>
https://ask.sagemath.org/question/38324/iterating-over-quotient-ring-and-polynomial-ring/?comment=38343#post-id-38343thank you for the solution. It was useful for me.Fri, 21 Jul 2017 14:39:09 +0200https://ask.sagemath.org/question/38324/iterating-over-quotient-ring-and-polynomial-ring/?comment=38343#post-id-38343