【问题标题】:How to implement time in Pari/GP如何在 Pari/GP 中实现时间
【发布时间】:2018-10-25 09:11:50
【问题描述】:

我有 Pari/GP 32 位,并希望实现任何类型的代码,该代码在有限的时间内运行,如果到那时没有产生任何内容,则自动停止。这是一个伪代码示例:

command
...
run command
if run time over 3 minutes
automatically interrupt the program and stop running

我知道有一种基本方法可以做到这一点,但我从未在 PARI/GP 指南中找到它。有什么帮助吗?谢谢。

【问题讨论】:

    标签: time pari pari-gp


    【解决方案1】:
     alarm(5);for(i=1,10^10,continue)
    

    【讨论】:

    • 您还可以将alarm 函数中的代码作为第二个参数移动。例如,alarm(5, factor(2^1234+1)) 将返回 2^1234+1 的完整分解,如果它可以在 5 秒内产生,否则将返回(不引发)错误对象。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-10
    • 2018-10-16
    • 2018-02-25
    • 2023-04-09
    • 2015-01-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多