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.Wed, 01 Oct 2014 00:13:23 +0200applying the script to running over variables-(write to file/read from file?)https://ask.sagemath.org/question/24263/applying-the-script-to-running-over-variables-write-to-fileread-from-file/ As I am new in programming with SAGE, I wonder whether anyone can help me in this topic which I think is a matter of writing results to a file first, and then taking them from there.
In particular, I have a command like this;
n = 11
K = GF(4,'a')
R = PolynomialRing(GF(4,'a'),"x")
x = R.gen()
a = K.gen()
v = [1,0,0,0,1,1,1,0,0,0,1]
R(v)
f = x^n-R(v)
S = R.quotient(f, 'y')
y = S.gen()
In the later steps I am using this v as a list of coefficients of a polynomial. And I do some algebra on them. But I want this v to run over all possible 11-length vectors over the finite field K as I defined. And I want to get the results for each v separately.
How can I write a program that will do this for me?
Thanks in advance.Wed, 24 Sep 2014 09:53:59 +0200https://ask.sagemath.org/question/24263/applying-the-script-to-running-over-variables-write-to-fileread-from-file/Answer by ndomes for <p>As I am new in programming with SAGE, I wonder whether anyone can help me in this topic which I think is a matter of writing results to a file first, and then taking them from there.</p>
<p>In particular, I have a command like this;</p>
<pre><code>n = 11
K = GF(4,'a')
R = PolynomialRing(GF(4,'a'),"x")
x = R.gen()
a = K.gen()
v = [1,0,0,0,1,1,1,0,0,0,1]
R(v)
f = x^n-R(v)
S = R.quotient(f, 'y')
y = S.gen()
</code></pre>
<p>In the later steps I am using this v as a list of coefficients of a polynomial. And I do some algebra on them. But I want this v to run over all possible 11-length vectors over the finite field K as I defined. And I want to get the results for each v separately.</p>
<p>How can I write a program that will do this for me?</p>
<p>Thanks in advance.</p>
https://ask.sagemath.org/question/24263/applying-the-script-to-running-over-variables-write-to-fileread-from-file/?answer=24268#post-id-24268 Do you want an iteration through all variations of [0,1] of length 10?
V = Tuples([0,1],10)
for v in V:
print v Wed, 24 Sep 2014 15:36:33 +0200https://ask.sagemath.org/question/24263/applying-the-script-to-running-over-variables-write-to-fileread-from-file/?answer=24268#post-id-24268Comment by algebraicallyclosed for <pre><code>Do you want an iteration through all variations of [0,1] of length 10?
V = Tuples([0,1],10)
for v in V:
print v
</code></pre>
https://ask.sagemath.org/question/24263/applying-the-script-to-running-over-variables-write-to-fileread-from-file/?comment=24339#post-id-24339Actually, since I am working on GF(4) the elements are 0,1,a,a+1Tue, 30 Sep 2014 11:56:03 +0200https://ask.sagemath.org/question/24263/applying-the-script-to-running-over-variables-write-to-fileread-from-file/?comment=24339#post-id-24339Answer by Dima for <p>As I am new in programming with SAGE, I wonder whether anyone can help me in this topic which I think is a matter of writing results to a file first, and then taking them from there.</p>
<p>In particular, I have a command like this;</p>
<pre><code>n = 11
K = GF(4,'a')
R = PolynomialRing(GF(4,'a'),"x")
x = R.gen()
a = K.gen()
v = [1,0,0,0,1,1,1,0,0,0,1]
R(v)
f = x^n-R(v)
S = R.quotient(f, 'y')
y = S.gen()
</code></pre>
<p>In the later steps I am using this v as a list of coefficients of a polynomial. And I do some algebra on them. But I want this v to run over all possible 11-length vectors over the finite field K as I defined. And I want to get the results for each v separately.</p>
<p>How can I write a program that will do this for me?</p>
<p>Thanks in advance.</p>
https://ask.sagemath.org/question/24263/applying-the-script-to-running-over-variables-write-to-fileread-from-file/?answer=24277#post-id-24277The corresponding vector space is `K^n`.
Then you can just
for v in K^n:
# whatever...
Wed, 24 Sep 2014 21:27:32 +0200https://ask.sagemath.org/question/24263/applying-the-script-to-running-over-variables-write-to-fileread-from-file/?answer=24277#post-id-24277Comment by algebraicallyclosed for <p>The corresponding vector space is <code>K^n</code>.
Then you can just </p>
<pre><code>for v in K^n:
# whatever...
</code></pre>
https://ask.sagemath.org/question/24263/applying-the-script-to-running-over-variables-write-to-fileread-from-file/?comment=24340#post-id-24340Now, ok to get v's from there but then below there is an algebraic process, for example, it will take each v and apply some procedure and get a result for this v. I want the results listed for each v at the end of the process.:(.Tue, 30 Sep 2014 11:58:17 +0200https://ask.sagemath.org/question/24263/applying-the-script-to-running-over-variables-write-to-fileread-from-file/?comment=24340#post-id-24340Comment by Dima for <p>The corresponding vector space is <code>K^n</code>.
Then you can just </p>
<pre><code>for v in K^n:
# whatever...
</code></pre>
https://ask.sagemath.org/question/24263/applying-the-script-to-running-over-variables-write-to-fileread-from-file/?comment=24355#post-id-24355[your_procedure(v) for v in K^n]Wed, 01 Oct 2014 00:13:23 +0200https://ask.sagemath.org/question/24263/applying-the-script-to-running-over-variables-write-to-fileread-from-file/?comment=24355#post-id-24355