From: Kiswono Prayogo Date: 2013-07-30T13:25:56+09:00 Subject: Re: Faster primality testing and factorization methods in Ruby --e89a8ff1ca526c49ce04e2b2e81d Content-Type: text/plain; charset=UTF-8 hmm.. when i tried your code from your github link, this shows up: $ ruby /tmp/primeszp.rb /tmp/primeszp.rb:44: warning: assigned but unused variable - rescnt /tmp/primeszp.rb:85: warning: assigned but unused variable - rescnt /tmp/primeszp.rb:119: warning: assigned but unused variable - rescnt /tmp/primeszp.rb:159: warning: assigned but unused variable - rescnt /tmp/primeszp.rb:165: warning: assigned but unused variable - modk /tmp/primeszp.rb:212: warning: shadowing outer local variable - p Rehearsal ------------------------------------------------------------------------- prime tests for P = 20000000000000003 0.000000 0.000000 0.000000 ( 0.000011) Miller-Rabin 0.000000 0.000000 0.000000 ( 0.009361) primzp7? ^C $ jruby /tmp/primeszp.rb Rehearsal ------------------------------------------------------------------------- prime tests for P = 20000000000000003 0.020000 0.000000 0.020000 ( 0.002000) Miller-Rabin 0.490000 0.030000 0.520000 ( 0.744000) primzp7? ^C ---> hangs or too slow on both ruby 2.0 and jruby 1.7.4, so i ctrl+C it after 10 seconds... i'm using archlinux, amd c-60 On Thu, Jun 27, 2013 at 10:48 AM, Jabari Z. wrote: > I have created various implementations of methods to replace prime? and > prime_division (from the standard lib file prime.rb) based on a class of > mathematical operators I've developed called prime generators (PG).Using > a special form of these PG I term Strictly Prime (SP) prime generators I > have created extremely simple and fast algorithms that can find all the > primes up to some number n, determine the primality of n, or > factorization. > > Below are links to the paper which provides the mathematical basis for > the proposed methods with two tables of benchmark results comparing the > performance of the library methods prime? and prime_division with my > proposed methods. I provide test results on 32-bit and 64-bit Linux > systems using 5 reference primes of 17 to 19 digits. > > My paper, 'Improved Primality Testing and Factorization in Ruby' > > http://www.scribd.com/doc/150217723/Improved-Primality-Testing-and-Factorization-in-Ruby > > The code rile 'primeszp.rb' is available in my github repository: > https://gist.github.com/jzakiya/455f2357cdb08f4ee1c4 > > Attachments: > > http://www.ruby-forum.com/attachment/8542/Improved_Primality_Testing_and_Factorization_in_Ruby.pdf > http://www.ruby-forum.com/attachment/8543/primeszp.rb > > > --e89a8ff1ca526c49ce04e2b2e81d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable hmm.. when i tried your code from your github link, this shows up:

=
$ ruby /tmp/primeszp.rb
/tmp/primeszp.rb:44: warning: a= ssigned but unused variable - rescnt
/tmp/primeszp.rb:85: warning= : assigned but unused variable - rescnt
/tmp/primeszp.rb:119: warning: assigned but unused variable - rescnt
/tmp/primeszp.rb:159: warning: assigned but unused variable - resc= nt
/tmp/primeszp.rb:165: warning: assigned but unused variable - = modk
/tmp/primeszp.rb:212: warning: shadowing outer local variable - p
Rehearsal -----------------------------------------------------------= --------------
prime tests for P =3D 20000000000000003 =C2=A0 0.0= 00000 =C2=A0 0.000000 =C2=A0 0.000000 ( =C2=A00.000011)
Miller-Rabin =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A00.000000 =C2=A0 0.000000 =C2=A0 0.= 000000 ( =C2=A00.009361)
primzp7? =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^C
=

$ jruby /tmp/primeszp.rb=C2=A0
Rehearsal= -------------------------------------------------------------------------<= /div>
prime tests for P =3D 20000000000000003 =C2=A0 0.020000 =C2=A0 0.00000= 0 =C2=A0 0.020000 ( =C2=A00.002000)
Miller-Rabin =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A00.490000 =C2=A0 0.030000 =C2=A0 0.520000 ( =C2=A00.744000)
<= div>primzp7? =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^C

---> hangs or too slow on both ruby 2.0 and jruby 1= .7.4, so i ctrl+C it after 10 seconds...

i'm u= sing archlinux, amd c-60

On Thu, J= un 27, 2013 at 10:48 AM, Jabari Z. <lists@ruby-forum.com>= wrote:
I have created various implementations of me= thods to replace prime? and
prime_division (from the standard lib file prime.rb) based on a class of mathematical operators I've developed called prime generators (PG).Usin= g
a special form of these PG I term Strictly Prime (SP) prime generators I have created extremely simple and fast algorithms that can find all the
primes up to some number n, determine the primality of n, or
factorization.

Below are links to the paper which provides the mathematical basis for
the proposed methods with two tables of benchmark results comparing the
performance of the library methods prime? and prime_division with my
proposed methods. I provide test results on 32-bit and 64-bit Linux
systems using 5 reference primes of 17 to 19 digits.

My paper, 'Improved Primality Testing and Factorization in Ruby' http://www.scribd.com/doc/15021= 7723/Improved-Primality-Testing-and-Factorization-in-Ruby

The code rile 'primeszp.rb' is available in my github repository: https://gist.github.com/jzakiya/455f2357cdb08f4ee1c4

Attachments:
http://www.ruby-forum= .com/attachment/8542/Improved_Primality_Testing_and_Factorization_in_Ruby.p= df
http://www.ruby-forum.com/attachment/8543/primeszp.rb


--e89a8ff1ca526c49ce04e2b2e81d--