[sage-support] Re: Changing basis in Free Modules (Disguising my question Changing basis in finite fields)
Hi David, Thank you very much for your solution. I think it is enough for me as finally I want to see the result in normal basis. However, I changed the code a little to suite my purpose but it failed. Could you please tell me what should I use instead of list property in multivariate case (maybe we need some ordering like grobner basis): sage: k = GF(7) # any coefficient ring here is okay sage: R = MPolynomialRing(k,2,x) # create polynomial ring over k in variable x sage: x = R.gens() sage: g = x[0]^3 + 2*x[1] + 5# create some polynomial sage: print g.list() # list of coefficients of polynomial sage: [2*u for u in g.list()] # multiplies every elements of g.list() by 2 (mod 7), returns result as a list Traceback (most recent call last): ... AttributeError: 'sage.rings.polynomial.multi_polynomial_libsingular' object has no attribute 'list' I hope that you don't get the feeling that I just naging and challenging you for nothing. It is almost exactly the computation I need for my thesis as I'm working on GHS attack. I should look at a curve when its parameters and variables is represented in base field (so one equation become many equations) and then I should pass some hyper-plane through it in its base field. Thanx again. Ahmad On Nov 30, 8:20 am, David Harvey [EMAIL PROTECTED] wrote: On Nov 30, 2007, at 2:45 AM, Ahmad wrote: Dear Sage Supporters, As nobody continued to pay attention to the question I asked in sept 3 about how I want to change the field basis permanently, I am using john Cremona's idea to ask my question in another way, in hope to attract more attention: Suppose k is a field. Let define ring k[x]. I extend this ring by adding variable 't' and taking quotient by polynomial 't^4 + t^3 + t^2 + t + 1'. So, I have the ring k[x][t]/(t^4 + t^3 + t^2 + t + 1) which is a free module over k[x]. But again sage use default basis (1, t, t^2, t^3) to represent this ring over k[x]: sage: k = GF(2); sage: R = k['x']; x = R.gen() sage: S = R['t']; t = S.gen() sage: SBar = S.quotient(t^4 + t^3 + t^2 + t + 1, 'a'); a = SBar.gen() sage: print x*a^4 x*a^3 + x*a^2 + x*a + x How can I change this basis to normal basis, so I get: sage: print x*a^4 x*a^4 Hi Ahmad, I looked over the september thread, and the problem is that William's solution won't work in this more general case, since you can't create a polynomial ring with coefficients in a vector space, it just doesn't make sense. But if all you need is a list of the coordinates, then maybe we can make this work. All you need to be able to do is apply a function to each coefficient of a polynomial. Here's how you do that: sage: k = GF(7) # any coefficient ring here is okay sage: R.x = PolynomialRing(k) # create polynomial ring over k in variable x sage: g = x^3 + 2*x + 5# create some polynomial sage: g.list() # list of coefficients of polynomial [5, 2, 0, 1] sage: [2*u for u in g.list()] # multiplies every elements of g.list () by 2 (mod 7), returns result as a list [3, 4, 0, 2] So you just need to replace 2*u with whatever function William gave you to change basis representation. Of course, what you *really* want is to be able to create a field that prints elements of itself with respect to a different basis, but I don't think this is implemented in sage (yet). That sounds like it could be a useful thing to have. david --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/ -~--~~~~--~~--~--~---
[sage-support] Re: Changing basis in Free Modules (Disguising my question Changing basis in finite fields)
Hi David, I think list function is enough for me if I extend the ring in two steps: first with free variables and then I extend it algebraically. Your solution is working for me in this way: sage: k = GF(2); sage: WRBasePolyRing = MPolynomialRing(k, 8, x); x = WRBasePolyRing.gens() sage: S = WRBasePolyRing['w']; w = S.gen() sage: WRPolyRing = S.quotient(w^4 + w^3 + w^2 + w + 1, 't'); t = WRPolyRing.gen() sage: X = x[0]*t + x[1]*t^2 + x[2]*t^4 + x[3]* t^8; sage: Y = x[4]*t + x[5]*t^2 + x[6]*t^4 + x[7]* t^8; sage: MyCurve = Y^2+X*Y+X^3+1 sage: print MyCurve.list() [x0^2*x1 + x0*x1^2 + x0*x2^2 + x1*x2^2 + x0^2*x3 + x2*x3^2 + x3^3 + x2*x4 + x3*x4 + x1*x5 + x3*x5 + x5^2 + x0*x6 + x0*x7 + x1*x7 + 1, x0^2*x1 + x1^3 + x0^2*x2 + x0*x2^2 + x2^2*x3 + x3^3 + x3*x4 + x1*x5 + x2*x5 + x5^2 + x1*x6 + x0*x7 + x3*x7 + x7^2, x0^2*x1 + x0*x2^2 + x2^3 + x1^2*x3 + x0*x3^2 + x3^3 + x0*x4 + x3*x4 + x4^2 + x1*x5 + x5^2 + x3*x6 + x0*x7 + x2*x7, x0^3 + x0^2*x1 + x1^2*x2 + x0*x2^2 + x1*x3^2 + x3^3 + x1*x4 + x3*x4 + x0*x5 + x1*x5 + x5^2 + x2*x6 + x6^2 + x0*x7] And after that as you mentioned, I can multiply the list by the basis change matrix. Thank you again (More question is on the way ... :) Bests, Ahmad On Dec 1, 3:27 am, Ahmad [EMAIL PROTECTED] wrote: Hi David, Thank you very much for your solution. I think it is enough for me as finally I want to see the result in normal basis. However, I changed the code a little to suite my purpose but it failed. Could you please tell me what should I use instead of list property in multivariate case (maybe we need some ordering like grobner basis): sage: k = GF(7) # any coefficient ring here is okay sage: R = MPolynomialRing(k,2,x) # create polynomial ring over k in variable x sage: x = R.gens() sage: g = x[0]^3 + 2*x[1] + 5# create some polynomial sage: print g.list() # list of coefficients of polynomial sage: [2*u for u in g.list()] # multiplies every elements of g.list() by 2 (mod 7), returns result as a list Traceback (most recent call last): ... AttributeError: 'sage.rings.polynomial.multi_polynomial_libsingular' object has no attribute 'list' I hope that you don't get the feeling that I just naging and challenging you for nothing. It is almost exactly the computation I need for my thesis as I'm working on GHS attack. I should look at a curve when its parameters and variables is represented in base field (so one equation become many equations) and then I should pass some hyper-plane through it in its base field. Thanx again. Ahmad On Nov 30, 8:20 am, David Harvey [EMAIL PROTECTED] wrote: On Nov 30, 2007, at 2:45 AM, Ahmad wrote: Dear Sage Supporters, As nobody continued to pay attention to the question I asked in sept 3 about how I want to change the field basis permanently, I am using john Cremona's idea to ask my question in another way, in hope to attract more attention: Suppose k is a field. Let define ring k[x]. I extend this ring by adding variable 't' and taking quotient by polynomial 't^4 + t^3 + t^2 + t + 1'. So, I have the ring k[x][t]/(t^4 + t^3 + t^2 + t + 1) which is a free module over k[x]. But again sage use default basis (1, t, t^2, t^3) to represent this ring over k[x]: sage: k = GF(2); sage: R = k['x']; x = R.gen() sage: S = R['t']; t = S.gen() sage: SBar = S.quotient(t^4 + t^3 + t^2 + t + 1, 'a'); a = SBar.gen() sage: print x*a^4 x*a^3 + x*a^2 + x*a + x How can I change this basis to normal basis, so I get: sage: print x*a^4 x*a^4 Hi Ahmad, I looked over the september thread, and the problem is that William's solution won't work in this more general case, since you can't create a polynomial ring with coefficients in a vector space, it just doesn't make sense. But if all you need is a list of the coordinates, then maybe we can make this work. All you need to be able to do is apply a function to each coefficient of a polynomial. Here's how you do that: sage: k = GF(7) # any coefficient ring here is okay sage: R.x = PolynomialRing(k) # create polynomial ring over k in variable x sage: g = x^3 + 2*x + 5# create some polynomial sage: g.list() # list of coefficients of polynomial [5, 2, 0, 1] sage: [2*u for u in g.list()] # multiplies every elements of g.list () by 2 (mod 7), returns result as a list [3, 4, 0, 2] So you just need to replace 2*u with whatever function William gave you to change basis representation. Of course, what you *really* want is to be able to create a field that prints elements of itself with respect to a different basis, but I don't think this is implemented in sage (yet). That sounds like it could be a useful thing to have. david --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit
[sage-support] Re: Changing basis in Free Modules (Disguising my question Changing basis in finite fields)
Hi David, I think list function is enough for me if I extend the ring in two steps: first with free variables and then I extend it algebraically. Your solution is working for me in this way: sage: k = GF(2); sage: WRBasePolyRing = MPolynomialRing(k, 8, x); x = WRBasePolyRing.gens() sage: S = WRBasePolyRing['w']; w = S.gen() sage: WRPolyRing = S.quotient(w^4 + w^3 + w^2 + w + 1, 't'); t = WRPolyRing.gen() sage: X = x[0]*t + x[1]*t^2 + x[2]*t^4 + x[3]* t^8; sage: Y = x[4]*t + x[5]*t^2 + x[6]*t^4 + x[7]* t^8; sage: MyCurve = Y^2+X*Y+X^3+1 sage: print MyCurve.list() [x0^2*x1 + x0*x1^2 + x0*x2^2 + x1*x2^2 + x0^2*x3 + x2*x3^2 + x3^3 + x2*x4 + x3*x4 + x1*x5 + x3*x5 + x5^2 + x0*x6 + x0*x7 + x1*x7 + 1, x0^2*x1 + x1^3 + x0^2*x2 + x0*x2^2 + x2^2*x3 + x3^3 + x3*x4 + x1*x5 + x2*x5 + x5^2 + x1*x6 + x0*x7 + x3*x7 + x7^2, x0^2*x1 + x0*x2^2 + x2^3 + x1^2*x3 + x0*x3^2 + x3^3 + x0*x4 + x3*x4 + x4^2 + x1*x5 + x5^2 + x3*x6 + x0*x7 + x2*x7, x0^3 + x0^2*x1 + x1^2*x2 + x0*x2^2 + x1*x3^2 + x3^3 + x1*x4 + x3*x4 + x0*x5 + x1*x5 + x5^2 + x2*x6 + x6^2 + x0*x7] And after that as you mentioned, I can multiply the list by the basis change matrix. Thank you again (More question is on the way ... :) Bests, Ahmad On Dec 1, 3:27 am, Ahmad [EMAIL PROTECTED] wrote: Hi David, Thank you very much for your solution. I think it is enough for me as finally I want to see the result in normal basis. However, I changed the code a little to suite my purpose but it failed. Could you please tell me what should I use instead of list property in multivariate case (maybe we need some ordering like grobner basis): sage: k = GF(7) # any coefficient ring here is okay sage: R = MPolynomialRing(k,2,x) # create polynomial ring over k in variable x sage: x = R.gens() sage: g = x[0]^3 + 2*x[1] + 5# create some polynomial sage: print g.list() # list of coefficients of polynomial sage: [2*u for u in g.list()] # multiplies every elements of g.list() by 2 (mod 7), returns result as a list Traceback (most recent call last): ... AttributeError: 'sage.rings.polynomial.multi_polynomial_libsingular' object has no attribute 'list' I hope that you don't get the feeling that I just naging and challenging you for nothing. It is almost exactly the computation I need for my thesis as I'm working on GHS attack. I should look at a curve when its parameters and variables is represented in base field (so one equation become many equations) and then I should pass some hyper-plane through it in its base field. Thanx again. Ahmad On Nov 30, 8:20 am, David Harvey [EMAIL PROTECTED] wrote: On Nov 30, 2007, at 2:45 AM, Ahmad wrote: Dear Sage Supporters, As nobody continued to pay attention to the question I asked in sept 3 about how I want to change the field basis permanently, I am using john Cremona's idea to ask my question in another way, in hope to attract more attention: Suppose k is a field. Let define ring k[x]. I extend this ring by adding variable 't' and taking quotient by polynomial 't^4 + t^3 + t^2 + t + 1'. So, I have the ring k[x][t]/(t^4 + t^3 + t^2 + t + 1) which is a free module over k[x]. But again sage use default basis (1, t, t^2, t^3) to represent this ring over k[x]: sage: k = GF(2); sage: R = k['x']; x = R.gen() sage: S = R['t']; t = S.gen() sage: SBar = S.quotient(t^4 + t^3 + t^2 + t + 1, 'a'); a = SBar.gen() sage: print x*a^4 x*a^3 + x*a^2 + x*a + x How can I change this basis to normal basis, so I get: sage: print x*a^4 x*a^4 Hi Ahmad, I looked over the september thread, and the problem is that William's solution won't work in this more general case, since you can't create a polynomial ring with coefficients in a vector space, it just doesn't make sense. But if all you need is a list of the coordinates, then maybe we can make this work. All you need to be able to do is apply a function to each coefficient of a polynomial. Here's how you do that: sage: k = GF(7) # any coefficient ring here is okay sage: R.x = PolynomialRing(k) # create polynomial ring over k in variable x sage: g = x^3 + 2*x + 5# create some polynomial sage: g.list() # list of coefficients of polynomial [5, 2, 0, 1] sage: [2*u for u in g.list()] # multiplies every elements of g.list () by 2 (mod 7), returns result as a list [3, 4, 0, 2] So you just need to replace 2*u with whatever function William gave you to change basis representation. Of course, what you *really* want is to be able to create a field that prints elements of itself with respect to a different basis, but I don't think this is implemented in sage (yet). That sounds like it could be a useful thing to have. david --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit
[sage-support] Intersecting a variety with hyperplanes and the problem with reduce function
Dear Supporters, I have a variety X in K[x_1,...,x^8] and I want to pass some hyperplanes through it and get the new equation of intersection. I used the reduce function of ideals and it works for me very well as follows: sage: k = GF(2); sage: R.w = k['w']; sage: K.t = GF(2^4, name='t', modulus = w^4 + w^3 + w^2 + w + 1); sage: WeilResPolyRing = MPolynomialRing(K, 8, x); sage: x = WeilResPolyRing.gens(); sage: X = x[0]*t + x[1]*t^2; sage: MyHyperplane = x[0] + x[1]; sage: J = ideal(MyHyperplane) sage: CinW = J.reduce(X) sage: print CinW (t^2 + t)*x1 However, for a strange but valid reason (I need to change the basis of finite field extension and sage just let me to do that in this way) I should define the polynomial ring K[x_1,...,x^8] in another way which is basically I first construct GF(2)[x_1,...,x_8] and then I add t to it such that t^4 + t^3 + t^2 + t + 1 = 0. Obviously this new construction is mathematically isomorphism to the previous one, however this time reduce function fails for some reason. Could you please tell me what is wrong here (the second part of both codes are identical and they differ just in the ring construction part): sage: k = GF(2); sage: WRBasePolyRing = MPolynomialRing(k, 8, x); x = WRBasePolyRing.gens() sage: S = WRBasePolyRing['w']; w = S.gen() sage: WRPolyRing = S.quotient(w^4 + w^3 + w^2 + w + 1, 't'); t = WRPolyRing.gen() sage: X = x[0]*t + x[1]*t^2; sage: MyHyperplane = x[0] + x[1]; sage: J = ideal(MyHyperplane) sage: CinW = J.reduce(X) sage: print CinW Traceback (most recent call last): ... TypeError: cannot coerce nonconstant polynomial Thank you very much in Advance! Bests, Ahmad --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/ -~--~~~~--~~--~--~---
[sage-support] Re: Changing basis in Free Modules (Disguising my question Changing basis in finite fields)
Thank you very much David, For now list function works for me very well using the approaches I discussed in last post, except that t makes some problem for reduce function which I asked in my next post. If the problem with reduce won't be solved, the dict function would be enough for implementing the basis changing in multivariate polynomials for sure. Cheers, Ahmad On Dec 1, 10:47 am, David Harvey [EMAIL PROTECTED] wrote: Hi Ahmad, Unfortunately I know nothing about multivariate polynomials in sage, but in case you didn't already know, there is an easy way to find out what methods an object supports. For example I did this: sage: k = GF(7) sage: R = MPolynomialRing(k,2,x) sage: x = R.gens() sage: g = x[0]^3 + 2*x[1] + 5 Since g.list() doesn't work, I type g. and then press Tab. I get a long list of methods attached to g. Then I see for example that I can do: sage: g.dict() {(0, 0): 5, (0, 1): 2, (3, 0): 1} This is a dictionary representation of the coefficients of g, and there are probably other representations available too. If I type: sage: g.dict? I get some documentation on what g.dict() does. david On Dec 1, 2007, at 10:37 AM, Ahmad wrote: Hi David, I think list function is enough for me if I extend the ring in two steps: first with free variables and then I extend it algebraically. Your solution is working for me in this way: sage: k = GF(2); sage: WRBasePolyRing = MPolynomialRing(k, 8, x); x = WRBasePolyRing.gens() sage: S = WRBasePolyRing['w']; w = S.gen() sage: WRPolyRing = S.quotient(w^4 + w^3 + w^2 + w + 1, 't'); t = WRPolyRing.gen() sage: X = x[0]*t + x[1]*t^2 + x[2]*t^4 + x[3]* t^8; sage: Y = x[4]*t + x[5]*t^2 + x[6]*t^4 + x[7]* t^8; sage: MyCurve = Y^2+X*Y+X^3+1 sage: print MyCurve.list() [x0^2*x1 + x0*x1^2 + x0*x2^2 + x1*x2^2 + x0^2*x3 + x2*x3^2 + x3^3 + x2*x4 + x3*x4 + x1*x5 + x3*x5 + x5^2 + x0*x6 + x0*x7 + x1*x7 + 1, x0^2*x1 + x1^3 + x0^2*x2 + x0*x2^2 + x2^2*x3 + x3^3 + x3*x4 + x1*x5 + x2*x5 + x5^2 + x1*x6 + x0*x7 + x3*x7 + x7^2, x0^2*x1 + x0*x2^2 + x2^3 + x1^2*x3 + x0*x3^2 + x3^3 + x0*x4 + x3*x4 + x4^2 + x1*x5 + x5^2 + x3*x6 + x0*x7 + x2*x7, x0^3 + x0^2*x1 + x1^2*x2 + x0*x2^2 + x1*x3^2 + x3^3 + x1*x4 + x3*x4 + x0*x5 + x1*x5 + x5^2 + x2*x6 + x6^2 + x0*x7] And after that as you mentioned, I can multiply the list by the basis change matrix. Thank you again (More question is on the way ... :) Bests, Ahmad --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/ -~--~~~~--~~--~--~---
[sage-support] Changing basis in Free Modules (Disguising my question Changing basis in finite fields)
Dear Sage Supporters, As nobody continued to pay attention to the question I asked in sept 3 about how I want to change the field basis permanently, I am using john Cremona's idea to ask my question in another way, in hope to attract more attention: Suppose k is a field. Let define ring k[x]. I extend this ring by adding variable 't' and taking quotient by polynomial 't^4 + t^3 + t^2 + t + 1'. So, I have the ring k[x][t]/(t^4 + t^3 + t^2 + t + 1) which is a free module over k[x]. But again sage use default basis (1, t, t^2, t^3) to represent this ring over k[x]: sage: k = GF(2); sage: R = k['x']; x = R.gen() sage: S = R['t']; t = S.gen() sage: SBar = S.quotient(t^4 + t^3 + t^2 + t + 1, 'a'); a = SBar.gen() sage: print x*a^4 x*a^3 + x*a^2 + x*a + x How can I change this basis to normal basis, so I get: sage: print x*a^4 x*a^4 Thank you very much for your attention. Ahmad --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/ -~--~~~~--~~--~--~---
[sage-support] Strange Error in Converting polynomials to vector
I just tried this and when the field is bigger or equal to 2^16 I got following error: 2^15: Fine! K.a = GF(2^15, 'a') V = K.vector_space() z = (a+1)^13 V(z) (1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0) 2^16: Error! K.a = GF(2^16, 'a') V = K.vector_space() z = (a+1)^13 V(z) Exception (click to the left for traceback): ... TypeError: can't initialize vector from nonzero non-list I just wanted to know what is the difference between case 2^15 and 2^16. Thanx in advance! Bests, Ahmad --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/ -~--~~~~--~~--~--~---
[sage-support] Re: Strange Error in Converting polynomials to vector
Anyway the to_V function introduced by William is wokring fine: def to_V(w): return V(w.polynomial().padded_list(V.dimension())) On Oct 1, 5:35 am, Ahmad [EMAIL PROTECTED] wrote: I just tried this and when the field is bigger or equal to 2^16 I got following error: 2^15: Fine! K.a = GF(2^15, 'a') V = K.vector_space() z = (a+1)^13 V(z) (1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0) 2^16: Error! K.a = GF(2^16, 'a') V = K.vector_space() z = (a+1)^13 V(z) Exception (click to the left for traceback): ... TypeError: can't initialize vector from nonzero non-list I just wanted to know what is the difference between case 2^15 and 2^16. Thanx in advance! Bests, Ahmad --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/ -~--~~~~--~~--~--~---
[sage-support] Re: Strange Error in Converting polynomials to vector
Thanx! On Oct 1, 9:16 am, Martin Albrecht [EMAIL PROTECTED] wrote: I just wanted to know what is the difference between case 2^15 and 2^16. Thanx in advance! Bests, Ahmad These are different implementations. GF(2^15) uses Givaro under the hood and GF(2^16) is using Pari/GP. I'll open a trac ticket about that bug. Martin PS: GF(p^n) for p^n = 2^16 should/will be re-implemented using NTL eventually. -- name: Martin Albrecht _pgp:http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0x8EF0DC99 _www:http://www.informatik.uni-bremen.de/~malb _jab: [EMAIL PROTECTED] --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/ -~--~~~~--~~--~--~---
[sage-support] Re: Changing basis in finite fields
Thanks again! I got the idea now. However, there is a problem which sticks me in the first stage and if I can solve it so your code work as prefect for me. The problem is that the instruction v(z) is not strong enough for my popuse. It works prefect when z is in k = GF(2^5) but it is not working when z is in the polynomial ring of GF(2^5)[x]. I can show it by an example: k.a = GF(2^5, name='a'); V = k.vector_space(); R.x = k['x']; FieldElm= a; PolyRingElm = x*a; print V(FieldElm); print V(PolyRingElm); And the result is: (0, 1, 0, 0, 0) Traceback (most recent call last): File stdin, line 1, in module File /home/amadi/Programmes/Sage/sage-2.8.3-linux-32bit-debian-4.0-i686- Linu\ x/sage_notebook/worksheets/admin/0/code/35.py, line 12, in module exec compile(ur'print V(PolyRingElm);' + '\n', '', 'single') File /home/amadi/Programmes/Sage/sage-2.8.3-linux-32bit-debian-4.0-i686- Linu\ x/data/extcode/sage/, line 1, in module File /home/amadi/Programmes/Sage/sage-2.8.3-linux-32bit-debian-4.0-i686- Linu\ x/local/lib/python2.5/site-packages/sage/modules/free_module.py, line 2802, in __call__ return FreeModule_generic_field.__call__(self,e) File /home/amadi/Programmes/Sage/sage-2.8.3-linux-32bit-debian-4.0-i686- Linu\ x/local/lib/python2.5/site-packages/sage/modules/free_module.py, line 504, in __call__ w = self._element_class(self, x, coerce, copy) File vector_modn_dense.pyx, line 134, in vector_modn_dense.Vector_modn_dense.__init__ TypeError: can't initialize vector from nonzero non-list Could you please help me to make the vector space aspect of my finite field works for its polynomial ring as well and give me something like: (0, x, 0, 0, 0) Thank you in advance! Bests, Ahmad On Sep 4, 5:53 pm, William Stein [EMAIL PROTECTED] wrote: On 9/4/07, David Joyner [EMAIL PROTECTED] wrote: I have to define two functions below in order to do this. If people think something like this would be generally useful, then it could be made built in to SAGE: I think it would be nice to have in_terms_of_normal_basis (of course you need to change 2 to p in general). However, I don't understand what to_V does that built-in coersion doesn't already do: sage: k.a = GF(2^5) sage: V = k.vector_space() sage: z = (1+a)^17; z a^3 + a + 1 sage: V(z) (1, 1, 0, 1, 0) This seems to be the same output you gave for to_V(z), or am I missing something? Hey, good point! Just change to_V(z) to V(z) everywhere. Here's a new worksheet: ahmad -- sage-support system:sage {{{id=0| k.a = GF(2^5) }}} {{{id=1| k /// Finite Field in a of size 2^5 }}} {{{id=2| V = k.vector_space() }}} {{{id=3| z = (1+a)^17; z /// a^3 + a + 1 }}} {{{id=6| B2 = [(a+1)^(2^i) for i in range(k.degree())] }}} {{{id=7| W = [V(b) for b in B2] }}} {{{id=8| V.span(W).dimension() /// 5 }}} {{{id=9| W0 = V.span_of_basis(W) }}} {{{id=10| def in_terms_of_normal_basis(z): return W0.coordinates(z) }}} {{{id=11| in_terms_of_normal_basis(a+1) /// [1, 0, 0, 0, 0] }}} {{{id=12| in_terms_of_normal_basis(1 + a + a^2 + a^3) /// [1, 0, 0, 1, 0] }}} --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/ -~--~~~~--~~--~--~---
[sage-support] Re: Changing basis in finite fields
Thank you very much! These were surprisingly fast replies! I tried to run william's code, but appearently my version of sage does not understand padded_list property: z.polynomial().padded_list(5) sage: z.polynomial().padded_list(5) --- type 'exceptions.AttributeError'Traceback (most recent call last) /home/amadi/Programmes/Sage/sage-2.6.linux32bit-i686-Linux/ipython console in module() type 'exceptions.AttributeError': 'Polynomial_dense_mod_p' object has no attribute 'padded_list' I'm writing it while I'm downloading Sage again. On Sep 3, 4:29 pm, William Stein [EMAIL PROTECTED] wrote: On 9/3/07, Ahmad [EMAIL PROTECTED] wrote: I'm new to sage and I don't know even if I'm supposed to post such questions to this group or not. If it is a correct place: Could you please tell me how can I change the basis in finite field representation. As much as know sage represent the finite field extension in: [1, t, t^2, .., t^{n-1}] for t being the root of irreducible polynomial used to extend the field. I need to represent my field in normal basis (I have chosen my irreducible polynomial such that [t, t^2, t^4 .., t^{2^{n-1}}] forms a basis for the extension). If it is not a correct place to ask such questions, please guide me to the correct place. Thank you very much for your attention and devotion of time! Here is an example session in which I create a finite field, find a normal basis, then explicitly represent elements in terms of it (by pushing everything over to vector spaces). I have to define two functions below in order to do this. If people think something like this would be generally useful, then it could be made built in to SAGE: sage: k.a = GF(2^5) sage: k Finite Field in a of size 2^5 sage: V = k.vector_space() sage: z = (1+a)^17; z a^3 + a + 1 sage: def to_V(w): ... return V(w.polynomial().padded_list(V.dimension())) sage: to_V(z) (1, 1, 0, 1, 0) sage: B2 = [(a+1)^(2^i) for i in range(k.degree())] sage: W = [to_V(b) for b in B2] sage: V.span(W).dimension() 5 sage: W0 = V.span_of_basis(W) sage: def in_terms_of_normal_basis(z): ... return W0.coordinates(to_V(z)) sage: in_terms_of_normal_basis(a+1) [1, 0, 0, 0, 0] sage: in_terms_of_normal_basis(1 + a + a^2 + a^3) [1, 0, 0, 1, 0] Or, in SAGE notebook text format: ahmad -- sage-support system:sage {{{id=0| k.a = GF(2^5) }}} {{{id=1| k /// Finite Field in a of size 2^5 }}} {{{id=2| V = k.vector_space() }}} {{{id=3| z = (1+a)^17; z /// a^3 + a + 1 }}} {{{id=4| def to_V(w): return V(w.polynomial().padded_list(V.dimension())) }}} {{{id=5| to_V(z) /// (1, 1, 0, 1, 0) }}} {{{id=6| B2 = [(a+1)^(2^i) for i in range(k.degree())] }}} {{{id=7| W = [to_V(b) for b in B2] }}} {{{id=8| V.span(W).dimension() /// 5 }}} {{{id=9| W0 = V.span_of_basis(W) }}} {{{id=10| def in_terms_of_normal_basis(z): return W0.coordinates(to_V(z)) }}} {{{id=11| in_terms_of_normal_basis(a+1) /// [1, 0, 0, 0, 0] }}} {{{id=12| in_terms_of_normal_basis(1 + a + a^2 + a^3) /// [1, 0, 0, 1, 0]}}} \ --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/ -~--~~~~--~~--~--~---
[sage-support] Changing basis in finite fields
Dear All, I'm new to sage and I don't know even if I'm supposed to post such questions to this group or not. If it is a correct place: Could you please tell me how can I change the basis in finite field representation. As much as know sage represent the finite field extension in: [1, t, t^2, .., t^{n-1}] for t being the root of irreducible polynomial used to extend the field. I need to represent my field in normal basis (I have chosen my irreducible polynomial such that [t, t^2, t^4 .., t^{2^{n-1}}] forms a basis for the extension). If it is not a correct place to ask such questions, please guide me to the correct place. Thank you very much for your attention and devotion of time! Bests, Ahmad --~--~-~--~~~---~--~~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/ -~--~~~~--~~--~--~---