## "Fossies" - the Fresh Open Source Software Archive ### Source code changes of the file "src/basemath/qfsolve.c" betweenpari-2.13.0.tar.gz and pari-2.13.1.tar.gz

About: PARI/GP is a computer algebra system designed for fast computations in number theory (factorizations, algebraic number theory, elliptic curves...), but also contains a large number of other mathematical functions.

qfsolve.c  (pari-2.13.0):qfsolve.c  (pari-2.13.1)
skipping to change at line 433 skipping to change at line 433
* G symmetric integral * G symmetric integral
* Returns [G',U,factd] with U in GLn(Q) such that G'=U~*G*U*constant * Returns [G',U,factd] with U in GLn(Q) such that G'=U~*G*U*constant
* is integral and has minimal determinant. * is integral and has minimal determinant.
* In dimension 3 or 4, may return a prime p if the reduction at p is * In dimension 3 or 4, may return a prime p if the reduction at p is
* impossible because of local nonsolvability. * impossible because of local nonsolvability.
* P,E = factor(+/- det(G)), "prime" -1 is ignored. Destroy E. */ * P,E = factor(+/- det(G)), "prime" -1 is ignored. Destroy E. */
static GEN qfsolvemodp(GEN G, GEN p); static GEN qfsolvemodp(GEN G, GEN p);
static GEN static GEN
qfminimize(GEN G, GEN P, GEN E) qfminimize(GEN G, GEN P, GEN E)
{ {
pari_sp av;
GEN d, U, Ker, sol, aux, faE, faP; GEN d, U, Ker, sol, aux, faE, faP;
long n = lg(G)-1, lP = lg(P), i, dimKer, m; long n = lg(G)-1, lP = lg(P), i, dimKer, m;
faP = vectrunc_init(lP); faP = vectrunc_init(lP);
faE = vecsmalltrunc_init(lP); faE = vecsmalltrunc_init(lP);
av = avma;
U = NULL; U = NULL;
for (i = 1; i < lP; i++) for (i = 1; i < lP; i++)
{ {
GEN p = gel(P,i); GEN p = gel(P,i);
long vp = E[i]; long vp = E[i];
if (!vp || !p) continue; if (!vp || !p) continue;
if (DEBUGLEVEL >= 4) err_printf(" p^v = %Ps^%ld\n", p,vp); if (DEBUGLEVEL >= 4) err_printf(" p^v = %Ps^%ld\n", p,vp);
/* The case vp = 1 can be minimized only if n is odd. */ /* The case vp = 1 can be minimized only if n is odd. */
if (vp == 1 && n%2 == 0) { if (vp == 1 && n%2 == 0) {
vectrunc_append(faP, p); vectrunc_append(faP, p);
vecsmalltrunc_append(faE, 1); vecsmalltrunc_append(faE, 1);
continue; av = avma; continue;
} }
Ker = kermodp(G,p, &dimKer); /* dimKer <= vp */ Ker = kermodp(G,p, &dimKer); /* dimKer <= vp */
if (DEBUGLEVEL >= 4) err_printf(" dimKer = %ld\n",dimKer); if (DEBUGLEVEL >= 4) err_printf(" dimKer = %ld\n",dimKer);
if (dimKer == n) if (dimKer == n)
{ /* trivial case: dimKer = n */ { /* trivial case: dimKer = n */
if (DEBUGLEVEL >= 4) err_printf(" case 0: dimKer = n\n"); if (DEBUGLEVEL >= 4) err_printf(" case 0: dimKer = n\n");
G = ZsymM_Z_divexact(G, p); G = ZsymM_Z_divexact(G, p);
E[i] -= n; E[i] -= n;
i--; continue; /* same p */ i--; continue; /* same p */
} }
skipping to change at line 494 skipping to change at line 495
blocks4(G, dimKer,n, &A,&B,&C); blocks4(G, dimKer,n, &A,&B,&C);
A = ZsymM_Z_divexact(qf_apply_ZM(A,K2), sqri(p)); A = ZsymM_Z_divexact(qf_apply_ZM(A,K2), sqri(p));
B = ZM_Z_divexact(ZM_transmul(B,K2), p); B = ZM_Z_divexact(ZM_transmul(B,K2), p);
G = shallowmatconcat(mkmat2(mkcol2(A,B), G = shallowmatconcat(mkmat2(mkcol2(A,B),
mkcol2(shallowtrans(B), C))); mkcol2(shallowtrans(B), C)));
/* U *= [K2,0;0,Id] */ /* U *= [K2,0;0,Id] */
U = shallowconcat(RgM_Rg_div(RgM_mul(vecslice(U,1,dimKer),K2), p), U = shallowconcat(RgM_Rg_div(RgM_mul(vecslice(U,1,dimKer),K2), p),
vecslice(U,dimKer+1,n)); vecslice(U,dimKer+1,n));
E[i] -= 2*dimKer2; E[i] -= 2*dimKer2;
} }
gerepileall(av, 2, &G, &U);
i--; continue; /* same p */ i--; continue; /* same p */
} }
/* vp = dimKer /* vp = dimKer
* 2nd case: kernel has dim >= 2 and contains an element of norm 0 mod p^2 * 2nd case: kernel has dim >= 2 and contains an element of norm 0 mod p^2
* search for an element of norm p^2... in the kernel */ * search for an element of norm p^2... in the kernel */
sol = NULL; sol = NULL;
if (dimKer > 2) { if (dimKer > 2) {
if (DEBUGLEVEL >= 4) err_printf(" case 2.1\n"); if (DEBUGLEVEL >= 4) err_printf(" case 2.1\n");
dimKer = 3; dimKer = 3;
skipping to change at line 559 skipping to change at line 561
/* Minimization was not possible so far. */ /* Minimization was not possible so far. */
/* If n == 3 or 4, this proves the local nonsolubility at p. */ /* If n == 3 or 4, this proves the local nonsolubility at p. */
if (n == 3 || n == 4) if (n == 3 || n == 4)
{ {
if (DEBUGLEVEL >= 1) err_printf(" no local solution at %Ps\n",p); if (DEBUGLEVEL >= 1) err_printf(" no local solution at %Ps\n",p);
return(p); return(p);
} }
vectrunc_append(faP, p); vectrunc_append(faP, p);
vecsmalltrunc_append(faE, vp); vecsmalltrunc_append(faE, vp);
av = avma;
} }
if (!U) U = matid(n); if (!U) U = matid(n);
else else
{ /* apply LLL to avoid coefficient explosion */ { /* apply LLL to avoid coefficient explosion */
aux = lllint(Q_primpart(U)); aux = lllint(Q_primpart(U));
G = qf_apply_ZM(G,aux); G = qf_apply_ZM(G,aux);
U = RgM_mul(U,aux); U = RgM_mul(U,aux);
} }
return mkvec4(G, U, faP, faE); return mkvec4(G, U, faP, faE);
} }
End of changes. 6 change blocks.
2 lines changed or deleted 5 lines changed or added