Dear Simon,
On Jul 20, 11:53 pm, Simon King <[email protected]> wrote:
> Hi!
>
> On 20 Jul., 22:58, eggartmumie <[email protected]> wrote:
>
> > def goppapolynomial(F,z): # return a Goppa polynomial in z over ring
> > or field F
> > X = str(z); R.<X> = PolynomialRing(F);
> > return R(X^(N-K));
>
> First of all, the notation R.<X> = F[] will work on the command line,
> but will not work in a .py file, because this notation is not Python
> syntax, but is a syntactic sugar provided by the Sage preparser. And
> of course, it is not possible to use a string instead of an
> identifier.
>
> Looking at the documentation (e.g., doing
> sage: PolynomialRing?
> ) you'll find what the "pure python" notation is, and in particular
> also to solve the problem of passing an arbitrary variable name. For
> instance:
>
> sage: P = PolynomialRing(QQ, 'w')
> sage: X = P.gen()
> sage: P; X
> Univariate Polynomial Ring in w over Rational Field
> w
>
> So:
> def goppapolynomial(F,z): # return a Goppa polynomial in z over ring
> or field F
> X = PolynomialRing(F,repr(z)).gen()
> return X^(N-K)
> should work (supposed that N and K are defined).
Sorry to bother You again:
I read the reference, I followed Your advice, all I get is a
polynomial of type
'sage.rings.polynomial.polynomial_zz_pex.Polynomial_ZZ_pEX'
which I connot coerce to the intended data type (I tried e.g.
PR = PolynomialRing(F,repr(z)); X = PolynomialRing(F,repr(z)).gen();
return PR(X^(N-K));
or
from sage.symbolic.expression_conversions import polynomial;
polynomial(g,ring = PR)
or also
polynomial(g, base_ring = F)
and the like) so that I cannot differentiate it to compute the
coefficients of the polynomial
represented as a linear combination of monomials (instead as a
product)
where I tried
vars = var('x'); g = function('g',x); g(x)=goppapolynomial(F,x); #
otherwise SAGE cannot differentiate
...
dg = diff(g,x); coeff[0]=dg(0);
For me as a newbie it is difficult to find the obvious in a 5000plus
pages reference manual.
Difficulties like that keep me from implementing Goppa codes in
SAGE ...
kind of discouraging experience, any advice welcome, EM
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org