| Karim Belabas on Sun, 17 Nov 2019 19:40:24 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: List of polynomial coefficients in GP |
* Jacques Gélinas [2019-11-15 16:52]:
> Is there a direct way to get the list of coefficients of a polynomial in GP ?
> Consider for example a polynomial with parameter P (representing Pi) in its coefficients:
> Vec(subst(1*u+2*P-6,u,x+3)) == [1, 2*P - 3]
> is what I want, but this fails in
> Vec(subst(0*u+2*P-6,u,x+3)) == [2, -6]
> so I must use
> cofs(p,v='x) = vector(1+max(0,poldegree(p,v)),k,polcoeff(p,k-1,v));
> to get
> cofs(subst(0*u+2*P-6,u,x+3),u) == [2*P - 6]
>
> Any suggestions for a simpler solution ?
I fixed a number of inconsistencies in subst's handling of constant
polynomials. This includes the one mentionned by Bill and a few others like
(19:37) gp > subst('u^0,u,Mat(Mod(1,2)))
%1 =
[1]
(19:37) gp > subst(0*'u^0,u,Mat(Mod(1,2)))
%2 =
[Mod(0, 2)]
(19:38) gp > subst(0*'u^0,u,Mod(matid(2),2))
%3 =
[Mod(0, 2) 0]
[ 0 Mod(0, 2)]
In particular, in 'master', I now get the expected
(19:38) gp > Vec(subst(1*u+2*P-6,u,x+3))
%4 = [1, 2*P - 3]
Cheers,
K.B.
--
Karim Belabas, IMB (UMR 5251) Tel: (+33) (0)5 40 00 26 17
Universite de Bordeaux Fax: (+33) (0)5 40 00 21 23
351, cours de la Liberation http://www.math.u-bordeaux.fr/~kbelabas/
F-33405 Talence (France) http://pari.math.u-bordeaux.fr/ [PARI/GP]
`