"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/basemath/alglin1.c" between
pari-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.

alglin1.c  (pari-2.13.0):alglin1.c  (pari-2.13.1)
skipping to change at line 2890 skipping to change at line 2890
} }
/* N.B. Our delta/lambda are SQUARES of those in the paper /* N.B. Our delta/lambda are SQUARES of those in the paper
* log(delta lambda) / log p, where lambda is 3+sqrt(5) / 2, * log(delta lambda) / log p, where lambda is 3+sqrt(5) / 2,
* whose log is < 1, hence + 1 (to cater for rounding errors) */ * whose log is < 1, hence + 1 (to cater for rounding errors) */
m = (long)ceil((dbllog2(delta)*M_LN2 + 1) / log((double)p)); m = (long)ceil((dbllog2(delta)*M_LN2 + 1) / log((double)p));
res = ZlM_gauss_ratlift(a, b, p, m, C); res = ZlM_gauss_ratlift(a, b, p, m, C);
if (iscol) return gerepilecopy(av, gel(res, 1)); if (iscol) return gerepilecopy(av, gel(res, 1));
return gerepileupto(av, res); return gerepileupto(av, res);
} }
/* #C = n, C[z[i]] = K[i], complete by 0s */
static GEN static GEN
RgC_inflate(GEN K, GEN v, long n) RgC_inflate(GEN K, GEN z, long n)
{ {
GEN c = zerocol(n); GEN c = zerocol(n);
long j, l = lg(K); long j, l = lg(K);
for (j = 1; j < l; j++) gel(c, v[j]) = gel(K, j); for (j = 1; j < l; j++) gel(c, z[j]) = gel(K, j);
return c; return c;
} }
/* in place: C[i] *= cB / v[i] */
static void
QC_normalize(GEN C, GEN v, GEN cB)
{
long l = lg(C), i;
for (i = 1; i < l; i++)
{
GEN c = cB, k = gel(C,i), d = gel(v,i);
if (d)
{
if (isintzero(d)) { gel(C,i) = gen_0; continue; }
c = div_content(c, d);
}
gel(C,i) = c? gmul(k,c): k;
}
}
/* same as above, M rational; if flag = 1, call indexrank and return 1 sol */ /* same as above, M rational; if flag = 1, call indexrank and return 1 sol */
GEN GEN
QM_gauss_i(GEN M, GEN B, long flag) QM_gauss_i(GEN M, GEN B, long flag)
{ {
pari_sp av = avma; pari_sp av = avma;
long i, l = lg(M); long i, l, n;
int col = typ(B) == t_COL;
GEN K, cB, N = cgetg_copy(M, &l), v = cgetg(l, t_VEC), z2 = NULL; GEN K, cB, N = cgetg_copy(M, &l), v = cgetg(l, t_VEC), z2 = NULL;
for (i = 1; i < l; i++) for (i = 1; i < l; i++)
gel(N,i) = Q_primitive_part(gel(M,i), &gel(v,i)); gel(N,i) = Q_primitive_part(gel(M,i), &gel(v,i));
if (flag) if (flag)
{ {
GEN z = ZM_indexrank(N), z1 = gel(z,1); GEN z = ZM_indexrank(N), z1 = gel(z,1);
z2 = gel(z,2); z2 = gel(z,2);
N = shallowmatextract(N, z1, z2); N = shallowmatextract(N, z1, z2);
B = typ(B) == t_MAT? rowpermute(B,z1): vecpermute(B,z1); B = col? vecpermute(B,z1): rowpermute(B,z1);
if (lg(z2) == l) z2 = NULL; else { v = vecpermute(v, z2); l = lg(v); } if (lg(z2) == l) z2 = NULL; else v = vecpermute(v, z2);
} }
B = Q_primitive_part(B, &cB); B = Q_primitive_part(B, &cB);
K = ZM_gauss(N, B); if (!K) return gc_NULL(av); K = ZM_gauss(N, B); if (!K) return gc_NULL(av);
for (i = 1; i < l; i++) n = l - 1;
if (col)
{ {
GEN c, k = gel(K,i), d = gel(v,i); QC_normalize(K, v, cB);
if (d) if (z2) K = RgC_inflate(K, z2, n);
{
if (isintzero(d))
{
if (gequal0(k)) continue;
return NULL;
}
d = inv_content(d);
}
c = mul_content(cB, d);
if (c) gel(K,i) = gmul(gel(K,i), c);
} }
if (z2) else
{ {
long n = lg(M)-1; long lK = lg(K);
if (typ(B) == t_COL) K = RgC_inflate(K, z2, n); for (i = 1; i < lK; i++)
else
{ {
l = lg(B); QC_normalize(gel(K,i), v, cB);
for (i = 1; i < l; i++) gel(B,i) = RgC_inflate(gel(B,i), z2, n); if (z2) gel(K,i) = RgC_inflate(gel(K,i), z2, n);
} }
} }
return gerepilecopy(av, K); return gerepilecopy(av, K);
} }
GEN GEN
QM_gauss(GEN M, GEN B) { return QM_gauss_i(M, B, 0); } QM_gauss(GEN M, GEN B) { return QM_gauss_i(M, B, 0); }
static GEN static GEN
ZM_inv_slice(GEN A, GEN P, GEN *mod) ZM_inv_slice(GEN A, GEN P, GEN *mod)
{ {
 End of changes. 12 change blocks. 
24 lines changed or deleted 34 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)