[Ecm-discuss] Need assist with an ECM-GMP program.

paul zimmermann Paul.Zimmermann at inria.fr
Ven 20 Mar 16:17:00 CET 2020


       Dear Georg-Johann,

> From: Georg-Johann Lay <avr at gjlay.de>
> Date: Fri, 20 Mar 2020 15:32:32 +0100
> 
> Am 20.03.20 um 14:19 schrieb paul zimmermann:
> >         Dear Georg-Johann,
> > 
> > it appears that ep->sigma, which is initially 0 (un-initialized) is set
> > by ecm_factor, and then if the first call fails, since now ep->sigma is
> > non-zero, it is taken as the sigma value, and it fails again and again.
> > 
> > With mpz_set_ui (ep->sigma, 0) after the ecm_factor() call it works better,
> > but there still seems to be a problem.
> > 
> > Paul
> 
> Tried that, but it did not help.
> 
> What helps though is to use a fresh ecm_params for each ecm_factor call.
>
> It this supposed to be the case?  I did not find a documentation of
> ecm_init() / ecm_clear() and used them similar to respective mpz_*
> functions, i.e. init once at start of program and clear at the end.

yes and no. Some of the ecm_param fields are used internally, without being
restored to their original state. All this would need a major redesign,
but in the short term you can either use a fresh ecm_params() at each call,
or use the brand new ecm_reset() functions I've added to the svn version.
With ecm_reset (ep) added to res = ecm_factor (...) in your code, it works.

>> Appeared to be reasonable as they are using malloc / free...
> 
> One more question:
> 
> I am getting return values > 0 from ecm_factor() where is sets the 1st
> operand to 1.  Of course 1 is technically a factor of the input, but
> I expected return value > 0 to mean "nontrivial factor", no?
> 
> There is
> 
> #define ECM_FACTOR_FOUND_P(x) ((x) > 0)
> 
> in ecm.h so "FACTOR" includes the trivial ones?

this is deliberate, when n = 1 we consider n is fully factored:

  else if (mpz_cmp_ui (n, 1) == 0)
    {
      mpz_set_ui (f, 1);
      return ECM_FACTOR_FOUND_STEP1;
    }

Best regards,
Paul


Plus d'informations sur la liste de diffusion Ecm-discuss