[Ecm-commits] r2388 - trunk

cvs commits ecm-commits at lists.gforge.inria.fr
Mon Feb 11 14:31:30 CET 2013


Author: morain
Date: 2013-02-11 14:31:29 +0100 (Mon, 11 Feb 2013)
New Revision: 2388

Log:
Preparing the use of more squareroots modulo N.


Modified:
   trunk/manyecm.c
Modified: trunk/manyecm.c
===================================================================
--- trunk/manyecm.c	2013-02-11 10:17:37 UTC (rev 2387)
+++ trunk/manyecm.c	2013-02-11 13:31:29 UTC (rev 2388)
@@ -806,8 +806,8 @@
 }
 
 /* b^(2*k+1) = 1 mod N => (b^(k+1))^2 = b mod N */
-static
-int psb_plus_odd(mpz_t sqroots[], int b, int k, mpz_t N)
+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);
@@ -816,8 +816,9 @@
 }
 
 /* OUTPUT: ECM_NO_FACTOR_FOUND or ECM_FACTOR_FOUND_STEP1 in very rare cases! */
-static
-int prepare_squareroots(int *disc1, mpz_t f, mpz_t sqroots[], int b, int n, int sgn, mpz_t N)
+static int
+prepare_squareroots_from_powers(int *disc1, mpz_t f, mpz_t sqroots[], int b,
+				int n, int sgn, mpz_t N)
 {
     int k, discr = 0, ret = ECM_NO_FACTOR_FOUND;
     mpz_t tmp, tmp2;
@@ -884,6 +885,30 @@
     return ret;
 }
 
+static int
+prepare_squareroots(int *disc1, mpz_t f, mpz_t sqroots[], int b,
+		    int n, int sgn, mpz_t N)
+{
+    int ret = prepare_squareroots_from_powers(disc1, f, sqroots, b, n, sgn, N);
+    int tabq[] = {3, 5, 7, 11, 13, 19, 0}, q, iq, qs;
+
+    if(ret != ECM_NO_FACTOR_FOUND)
+	return ret;
+#if 0
+    if(*disc1 != 0)
+	/* for the time being, stop if some discriminant was found */
+	return ret;
+#endif
+    /* let's find some squareroots using small powers of n */
+    for(iq = 0; tabq[iq] != 0; iq++){
+	q = tabq[iq];
+	qs = (q % 4 == 1 ? q : -q);
+	if(n % q == 0)
+	    printf("# I can find sqrt(%d)\n", qs);
+    }
+    return ret;
+}
+
 /* Consider M = b^n+1 if n > 0, M = b^(-n)-1 otherwise.
    N is supposed to be a *primitive* cofactor of M.
    Then find a special cocktail of CM curves a` la Atkin.




More information about the Ecm-commits mailing list