arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 1811.09840cs.PL
收藏

三个欧拉筛和一个快速素数生成器(函数Pearl)

Three Euler's Sieves and a Fast Prime Generator (Functional Pearl)

Ivano Salvo, Agnese Pacifico

摘要:

欧拉筛法改进了埃拉托塞尼筛法来计算素数,通过划掉每个非素数一次。欧拉筛被认为是很难忠实和有效地编码为一个纯粹的功能流为基础的程序。我们提出了三个实现欧拉筛的Haskell程序,所有这些程序都是基于只生成一次要被划掉的复合材料的想法。他们对欧拉筛的忠诚取决于由流的连续性所强加的代价高昂的流联盟。我们的程序优于经典的天真流为基础的总理发电机,如审判司,但他们是渐近比奥尼尔'忠实'筛埃拉托塞尼。为了克服流并的瓶颈,我们将我们的技术集成到O'Neill程序中,从而得到一个基于欧拉筛和优先队列的快速素数生成器。

英文摘要:

The Euler's Sieve refines the Sieve of Eratosthenes to compute prime numbers, by crossing off each non prime number just once. Euler's Sieve is considered hard to be faithfully and efficiently coded as a purely functional stream based program. We propose three Haskell programs implementing the Euler's Sieve, all based on the idea of generating just once each composite to be crossed off. Their faithfulness with respect to the Euler's Sieve is up to costly stream unions imposed by the sequential nature of streams. Our programs outperform classical naive stream based prime generators such as trial division, but they are asymptotically worse than the O'Neill `faithful' Sieve of Eratosthenes. To circumvent the bottleneck of union of streams, we integrate our techniques inside the O'Neill program, thus obtaining a fast prime generator based on the Euler's Sieve and priority queues.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑