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]
> >
> > }}}
>
>
> >
>

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