Bill Allombert on Fri, 30 Jun 2023 09:12:27 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: How to interrupt a MT calculation?


On Fri, Jun 30, 2023 at 02:19:22AM +0200, Jean-Luc ARNAUD wrote:
> Hi all,
> 
> In such a script:
> 
> |time()=[getabstime(),getwalltime()];||
> ||export(time);||
> ||
> ||Factor2_MT(n)=||
> ||
> ||{my(t);||||
> ||
> ||  print(pareval([
>     ()->t=time(); factorint(n, 1); time()-t,||
> ||    ()->t=time(); factorint(n, 3); time()-t,||
> ||    ()->t=time(); if (n>2^468-1, factorint(n, 7), factorint(n, 6));
> time()-t,||
> ||    ()->t=time(); factorint(n, 9); time()-t,||
> ||    ()->t=time(); factorint(n, 11); time()-t,||
> ||    ()->t=time(); print(factor(n)); time()-t
>     ]))||
> ||};|
> 
> How is it possible to programmatically stop the calculations, let say as
> soon as a result is returned?

This is not really advised, but you can do as follow
Use
default(factor_add_primes,1)

and then replace
factorint(n,...) by error(factorint(n, ...));
and then do

iferr(pareval([ .... ]),E,return(Vec(E)))

Cheers,
Bill