[Ecm-commits] r2370 - trunk

cvs commits ecm-commits at lists.gforge.inria.fr
Sat Feb 2 17:46:39 CET 2013


Author: morain
Date: 2013-02-02 17:46:39 +0100 (Sat, 02 Feb 2013)
New Revision: 2370

Log:
A first attempt at a faster version for D=-4. To be continued.


Modified:
   trunk/cmecm.c
   trunk/cmecm.h
   trunk/stage2.c
Modified: trunk/cmecm.c
===================================================================
--- trunk/cmecm.c	2013-02-01 17:06:54 UTC (rev 2369)
+++ trunk/cmecm.c	2013-02-02 16:46:39 UTC (rev 2370)
@@ -462,10 +462,12 @@
     unsigned long umax, vmax, dF = 0, k = 0;
 
     if(disc == -4){
-	/* u^2 + v^2 <= B2, u odd, v even */
+	/* tmp <- floor(sqrt(B2-1)) */
 	mpz_init_set(tmp, B2);
 	mpz_sub_si(tmp, tmp, 1);
 	mpz_sqrt(tmp, tmp);
+#if CMECM_D_4 == 0 /* standard version */
+	/* u^2 + v^2 <= B2, u odd, v even */
 	vmax = mpz_get_ui(tmp);
 	/* largest v must be even */
 	if(vmax % 2 == 1)
@@ -482,6 +484,13 @@
 	if(umax % 2 == 0)
 	    umax--;
 	for(k = 1; k*dF < umax; k++);
+#else /* faster */
+	/* u^2 + v^2 <= B2, u > v > 0 */
+	umax = mpz_get_ui(tmp);
+	/* find smallest power of 2 >= umax */
+	for(dF = 1; dF < umax; dF <<= 1);
+	k = 1;
+#endif
 	mpz_clear(tmp);
     }
     *pdF = dF;
@@ -569,7 +578,14 @@
     ec_point_init(omegaP, E, modulus);
     if(C->disc == -4){
 	apply_CM(omegaP, C->disc, C->sq, P, modulus);
+#if CMECM_D_4 == 0
 	ret = all_multiples(f, F, dF, E, omegaP, modulus, 2, 2);
+#else /* TODO: replace omegaP with P... 
+	 in the pedestrian version, one evaluates [v][zeta4]P in F
+	 and [u]P in G, whereas we can share everything...!
+       */
+	ret = all_multiples(f, F, dF, E, omegaP, modulus, 1, 1);
+#endif
     }
     ec_point_clear(omegaP, E, modulus);
     ec_point_clear(P, E, modulus);
@@ -615,8 +631,14 @@
     }
     
     if(X->disc == -4){
+#if CMECM_D_4 == 0
 	umin = 1;
 	du = 2;
+#else
+	printf("# Case D=-4 suboptimal, man!\n");
+	umin = 1;
+	du = 1;
+#endif
     }
     
     /* conversions */

Modified: trunk/cmecm.h
===================================================================
--- trunk/cmecm.h	2013-02-01 17:06:54 UTC (rev 2369)
+++ trunk/cmecm.h	2013-02-02 16:46:39 UTC (rev 2370)
@@ -1,3 +1,5 @@
+#define CMECM_D_4 1 /* fast version */
+
 int build_curves_with_CM(mpz_t f, int *nE, ec_curve_t *tE, ec_point_t *tP, int disc, mpmod_t n, mpz_t *sqroots);
 void
 set_stage2_params_CM(unsigned long *pdF, unsigned long *pk, mpz_t B2, int disc);

Modified: trunk/stage2.c
===================================================================
--- trunk/stage2.c	2013-02-01 17:06:54 UTC (rev 2369)
+++ trunk/stage2.c	2013-02-02 16:46:39 UTC (rev 2370)
@@ -644,7 +644,7 @@
 			      modulus);
       else
 	  youpi = ecm_rootsG_CM (f, G, dF, (ecm_roots_state_t *) rootsG_state, 
-			      modulus);
+				 modulus);
 
       if (test_verbose (OUTPUT_TRACE))
 	{




More information about the Ecm-commits mailing list