source: trunk/dports/math/pari/files/upstream-patches @ 21489

Last change on this file since 21489 was 21489, checked in by eridius@…, 13 years ago

Massive update to svn properties on files:
All patchfiles have svn:eol-style removed.
All files that are not in fact able to be executed have svn:executable removed
All binary files have svn:eol-style removed (and are probably corrupt)
All binary files have svn:mime-type set to application/octet-stream
All files which are not patchfiles or binary files have svn:eol-style set to native
All Portfiles have svn:eol-style set to native and svn:executable removed

File size: 12.2 KB
Line 
1Index: src/basemath/base1.c
2===================================================================
3RCS file: /home/cvs/pari/src/basemath/base1.c,v
4retrieving revision 1.248
5retrieving revision 1.248.2.1
6diff -d -u -r1.248 -r1.248.2.1
7--- src/basemath/base1.c        8 Apr 2006 12:11:16 -0000       1.248
8+++ src/basemath/base1.c        16 Nov 2006 09:31:52 -0000      1.248.2.1
9@@ -1169,7 +1169,7 @@
10 {
11   GEN nf = cgetg(10,t_VEC);
12   GEN x = T->x;
13-  GEN invbas, Tr, D, TI, A, dA, MDI, mat = cgetg(8,t_VEC);
14+  GEN absdK, invbas, Tr, D, TI, A, dA, MDI, mat = cgetg(8,t_VEC);
15   nffp_t F;
16   get_nf_fp_compo(T, &F, ro, prec);
17 
18@@ -1190,10 +1190,11 @@
19   if (DEBUGLEVEL) msgtimer("mult. table");
20 
21   Tr = get_Tr(gel(nf,9), x, F.basden);
22-  TI = ZM_inv(Tr, T->dK); /* dK T^-1 */
23+  absdK = T->dK; if (signe(absdK) < 0) absdK = negi(absdK);
24+  TI = ZM_inv(Tr, absdK); /* dK T^-1 */
25   A = Q_primitive_part(TI, &dA);
26   gel(mat,6) = A; /* primitive part of codifferent, dA its denominator */
27-  dA = dA? diviiexact(T->dK, dA): T->dK;
28+  dA = dA? diviiexact(absdK, dA): absdK;
29   A = hnfmodid(A, dA);
30   MDI = ideal_two_elt(nf, A);
31   gel(MDI,2) = eltmul_get_table(nf, gel(MDI,2));
32Index: src/basemath/base3.c
33===================================================================
34RCS file: /home/cvs/pari/src/basemath/base3.c,v
35retrieving revision 1.194
36retrieving revision 1.194.2.1
37diff -d -u -r1.194 -r1.194.2.1
38--- src/basemath/base3.c        11 Apr 2006 17:28:55 -0000      1.194
39+++ src/basemath/base3.c        11 Dec 2006 14:29:52 -0000      1.194.2.1
40@@ -631,7 +631,7 @@
41       return gcopy(x);
42     default: z=cgetg(3,t_POLMOD);
43       gel(z,1) = gcopy(gel(nf,1));
44-      gel(z,2) = gmul(x,pol_1[varn(nf[1])]); return z;
45+      gel(z,2) = gtopoly(x, varn(nf[1])); return z;
46   }
47 }
48 
49Index: src/basemath/ifactor1.c
50===================================================================
51RCS file: /home/cvs/pari/src/basemath/ifactor1.c,v
52retrieving revision 1.104.2.2
53retrieving revision 1.104.2.3
54diff -d -u -r1.104.2.2 -r1.104.2.3
55--- src/basemath/ifactor1.c     4 Oct 2006 13:54:31 -0000       1.104.2.2
56+++ src/basemath/ifactor1.c     11 Dec 2006 14:06:45 -0000      1.104.2.3
57@@ -2432,7 +2432,7 @@
58 int
59 is_357_power(GEN x, GEN *pt, ulong *mask)
60 {
61-  long lx = lgefint(x), exponent, resbyte;
62+  long lx = lgefint(x), resbyte;
63   ulong residue;
64   pari_sp av;
65   GEN y;
66@@ -2468,32 +2468,28 @@
67   if (*mask & 5) check_res( 43UL,18);
68   if (*mask & 6) check_res( 71UL,21);
69 
70-  /* priority to higher powers: if we have a 21st, it is easier to rediscover
71-   * that its 7th root is a cube than that its cube root is a 7th power */
72-  if ( (resbyte = *mask & 4) )
73-    exponent = 7;
74-  else if ( (resbyte = *mask & 2) )
75-    exponent = 5;
76-  else
77-    { resbyte = 1; exponent = 3; }
78-
79   av = avma;
80-  y = mpround( sqrtnr(itor(x, 3 + (lx-2) / exponent), exponent) );
81-  if (!equalii(powiu(y, exponent), x))
82+  while (*mask)
83   {
84-    if (DEBUGLEVEL >= 5)
85+    long e, b;
86+    /* priority to higher powers: if we have a 21st, it is easier to rediscover
87+     * that its 7th root is a cube than that its cube root is a 7th power */
88+         if (*mask & 4) { b = 4; e = 7; }
89+    else if (*mask & 2) { b = 2; e = 5; }
90+    else                { b = 1; e = 3; }
91+    y = mpround( sqrtnr(itor(x, 3 + (lx-2)/e), e) );
92+    if (equalii(powiu(y,e), x))
93     {
94-      if (exponent == 3)
95-       fprintferr("\tBut it nevertheless wasn't a cube.\n");
96-      else
97-       fprintferr("\tBut it nevertheless wasn't a %ldth power.\n", exponent);
98+      if (!pt) { avma = av; return e; }
99+      avma = (pari_sp)y; *pt = gerepileuptoint(av, y);
100+      return e;
101     }
102-    *mask &= ~resbyte; /* turn the bit off */
103-    avma = av; return 0;
104+    if (DEBUGLEVEL >= 5)
105+      fprintferr("\tBut it nevertheless wasn't a %ld%s power.\n", e,eng_ord(e));
106+    *mask &= ~b; /* turn the bit off */
107+    avma = av;
108   }
109-  if (!pt) { avma = av; return exponent; }
110-  avma = (pari_sp)y; *pt = gerepileuptoint(av, y);
111-  return exponent;
112+  return 0;
113 }
114 
115 /* p not necessarily prime */
116Index: src/basemath/polarit1.c
117===================================================================
118RCS file: /home/cvs/pari/src/basemath/polarit1.c,v
119retrieving revision 1.268.2.1
120retrieving revision 1.268.2.2
121diff -d -u -r1.268.2.1 -r1.268.2.2
122--- src/basemath/polarit1.c     3 Aug 2006 17:21:21 -0000       1.268.2.1
123+++ src/basemath/polarit1.c     11 Dec 2006 15:22:37 -0000      1.268.2.2
124@@ -2487,23 +2487,26 @@
125     /* u is square-free (product of irreducibles of multiplicity e) */
126     nb0 = nbfact; N = degpol(u);
127     t[nbfact] = FqX_normalize(u, T,p);
128-    if (N == 1) nbfact++;
129-    else
130-    {
131+    if (N) {
132+      nb0 = nbfact;
133+      t[nbfact] = FqX_normalize(u, T,p);
134+      if (N == 1) nbfact++;
135+      else
136+      {
137 #if 0
138-      nbfact += FqX_split_Berlekamp(t+nbfact, q, T, p);
139+        nbfact += FqX_split_Berlekamp(t+nbfact, q, T, p);
140 #else
141-      GEN P = FqX_split_Trager(t[nbfact], T, p);
142-      if (P) {
143-        for (j = 1; j < lg(P); j++) t[nbfact++] = gel(P,j);
144-      } else {
145-        if (DEBUGLEVEL) pari_warn(warner, "FqX_split_Trager failed!");
146-        nbfact += FqX_sqf_split(t+nbfact, q, T, p);
147-      }
148+        GEN P = FqX_split_Trager(t[nbfact], T, p);
149+        if (P) {
150+          for (j = 1; j < lg(P); j++) t[nbfact++] = gel(P,j);
151+        } else {
152+          if (DEBUGLEVEL) pari_warn(warner, "FqX_split_Trager failed!");
153+          nbfact += FqX_sqf_split(t+nbfact, q, T, p);
154+        }
155 #endif
156+      }
157+      for (j = nb0; j < nbfact; j++) E[j] = e;
158     }
159-    for (j = nb0; j < nbfact; j++) E[j] = e;
160-
161     if (!degpol(f2)) break;
162     f = f2; df1 = df2; e += pk;
163   }
164Index: src/basemath/polarit3.c
165===================================================================
166RCS file: /home/cvs/pari/src/basemath/polarit3.c,v
167retrieving revision 1.325.2.1
168retrieving revision 1.325.2.2
169diff -d -u -r1.325.2.1 -r1.325.2.2
170--- src/basemath/polarit3.c     24 Aug 2006 21:41:42 -0000      1.325.2.1
171+++ src/basemath/polarit3.c     11 Dec 2006 14:27:42 -0000      1.325.2.2
172@@ -3320,13 +3320,13 @@
173     bound = ZY_ZXY_ResBound(A, B, dB);
174     if (bound > 50000)
175     {
176-      long prec = MEDDEFAULTPREC;
177+      long eA = gexpo(A), eB = gexpo(B), prec = nbits2prec(max(eA,eB));
178       for(;; prec = (prec-1)<<1)
179       {
180         GEN run = real_1(prec);
181         GEN R = subres(gmul(A, run), gmul(B, run));
182         bound = gexpo(R) + 1;
183-        if (!gcmp0(R) || bound <= 0) break;
184+        if (!gcmp0(R)) break;
185       }
186       if (dB) bound -= (long)(dbllog2(dB)*degA);
187     }
188Index: src/basemath/trans1.c
189===================================================================
190RCS file: /home/cvs/pari/src/basemath/trans1.c,v
191retrieving revision 1.211.2.1
192retrieving revision 1.211.2.3
193diff -d -u -r1.211.2.1 -r1.211.2.3
194--- src/basemath/trans1.c       30 Sep 2006 11:05:52 -0000      1.211.2.1
195+++ src/basemath/trans1.c       11 Dec 2006 14:24:41 -0000      1.211.2.3
196@@ -1201,7 +1201,7 @@
197     l2 += m>>TWOPOTBITS_IN_LONG;
198   } else { /* rare ! */
199     b = -1 - log((double)(ulong)x[2]) + (BITS_IN_LONG-1-ex)*LOG2; /*-1-log(x)*/
200-    n = (long)(1 + beta/b);
201+    n = (long)(1.1 + beta/b);
202     m = 0;
203   }
204   unr=real_1(l2);
205@@ -1211,15 +1211,14 @@
206 
207   s = 0; l1 = 3; av2 = avma;
208   for (i=n; i>=2; i--)
209-  {
210+  { /* compute X^(n-1)/n! + ... + X/2 + 1 */
211     setlg(X,l1); p3 = divrs(X,i);
212     s -= expo(p3); p1 = mulrr(p3,p2); setlg(p1,l1);
213     l1 += s>>TWOPOTBITS_IN_LONG; if (l1>l2) l1=l2;
214     s &= (BITS_IN_LONG-1);
215     setlg(unr,l1); p1 = addrr_sign(unr,1, p1,1);
216-    setlg(p2,l1); affrr(p1,p2); avma = av2;
217+    setlg(p2,l1); affrr(p1,p2); avma = av2; /* p2 <- 1 + (X/i)*p2 */
218   }
219-  setlg(p2,l2);
220   setlg(X,l2); p2 = mulrr(X,p2);
221 
222   for (i=1; i<=m; i++)
223@@ -1588,8 +1587,8 @@
224   tmplog2 = newbloc(prec);
225   *tmplog2 = evaltyp(t_REAL) | evallg(prec);
226   av = avma;
227-  n = bit_accuracy(prec) >> 1;
228   l = prec+1;
229+  n = bit_accuracy(l) >> 1;
230   y = divrr(Pi2n(-1, l), agm1r_abs( real2n(2 - n, l) ));
231   affrr(divrs(y,n), tmplog2);
232   if (glog2) gunclone(glog2);
233Index: src/basemath/trans2.c
234===================================================================
235RCS file: /home/cvs/pari/src/basemath/trans2.c,v
236retrieving revision 1.123.2.1
237retrieving revision 1.123.2.2
238diff -d -u -r1.123.2.1 -r1.123.2.2
239--- src/basemath/trans2.c       3 Aug 2006 17:13:36 -0000       1.123.2.1
240+++ src/basemath/trans2.c       11 Dec 2006 14:24:41 -0000      1.123.2.2
241@@ -409,12 +409,14 @@
242 mpsh(GEN x)
243 {
244   pari_sp av;
245-  GEN z;
246+  long ex = expo(x), lx;
247+  GEN z, res;
248 
249-  if (!signe(x)) return real_0_bit(expo(x));
250-  av = avma;
251+  if (!signe(x)) return real_0_bit(ex);
252+  lx = lg(x); res = cgetr(lx); av = avma;
253+  if (ex < 1 - BITS_IN_LONG) x = rtor(x, lx + nbits2nlong(-ex)-1);
254   z = mpexp(x); z = addrr(z, divsr(-1,z)); setexpo(z, expo(z)-1);
255-  return gerepileuptoleaf(av, z);
256+  affrr(z, res); avma = av; return res;
257 }
258 
259 GEN
260@@ -447,19 +449,22 @@
261 static GEN
262 mpth(GEN x)
263 {
264-  long l, s = signe(x);
265+  long lx, s = signe(x);
266   GEN y;
267 
268   if (!s) return real_0_bit(expo(x));
269-  l = lg(x);
270-  if (absr_cmp(x, stor(bit_accuracy(l), 3)) >= 0) {
271-    y = real_1(l);
272+  lx = lg(x);
273+  if (absr_cmp(x, stor(bit_accuracy(lx), 3)) >= 0) {
274+    y = real_1(lx);
275   } else {
276     pari_sp av = avma;
277-    GEN t = exp1r_abs(gmul2n(x,1)); /* exp(|2x|) - 1 */
278+    long ex = expo(x);
279+    GEN t;
280+    if (ex < 1 - BITS_IN_LONG) x = rtor(x, lx + nbits2nlong(-ex)-1);
281+    t = exp1r_abs(gmul2n(x,1)); /* exp(|2x|) - 1 */
282     y = gerepileuptoleaf(av, divrr(t, addsr(2,t)));
283   }
284-  if (s < 0) setsigne(y, -signe(y)); /* tanh is odd */
285+  if (s < 0) togglesign(y); /* tanh is odd */
286   return y;
287 }
288 
289@@ -497,10 +502,15 @@
290 static GEN
291 mpash(GEN x)
292 {
293-  pari_sp av = avma;
294-  GEN z = logr_abs( addrr_sign(x,1, sqrtr( addrs(mulrr(x,x), 1) ), 1) );
295-  if (signe(x) < 0) setsigne(z, -signe(z));
296-  return gerepileuptoleaf(av, z);
297+  GEN z, res;
298+  pari_sp av;
299+  long lx = lg(x), ex = expo(x);
300
301+  res = cgetr(lx); av = avma;
302+  if (ex < 1 - BITS_IN_LONG) x = rtor(x, lx + nbits2nlong(-ex)-1);
303+  z = logr_abs( addrr_sign(x,1, sqrtr( addrs(mulrr(x,x), 1) ), 1) );
304+  if (signe(x) < 0) togglesign(z);
305+  affrr(z, res); avma = av; return res;
306 }
307 
308 GEN
309@@ -623,7 +633,10 @@
310 mpath(GEN x)
311 {
312   pari_sp av = avma;
313-  GEN z = logr_abs( addrs(divsr(2,subsr(1,x)), -1) );
314+  long ex = expo(x);
315+  GEN z;
316+  if (ex < 1 - BITS_IN_LONG) x = rtor(x, lg(x) + nbits2nlong(-ex)-1);
317+  z = logr_abs( addrs(divsr(2,subsr(1,x)), -1) );
318   setexpo(z, expo(z)-1); return gerepileuptoleaf(av, z);
319 }
320 
321Index: src/headers/parigen.h
322===================================================================
323RCS file: /home/cvs/pari/src/headers/parigen.h,v
324retrieving revision 1.27
325retrieving revision 1.27.2.1
326diff -d -u -r1.27 -r1.27.2.1
327--- src/headers/parigen.h       19 Apr 2006 16:18:26 -0000      1.27
328+++ src/headers/parigen.h       11 Dec 2006 14:24:41 -0000      1.27.2.1
329@@ -105,6 +105,7 @@
330 #define signe(x)      ((((long*)(x))[1]) >> SIGNSHIFT)
331 #define setsigne(x,s) (((ulong*)(x))[1]=\
332                         (((ulong*)(x))[1]&(~SIGNBITS)) | (ulong)evalsigne(s))
333+#define togglesign(x) (void)((((GEN)(x))[1] & SIGNBITS) && (((GEN)(x))[1] ^= HIGHBIT))
334 
335 #define lgeflist(x)      (((long*)(x))[1])
336 #define setlgeflist(x,l) (((ulong*)(x))[1]=(ulong)(l))
337Index: src/kernel/gmp/mp.c
338===================================================================
339RCS file: /home/cvs/pari/src/kernel/gmp/mp.c,v
340retrieving revision 1.87.2.1
341retrieving revision 1.87.2.2
342diff -d -u -r1.87.2.1 -r1.87.2.2
343--- src/kernel/gmp/mp.c 12 Sep 2006 13:52:04 -0000      1.87.2.1
344+++ src/kernel/gmp/mp.c 22 Nov 2006 21:20:28 -0000      1.87.2.2
345@@ -126,7 +126,10 @@
346 
347 /* we had a = setloop(?), then some incloops. Reset a to b */
348 GEN
349-resetloop(GEN a, GEN b) { affii(b, a); return a; }
350+resetloop(GEN a, GEN b) {
351+  a[0] = evaltyp(t_INT) | evallg(lgefint(b));
352+  affii(b, a); return a;
353+}
354 
355 /* assume a > 0, initialized by setloop. Do a++ */
356 static GEN
357Index: src/language/members.c
358===================================================================
359RCS file: /home/cvs/pari/src/language/members.c,v
360retrieving revision 1.24
361retrieving revision 1.24.2.1
362diff -d -u -r1.24 -r1.24.2.1
363--- src/language/members.c      15 Mar 2006 09:26:40 -0000      1.24
364+++ src/language/members.c      16 Nov 2006 16:18:31 -0000      1.24.2.1
365@@ -206,9 +206,10 @@
366 GEN
367 member_codiff(GEN x) /* codifferent */
368 {
369-  long t; GEN nf = get_nf(x,&t), y = nfmats(nf);
370+  long t; GEN H, nf = get_nf(x,&t), y = nfmats(nf);
371   if (!y) member_err("codiff");
372-  return gdiv(gel(y,6), absi(gel(nf,3)));
373+  H = hnf(gel(y,6));
374+  return gdiv(H, gcoeff(H,1,1));
375 }
376 
377 GEN
Note: See TracBrowser for help on using the repository browser.