On Fri, Jul 16, 2010 at 2:35 PM, m.rebolledo <[email protected]> wrote: > thank you but the solution that you proposed seem to tell "abort if > the process is too long" and I would like to do something like "while > R_c is too long to factorized, do c:=c+1". > is it possible with @fork?
What is the definition of "too long to factorize"? > > sorry if it is obvious ... > > On 16 juil, 12:40, "Dr. David Kirkby" <[email protected]> wrote: >> On 07/16/10 11:32 AM, William Stein wrote: >> >> >> >> >> >> > On Thu, Jul 15, 2010 at 10:36 AM, troublion<[email protected]> >> > wrote: >> >> hello, >> >> >> within a procedure I need to factorize an integer R_c depending on a >> >> parameter c which I can change if I want. But this integer can be very >> >> big (like 170 digits or more...) so sage could not factorize it. I >> >> would like to say to sage something like "if you can, factorize it, >> >> else look at R_{c+1}". >> >> Is it possible? How? >> >> thank you very much in advance, >> >> > My new @fork decorator is perfect for this, which you get from >> >http://trac.sagemath.org/sage_trac/ticket/9501, or wait for sage-4.5.1 >> > (in 2-3 weeks). >> >> > Code: >> >> > @fork(timeout=1) >> > def fac1(n): >> > return factor(n) >> >> > Usage: >> >> > sage: fac1(2903482093840982) >> > 2 * 15907 * 26203 * 3482971 >> > sage: fac1(2^97+1) >> > 3 * 971 * 1553 * 31817 * 1100876018364883721 >> > sage: fac1(2^997+1) >> > Killing subprocess 94648 with input >> > ((1339385758982834151185531311325002263201756014631917009304687985462938813 >> > >> > 906170153116497973519619822659493341146941433531483931607115392554498072196 >> > >> > 837321850491820971853028873177634325632796392734744272769130809372947742658 >> > >> > 424845944895692993259632864321399559710817770957553728956578048354650708508 >> > 673,), >> > {}) which took too long >> > 'NO DATA (timed out)' >> >> Mathematica has two related to this >> >> http://reference.wolfram.com/mathematica/ref/TimeConstrained.htmlhttp://reference.wolfram.com/mathematica/ref/MemoryConstrained.html >> >> It might be useful if Sage could implement the latter too. >> >> Dave > > -- > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/sage-support > URL: http://www.sagemath.org > -- William Stein Professor of Mathematics University of Washington http://wstein.org -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
