bridge/class-master/depend/pari/src/basemath/ifactor1.c
/* Parallel doubling on nbc curves, assigning the result to locations at
 * and following *X2.  Safe to be called with X2 equal to X1.  Return
 * value as for ecm_elladd.  If we find a point at infinity mod N,
 * and if X1 != X2, we copy the points at X1 to X2. */
Parallel doubling on nbc curves, assigning the result to locations at
and following *X2.  Safe to be called with X2 equal to X1.  Return
value as for ecm_elladd.  If we find a point at infinity mod N,
and if X1 != X2, we copy the points at X1 to X2.
Parallel doubling on nbc curves assigning the result to locations at and following * X2 . Safe to be called with X2 equal to X1 . Return value as for ecm_elladd . If we find a point at infinity mod N and if X1 ! = X2 we copy the points at X1 to X2 .
static int
elldouble(GEN N, GEN *gl, long nbc, GEN *X1, GEN *X2)
{
  GEN *Y1 = X1+nbc, *Y2 = X2+nbc;
  GEN W[nbcmax+1]; 
  long i;
  pari_sp av = avma;
   W[1] = Y1[0];
  for (i=1; i<nbc; i++) W[i+1] = modii(mulii(Y1[i], W[i]), N);
  if (!invmod(W[nbc], N, gl))
  {
    if (!equalii(N,*gl)) return 2;
    ZV_aff(2*nbc,X1,X2); 
    avma = av; return 1;
  }
  while (i--) 
  {
    pari_sp av2;
    GEN v, w, L, z = i? mulii(*gl,W[i]): *gl;
    if (i) *gl = modii(mulii(*gl, Y1[i]), N);
    av2 = avma;
    L = modii(mulii(addui(1, mului(3, Fp_sqr(X1[i],N))), z), N);
    if (signe(L)) 
      L = shifti(mod2(L)? addii(L, N): L, -1);
    v = modii(subii(sqri(L), shifti(X1[i],1)), N);
    w = modii(subii(mulii(L, subii(X1[i], v)), Y1[i]), N);
    affii(v, X2[i]);
    affii(w, Y2[i]);
    avma = av2;
  }
  avma = av; return 0;
}
static int elldouble ( GEN N , GEN * gl , long nbc , GEN * X1 , GEN * X2 ) { GEN * Y1 = X1 + nbc , * Y2 = X2 + nbc ; GEN W [ nbcmax + 1 ] ; long i ; pari_sp av = avma ; W [ 1 ] = Y1 [ 0 ] ; for ( i = 1 ; i < nbc ; i ++ ) W [ i + 1 ] = modii ( mulii ( Y1 [ i ] , W [ i ] ) , N ) ; if ( ! invmod ( W [ nbc ] , N , gl ) ) { if ( ! equalii ( N , * gl ) ) return 2 ; ZV_aff ( 2 * nbc , X1 , X2 ) ; avma = av ; return 1 ; } while ( i -- ) { pari_sp av2 ; GEN v , w , L , z = i ? mulii ( * gl , W [ i ] ) : * gl ; if ( i ) * gl = modii ( mulii ( * gl , Y1 [ i ] ) , N ) ; av2 = avma ; L = modii ( mulii ( addui ( 1 , mului ( 3 , Fp_sqr ( X1 [ i ] , N ) ) ) , z ) , N ) ; if ( signe ( L ) ) L = shifti ( mod2 ( L ) ? addii ( L , N ) : L , -1 ) ; v = modii ( subii ( sqri ( L ) , shifti ( X1 [ i ] , 1 ) ) , N ) ; w = modii ( subii ( mulii ( L , subii ( X1 [ i ] , v ) ) , Y1 [ i ] ) , N ) ; affii ( v , X2 [ i ] ) ; affii ( w , Y2 [ i ] ) ; avma = av2 ; } avma = av ; return 0 ; }
Parallel doubling on nbc curves, assigning the result to locations at
 and following *X2.
Parallel doubling on nbc curves assigning the result to locations at and following * X2 .
/* W[0] unused */ /*W[0] = gen_1;*/ /* also copies Y1->Y2 */ /* nbc times */ /* half of zero is still zero */