Commit 687c3dd4 authored by Peter Bruin's avatar Peter Bruin

improve stack handling in multiply_power_series_Flxq

parent 9399bea2
......@@ -92,14 +92,16 @@ multiply_power_series_Fl (GEN s, GEN t, unsigned long p) {
static GEN
multiply_power_series_Flxq (GEN s, GEN t, unsigned long p, GEN T) {
int i, l = lg (s);
long i, l = lg(s), n;
GEN s1, t1, tmp, result;
pari_sp av = avma;
pari_sp av;
if (typ (s) != t_COL
|| typ (t) != t_COL
|| lg (t) != l)
pari_err_TYPE2("multiply_power_series_Flxq", s, t);
result = cgetg(l, t_COL);
av = avma;
s1 = cgetg(l + 1, t_POL);
t1 = cgetg(l + 1, t_POL);
s1[1] = evalsigne(1) | evalvarn(MAXVARN);
......@@ -108,16 +110,22 @@ multiply_power_series_Flxq (GEN s, GEN t, unsigned long p, GEN T) {
gel (s1 + 1, i) = gel (s, i);
for(i = 1; i < l; i++)
gel (t1 + 1, i) = gel (t, i);
tmp = FlxqX_mul (s1, t1, T, p);
result = cgetg (l, t_COL);
for (i = 1; i < lg(tmp) - 1; i++)
gel (result, i) = gel (tmp, i + 1);
/* next 4 lines == FlxqX_mul without gerepile */
s1 = zxX_to_Kronecker(s1, T);
t1 = zxX_to_Kronecker(t1, T);
tmp = Flx_mul(s1, t1, p);
tmp = Kronecker_to_FlxqX(tmp, T, p);
n = minss(l - 1, lg(tmp) - 2);
for (i = 1; i <= n; i++)
gel(result, i) = gel(tmp, i + 1);
avma = (pari_sp) gel(tmp, n + 1);
gerepilecoeffssp(av, (pari_sp) tmp, result + 1, n);
if (i < l) {
GEN z = zero_Flx(varn(T));
long v = varn(T);
for (; i < l; i++)
gel (result, i) = z;
gel(result, i) = zero_Flx(v);
}
return gerepilecopy (av, result);
return result;
}
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment