<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/lib/prime.rb, branch v3_0_4</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>[ruby/prime] v0.1.2</title>
<updated>2020-12-09T05:45:56+00:00</updated>
<author>
<name>Marc-Andre Lafortune</name>
<email>github@marc-andre.ca</email>
</author>
<published>2020-12-09T05:45:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b603085d2f4b997541247f8eab864f92f9b5f006'/>
<id>b603085d2f4b997541247f8eab864f92f9b5f006</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/prime] Optimize `Integer#prime?`</title>
<updated>2020-12-09T05:40:09+00:00</updated>
<author>
<name>Marc-Andre Lafortune</name>
<email>github@marc-andre.ca</email>
</author>
<published>2020-12-05T05:20:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1866d483dce614a02c5186bd0588b48a5041e55e'/>
<id>1866d483dce614a02c5186bd0588b48a5041e55e</id>
<content type='text'>
Miller Rabin algorithm can be used to test primality for integers smaller than a max value "MaxMR" (~3e24)

It can be much faster than previous implementation: ~100x faster for numbers with 13 digits, at least 5 orders of magnitude for even larger numbers (previous implementation is so slow that it requires more patience than I have for more precise estimate).

Miller Rabin test becomes faster than previous implementation at somewhere in the range 1e5-1e6. It seems that the range 62000..66000 is where Miller Rabin starts being always faster, so I picked 0xffff arbitrarily; before that, or above "MaxMR", the previous implementation remains.

I compared the `faster_prime` gem too. It is slower than previous implementation up to ~1e4. After that it becomes faster and faster compared to previous implementation, but is still slower than Miller Rabin starting at ~1e5 and up to MaxMR. Thus, after this commit, builtin `Integer#prime?` will be similar or faster than `faster_prime` up to "MaxMR".

Adapted from patch of Stephen Blackstone [Feature #16468]

Benchmark results and code: https://gist.github.com/marcandre/b263bdae488e76dabdda84daf73733b9

Co-authored-by: Stephen Blackstone &lt;sblackstone@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Miller Rabin algorithm can be used to test primality for integers smaller than a max value "MaxMR" (~3e24)

It can be much faster than previous implementation: ~100x faster for numbers with 13 digits, at least 5 orders of magnitude for even larger numbers (previous implementation is so slow that it requires more patience than I have for more precise estimate).

Miller Rabin test becomes faster than previous implementation at somewhere in the range 1e5-1e6. It seems that the range 62000..66000 is where Miller Rabin starts being always faster, so I picked 0xffff arbitrarily; before that, or above "MaxMR", the previous implementation remains.

I compared the `faster_prime` gem too. It is slower than previous implementation up to ~1e4. After that it becomes faster and faster compared to previous implementation, but is still slower than Miller Rabin starting at ~1e5 and up to MaxMR. Thus, after this commit, builtin `Integer#prime?` will be similar or faster than `faster_prime` up to "MaxMR".

Adapted from patch of Stephen Blackstone [Feature #16468]

Benchmark results and code: https://gist.github.com/marcandre/b263bdae488e76dabdda84daf73733b9

Co-authored-by: Stephen Blackstone &lt;sblackstone@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Improve docs for Prime.{prime_division,int_from_prime_division} (#8)</title>
<updated>2020-03-06T11:55:22+00:00</updated>
<author>
<name>Marcus Stollsteimer</name>
<email>sto.mar@web.de</email>
</author>
<published>2019-12-27T19:19:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=baaf6815704ef36160e45244b844b633ed51c3b4'/>
<id>baaf6815704ef36160e45244b844b633ed51c3b4</id>
<content type='text'>
Move explanation for the decomposition array from the Example section
to the method description. Mention the term "multiplicity".

Use examples that also demonstrate factors with multiplicity
other than 1, and avoid factors/multiplicities with the same value.
Also add the decomposition written as simple mathematical expression.

This also fixes missing syntax highlighting for the code examples
due to verbatim blocks that did not only include Ruby code.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Move explanation for the decomposition array from the Example section
to the method description. Mention the term "multiplicity".

Use examples that also demonstrate factors with multiplicity
other than 1, and avoid factors/multiplicities with the same value.
Also add the decomposition written as simple mathematical expression.

This also fixes missing syntax highlighting for the code examples
due to verbatim blocks that did not only include Ruby code.
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/prime] Fix typo</title>
<updated>2020-03-06T11:54:45+00:00</updated>
<author>
<name>Marcus Stollsteimer</name>
<email>sto.mar@web.de</email>
</author>
<published>2019-12-27T18:47:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e92fbaf6090fbc60081654cb36da47fc352000ce'/>
<id>e92fbaf6090fbc60081654cb36da47fc352000ce</id>
<content type='text'>
https://github.com/ruby/prime/commit/549c1b86f1
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/prime/commit/549c1b86f1
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/prime] Improve docs for Prime.include? (#7)</title>
<updated>2020-03-06T11:54:38+00:00</updated>
<author>
<name>Marcus Stollsteimer</name>
<email>sto.mar@web.de</email>
</author>
<published>2019-12-25T19:01:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=f236f6082cf2d95c913c2d16c9a9a0ad554f627f'/>
<id>f236f6082cf2d95c913c2d16c9a9a0ad554f627f</id>
<content type='text'>
https://github.com/ruby/prime/commit/230a5af325
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/ruby/prime/commit/230a5af325
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/prime] Fix Prime.include?</title>
<updated>2020-03-06T11:54:33+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2019-08-11T20:14:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e79fc05a4ca672816c6b737d00a85fea4aa6c2b7'/>
<id>e79fc05a4ca672816c6b737d00a85fea4aa6c2b7</id>
<content type='text'>
Previously, it would be an infinite loop if passed a non-prime
integer.

Also, Prime.include? should also provide similar results to
Module#include? if passed a Module, so handle that.

For consistency with Enumerable#include?, return false if passed
other object types.

Fixes Ruby Bug 10167.

https://github.com/ruby/prime/commit/55dda6aa7f
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously, it would be an infinite loop if passed a non-prime
integer.

Also, Prime.include? should also provide similar results to
Module#include? if passed a Module, so handle that.

For consistency with Enumerable#include?, return false if passed
other object types.

Fixes Ruby Bug 10167.

https://github.com/ruby/prime/commit/55dda6aa7f
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/prime] Bump version</title>
<updated>2019-12-23T02:48:54+00:00</updated>
<author>
<name>Marc-Andre Lafortune</name>
<email>github@marc-andre.ca</email>
</author>
<published>2019-12-23T01:54:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=048f797bf019cdf303d70494fba63d4a4e606462'/>
<id>048f797bf019cdf303d70494fba63d4a4e606462</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>proc.c: proc without block</title>
<updated>2019-01-10T08:19:14+00:00</updated>
<author>
<name>nobu</name>
<email>nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2019-01-10T08:19:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=9f1fb0a17febc59356d58cef5e98db61a3c03550'/>
<id>9f1fb0a17febc59356d58cef5e98db61a3c03550</id>
<content type='text'>
* proc.c (proc_new): promoted lambda/proc/Proc.new with no block
  in a method called with a block to a warning/error.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* proc.c (proc_new): promoted lambda/proc/Proc.new with no block
  in a method called with a block to a warning/error.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>lib/prime.rb: remove unused methods</title>
<updated>2018-06-24T09:31:07+00:00</updated>
<author>
<name>mame</name>
<email>mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2018-06-24T09:31:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=103b5063f2568b1c16c1e5e2d234f783da7f73ff'/>
<id>103b5063f2568b1c16c1e5e2d234f783da7f73ff</id>
<content type='text'>
This change removes TrialDivision#cache, TrialDivision#primes, and
TrialDivision#primes_so_far.

TrialDivision class is undocumented officially, so this class is used
only internally.  Yugui san moved prime library from mathn to prime in
2008, and then she might forget to delete these methods.

A patch from @shio-phys.  https://github.com/ruby/prime/pull/4

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This change removes TrialDivision#cache, TrialDivision#primes, and
TrialDivision#primes_so_far.

TrialDivision class is undocumented officially, so this class is used
only internally.  Yugui san moved prime library from mathn to prime in
2008, and then she might forget to delete these methods.

A patch from @shio-phys.  https://github.com/ruby/prime/pull/4

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>Promote Prime library to default gems.</title>
<updated>2018-06-02T23:05:45+00:00</updated>
<author>
<name>hsbt</name>
<email>hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2018-06-02T23:05:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=8ce71b616056fd6875d139a94c5577167beea7a4'/>
<id>8ce71b616056fd6875d139a94c5577167beea7a4</id>
<content type='text'>
  * Its upstream is https://github.com/ruby/prime.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63560 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
  * Its upstream is https://github.com/ruby/prime.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63560 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
</feed>
