[Ecm-commits] r2387 - trunk

cvs commits ecm-commits at lists.gforge.inria.fr
Mon Feb 11 11:17:38 CET 2013


Author: morain
Date: 2013-02-11 11:17:37 +0100 (Mon, 11 Feb 2013)
New Revision: 2387

Log:
Various bug fixes + improvement in dump_curves.


Modified:
   trunk/ecm.c
   trunk/manyecm.c
   trunk/stage2.c
Modified: trunk/ecm.c
===================================================================
--- trunk/ecm.c	2013-02-10 17:29:59 UTC (rev 2386)
+++ trunk/ecm.c	2013-02-11 10:17:37 UTC (rev 2387)
@@ -1505,7 +1505,10 @@
       P.disc = E->disc;
 #endif
       mpres_init(P.sq[0], modulus);
-      mpres_set(P.sq[0], E->sq[0], modulus);
+      if(mpz_cmp_ui(zE->sq[0], 1) == 0) /* humf */
+	  mpz_set_ui(P.sq[0], 1);
+      else
+	  mpres_set(P.sq[0], E->sq[0], modulus);
   }
   
   if (youpi == ECM_NO_FACTOR_FOUND && mpz_cmp (B2, B2min) >= 0)

Modified: trunk/manyecm.c
===================================================================
--- trunk/manyecm.c	2013-02-10 17:29:59 UTC (rev 2386)
+++ trunk/manyecm.c	2013-02-11 10:17:37 UTC (rev 2387)
@@ -53,6 +53,7 @@
 	mpz_set(params->y, P->y);
     }
     params->E = E;
+
     ret = ecm_factor(f, N, B1, params);
     return ret;
 }
@@ -106,12 +107,18 @@
 
     gmp_printf("p:=%Zd; F:=GF(p); P:=[]; A:=[]; B:=[]; E:=[]; D:=[];\n", f);
     printf("CheckE:=procedure(E, D, P, info)\n");
+    printf("    K:=QuadraticField(D); OK:=MaximalOrder(K);\n");
     printf("    printf \"#E[%%o]=%%o\\n\", info, Factorization(#E);\n");
     printf("    gen:=Generators(E);\n");
     printf("    printf \"ords=%%o\\n\", ");
     printf("[Factorization(Order(g)) : g in gen];\n");
-    printf("    printf \"ord(P)=%%o\\n\", ");
-    printf("Factorization(Order(E!P));\n");
+    printf("    lf:=Factorization(Order(E!P));\n");
+    printf("    printf \"ord(P)=%%o\\n\", lf;\n");
+    printf("    for i:=1 to #lf do\n");
+    printf("        lfi:=Factorization(lf[i][1]*OK);\n");
+    printf("        ok,gen:=IsPrincipal(lfi[1][1]);\n");
+    printf("        print lf[i], ok, gen;\n");
+    printf("    end for;\n");
     printf("end procedure;\n");
     for(i = 0; i < nE; i++){
 	printf("D[%d]:=%d;\n", i+1, tE[i]->disc);
@@ -762,12 +769,13 @@
 static
 int psb_minus_even(mpz_t sqroots[], int b, int k, mpz_t N)
 {
-    /* set squareroot of -1 */
+    printf("# got sqrt(-1)\n");
     mpz_init_set_si(sqroots[0], b);
     mpz_powm_ui(sqroots[0], sqroots[0], k, N);
     if(k % 2 == 0){
 	/* zeta8 = b^(k/2) = (1+zeta4)/sqrt(2) 
 	   => sqrt(2) = (1+zeta4)/zeta8 */
+	printf("# got sqrt(2)\n");
 	mpz_init_set_si(sqroots[1], b);
 	mpz_powm_ui(sqroots[1], sqroots[1], k>>1, N);
 	mpz_invert(sqroots[1], sqroots[1], N);
@@ -790,7 +798,7 @@
     else if(b == 3 || b == 7 || b == 11)
 	disc1 = -b;
     if(disc1 != 0){
-	/* set squareroot of -b */
+	printf("# got sqrt(-%d)\n", b);
 	mpz_init_set_si(sqroots[0], b);
 	mpz_powm_ui(sqroots[0], sqroots[0], k+1, N);
     }
@@ -801,6 +809,7 @@
 static
 int psb_plus_odd(mpz_t sqroots[], int b, int k, mpz_t N)
 {
+    printf("# got sqrt(%d)\n", b);
     mpz_init_set_si(sqroots[0], b);
     mpz_powm_ui(sqroots[0], sqroots[0], k+1, N);
     return b;
@@ -881,7 +890,8 @@
    To solve the B1 problem, only consider (b, n)'s s.t. disc(b, n) = discref.
  */
 int
-process_special_blend(mpz_t tf[], int *nf, mpz_t N, int b, int n, int discref,
+process_special_blend(mpz_t tf[], int *nf, int *tried, 
+		      mpz_t N, int b, int n, int discref,
 		      double B1, mpz_t B2, 
 		      ecm_params params, char *savefilename)
 {
@@ -920,6 +930,7 @@
 	return ret;
     if(disc1 == discref){
 	gmp_printf("# Let us use disc=%d with B1=%1.0f B2=%Zd\n",disc1,B1,B2);
+	*tried = 1;
 	ret = process_many_curves_loop(tf, nf, N, B1, B2, params,
 				       NULL, NULL, 0, 0, 1,
 				       disc1, sqroots,
@@ -988,7 +999,7 @@
 main(int argc, char *argv[])
 {
     mpz_t N, tf[NFMAX], B2;
-    int res = 0, smin = -1, smax = -1, ncurves = 0, method = ECM_ECM;
+    int res = 0, smin = -1, smax = -1, ncurves = 0, method = ECM_ECM, tried;
     int nf = 0, i, bb = 0;
     double B1 = 0.0, dB2 = 0.0;
     int disc = 0, b = 0, n = 0;
@@ -1171,13 +1182,14 @@
 	    exit (1);
 	}
 	res = ECM_NO_FACTOR_FOUND;
+	tried = 0;
 	if(method == ECM_ECM){
 	    if(b != 0){
 		nf = 0;
-		res = process_special_blend(tf,&nf,N,bb,n,disc,B1,B2,
+		res = process_special_blend(tf,&nf,&tried,N,bb,n,disc,B1,B2,
 					    params,savefilename);
 	    }
-	    if(res == ECM_NO_FACTOR_FOUND
+	    if(res == ECM_NO_FACTOR_FOUND && !tried
 	       && (curvesname != NULL || torsion != NULL || disc != 0)){
 		nf = 0;
 		res = process_many_curves_loop(tf, &nf, N, B1, B2, params,

Modified: trunk/stage2.c
===================================================================
--- trunk/stage2.c	2013-02-10 17:29:59 UTC (rev 2386)
+++ trunk/stage2.c	2013-02-11 10:17:37 UTC (rev 2387)
@@ -360,7 +360,8 @@
       use_ntt = 0; /* don't use NTT for Fermat numbers */
     }
 
-  if(mpz_cmp_ui(((curve *)X)->sq[0], 1) == 0){
+  /* we can use disc = -4 even if zeta4 is unknown */
+  if(disc != -4 && mpz_cmp_ui(((curve *)X)->sq[0], 1) == 0){
       disc = 0;
       ((curve *)X)->disc = 0; /* humf */
   }




More information about the Ecm-commits mailing list