If I understand you correctly you want to think of your elements as
belonging to a 5-dimensional vector space (or module rather) over
GF(2)[x], while they are being represented as elements of k[x] where k
is a 5-dimensional extension of GF(2).

It's a common problem:  mathematically, adjoining the indeterminate x
and then the algebraic element a, in that order, gives you an
isomorphic structure to adjoining first a and then x;  but the
representations are different.  I have had such situations before
(using Magma) but it would be very helpful if someone more sage than
me (!) could give a solution here as elegant as William's earlier one.

John

On 9/7/07, Ahmad <[EMAIL PROTECTED]> wrote:
>
> Hi David,
>
> I can use R instead of V but in this case I can not take the profit of
> the instructions that William has been wrote to represent my
> polynomial in Normal basis like "span_of_basis()" and "coordinates()".
>
> So what I ultimately want is that if I write these:
>
> sage: k.<a> = GF(2^5, name='a')
> sage: R.<x> = k['x']
> sage: MyPoly = x*a^8
> sage: print MyPoly
> (a^3 + a^2 + 1)*x
>
> My results would be in normal basis and the sage just gives me:
>
> a^8*x
>
> instead of :
>
> (a^3 + a^2 + 1)*x
>
> Maybe my example wasn't clear enough so if I change my program to:
>
> sage: k.<a> = GF(2^5, name='a')
> sage: V = k.vector_space()
> sage: R.<x> = k['x']
> sage: PolyRingElm = x*a^8;
> sage: print V(PolyRingElm)
>
> I would like to get something like to get something like:
>
> (0,0,0,x,0)
>
> in Normal Basis. It is exactly my problem. I need to get the sage
> results in polynomial ring in normal basis. Not just the sage result
> in original field in normal basis.
>
> After all I'm addicted to simicolons because of my habit of C
> Programming! Is not necessary at all? ;)
>
> Ahmad
>
>
> On Sep 6, 6:27 am, "David Joyner" <[EMAIL PROTECTED]> wrote:
> > On 9/6/07, Ahmad <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> >
> >
> > > 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);
> >
> > Use R not V for that:
> >
> > sage: print R(PolyRingElm)
> > a*x
> >
> > You are coercing into the ring not the vector space.
> > Also, why are you using semicolons?
> >
> >
> >
> > > 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]
> >
> > > > }}}
>
>
> >
>


-- 
John Cremona

--~--~---------~--~----~------------~-------~--~----~
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/
-~----------~----~----~----~------~----~------~--~---

Reply via email to