Bill Allombert on Sun, 10 Apr 2011 12:55:41 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: int array to poly (libpari) |
On Sun, Apr 10, 2011 at 12:54:57PM +0300, Eugene N wrote: > Hello > > I am writing some C code, wich will check if a polynomial is irreducible > (with libpari *gpolisirreducible*). > > Poly will be in the form of int poly[]= {m,m-1,...,0}; (over GF[2]) > > I am new to pari, and so far i only have seen *gp_read_str *as means of > initializing a GEN object from C string. > > But in general, how can i initialize a poly from array? Read section 4.5.10 of the manual: The following sample function convert poly to a GEN of type t_POL with integers coefficients. You can then use FpX_nbfact(x,gen_2)==1 to check for irreducibility modulo 2. GEN poly2pari(long m, long *poly) { long l = m+3; GEN x = cgetg(l, t_POL); x[1] = evalvarn(0); for(i=0;i<=m;i++) gel(x, i+2) = stoi(i); return normalizepol_lg(x, l); } Cheers, Bill.