Karim BELABAS on Mon, 14 Feb 2000 15:18:57 +0100 (MET)

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: gisirreducible

> I would like to use gisirreducible in a C program to test some
> polynomials, but I really don't find the correct way of using this
> function.
> If I define pol as a polynomial, others functions (polroots, gsubst)
> work perfectly well, but I don't know the type of gisirreducible(pol).
> Is it an int, a t_INT?

(15:03) gp > ??polisirreducible 

   The library syntax is gisirreducible(pol).

There's no special mention so everything in sight (argument, return value) 
is a GEN. It would seem more logical for an apparently boolean function to
return an int; but it's not boolean since you can apply it, e.g to vectors
of polynomials (the result being a vector of boolean values).

Applied to an ordinary polynomial the result should have type t_INT and be
equal to gzero or gun [ don't use such hardcoded values though, the correct
way to test is indeed "if (gcmp1(gisirreducible(pol))". ]

>  Attempts like
> "output(gisirreducible(pol));"

This is correct and should work, assuming pol is a valid GEN object.

> "printf("%d\n",gisirreducible(pol));"

This is syntactically valid but yields a completely unexpected result (the
address of the returned GEN, typecast to a long).

> "if(gcmp1(gisirreducible(pol)))"

This is also correct.

> and so on can always be compiled, but execution yields something like
> x^11 - 11*x^9 + 43*x^7 - 70*x^5 - 2*x^4 + 41*x^3 + 7*x^2 - 5*x - 2
>   ***   segmentation fault: bug in PARI or calling program.
>   ***   Error in the PARI system. End of program.

What is the complete program ? None of the snippets above should output the

/* test.c */
#include <pari.h>

main() {
  GEN pol;
  pol = flisexpr("x^11-11*x^9+43*x^7-70*x^5-2*x^4+41*x^3+7*x^2-5*x-2");

(15:14)(*1) orkay-karim % gcc test.c -lpari -lm
(15:14)(*1) orkay-karim % ./a.out

[It may also be a bug in your PARI library. Check the output of
polisirreducible(pol) under GP]

Hope this help,

Karim Belabas                    email: Karim.Belabas@math.u-psud.fr
Dep. de Mathematiques, Bat. 425
Universite Paris-Sud             Tel: (00 33) 1 69 15 57 48
F-91405 Orsay (France)           Fax: (00 33) 1 69 15 60 19
PARI/GP Home Page: http://hasse.mathematik.tu-muenchen.de/ntsw/pari/