gap-packages / PARIInterface

An interface to the PARI computer algebra library
GNU General Public License v2.0
0 stars 3 forks source link

PARIPolynomial should be converted back to GAP polynomial #17

Open videlec opened 5 years ago

videlec commented 5 years ago

For now, conversion to pari polynomials are converted into vectors

gap> LoadPackage("PARIInterface");;
gap> x := Indeterminate(Rationals, "x");;
gap> p := PARIPolynomial(3*x^2 + 2*x + 1);
PARI(3*x^2 + 2*x + 1)
gap> PARI_GEN_TO_OBJ(p);
[ 1, 2, 3 ]

It would be nicer if we would get back the original

Also, conversion to pari polynomials forget about variable names

gap> LoadPackage("PARIInterface");
true
gap> PARI_UNIPOLY([1,2,3]);
PARI(3*x^2 + 2*x + 1)
gap> x := Indeterminate(Rationals, "x");
x
gap> y := Indeterminate(Rationals, "y");
y
gap> PARIPolynomial(x + 1);
PARI(x + 1)
gap> PARIPolynomial(y + 1);
PARI(x + 1)

If there is no workaround, that should be properly documented.

markuspf commented 5 years ago

Does pari have a way to set variable names, or does it have any other way of identifying variables?

I think we can make this consistent and more useful.

fingolfin commented 5 years ago

In general, since PARI and GAP support different coefficient domains, I don't think this conversion will always be useful / possible. In other similar situations (interfacing one computer algebra system from another) it turned out that for practical computations, you almost never perform conversions, and those usually only happen at the start (to generate input) and the end, i.e., they don't need to be very efficient. Instead, it's better to keep data in the external system, and process it here.

Specifically:

All in all, I usually would avoid any "default" conversions, other than in very specific special cases where they really make sense.