Re: Ultimate Prime Sieve -- Sieve of Zakiya (SoZ)
  Home FAQ Contact Sign in
comp.lang.forth only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.forth Profile…
 Up
Re: Ultimate Prime Sieve -- Sieve of Zakiya (SoZ)         


Author: Michael
Date: Jun 8, 2008 15:41

On 8 Jun., 08:08, m...@iae.nl (Marcel Hendrix) wrote:
..
> Example:  (3 GHz PIV)
>
>> timer-reset S" 18446744073709551617" cr .FACTOR cr .elapsed
> 274177 * 67280421310721
> 0.028 seconds elapsed. ok

May be I missed your TIMER-RESET and .ELAPSED words earlyer - looks
great.

Is there a gforth version around?
Michael
18 Comments
Re: Ultimate Prime Sieve -- Sieve of Zakiya (SoZ)         


Author: jzakiya
Date: Jun 16, 2008 18:24

On Jun 8, 6:41 pm, Michael wrote:
> On 8 Jun., 08:08, m...@iae.nl (Marcel Hendrix) wrote:
> ..
>
>> Example: (3 GHz PIV)
>
>>> timer-reset S" 18446744073709551617" cr .FACTOR cr .elapsed
>> 274177 * 67280421310721
>> 0.028 seconds elapsed. ok
>
> May be I missed your TIMER-RESET and .ELAPSED words earlyer - looks
> great.
>
> Is there a gforth version around?
> Michael
Show full article (6.29Kb)
no comments
Re: Ultimate Prime Sieve -- Sieve of Zakiya (SoZ)         


Author: jzakiya
Date: Aug 1, 2008 12:10

On Jun 16, 9:24 pm, jzakiya mail.com> wrote:
> On Jun 8, 6:41 pm, Michael wrote:
>
>> On 8 Jun., 08:08, m...@iae.nl (Marcel Hendrix) wrote:
>> ..
>
>>> Example:  (3 GHz PIV)
>
>>>> timer-reset S" 18446744073709551617" cr .FACTOR cr .elapsed
>>> 274177 * 67280421310721
>>> 0.028 seconds elapsed. ok
>
>> May be I missed your TIMER-RESET and .ELAPSED words earlyer - looks
>> great.
>
>> Is there a gforth version around?
>> Michael
>
> Below is Forth code to perform theSieveof Zakiya (SoZ).
> This code is a direct translation of a few of the sieves ...
Show full article (7.02Kb)
16 Comments
Re: Ultimate Prime Sieve -- Sieve of Zakiya (SoZ)         


Author: Marcel Hendrix
Date: Aug 2, 2008 08:27

jzakiya mail.com> writes Re: Ultimate Prime Sieve -- Sieve of Zakiya (SoZ)
> On Jun 16, 9:24=A0pm, jzakiya mail.com> wrote:
>> On Jun 8, 6:41 pm, Michael wrote:
> I've uploaded more efficient/faster code:

I had some problems understanding what (or better *why*) your code
tried to do things.

The way a prime sieve gets used, e.g. in the Euler Project, I normally
allocate a 1 megabyte array, initialize it with boolean flags (true:
the value corresponding with this index is a prime, where the integer
to index code is "3 - 1 rshift"), and then use this boolean
array for the rest of the program. The setting up time of the Sieve is
truly insignificant compared to the run-time of the actual code that
uses the Sieve to determine if a given integer is prime.

(Of course, I uses Albert's van der Horst benchpin code to do the real
searching, the sieve array is only to weed out the common candidates.
If benchpin is not used, the Sieve might need to be hundredths of
megabytes in size for Euler Project programs.)
Show full article (3.19Kb)
no comments
Re: Ultimate Prime Sieve -- Sieve of Zakiya (SoZ)         


Author: Albert van der Horst
Date: Aug 3, 2008 04:51

In article <86283821153559@frunobulax.edu>, Marcel Hendrix wrote:
>jzakiya mail.com> writes Re: Ultimate Prime Sieve -- Sieve of Zakiya (SoZ)


>
>(Of course, I uses Albert's van der Horst benchpin code to do the real
>searching, the sieve array is only to weed out the common candidates.
>If benchpin is not used, the Sieve might need to be hundredths of
>megabytes in size for Euler Project programs.)

A remark: the benchpin program doesn't use a sieve at all!
It is an example of a recursive program that calculates something
useful, and at the same time of prime counting without using
a sieve, or for that matter any storage outside of the stacks.

I would paraphraze this as: "I use the techniques of Mentzel,
that I learned from the benchpin code."

The world record for prime counting is above 10^22. This is totally
out of reach for simple sieving.
Show full article (3.93Kb)
no comments
Re: Ultimate Prime Sieve -- Sieve of Zakiya (SoZ)         


Author: jzakiya
Date: Aug 4, 2008 11:14

Marcel

I hope this answers your questions.
>I had some problems understanding what (or better *why*) your code
>tried to do things.
>The way a prime sieve gets used, e.g. in the Euler Project, I normally
>allocate a 1 megabyte array, initialize it with boolean flags (true:
>the value corresponding with this index is a prime, where the integer
>to index code is "3 - 1 rshift"), and then use this boolean
>array for the rest of the program. The setting up time of the Sieve is
>truly insignificant compared to the run-time of the actual code that
>uses the Sieve to determine if a given integer is prime.
>(Of course, I uses Albert's van der Horst benchpin code to do the real
>searching, the sieve array is only to weed out the common candidates.
>If benchpin is not used, the Sieve might need to be hundredths of
>megabytes in size for Euler Project programs.)
Show full article (6.12Kb)
no comments
Re: Ultimate Prime Sieve -- Sieve of Zakiya (SoZ)         


Author: jzakiya
Date: Aug 4, 2008 21:51

On Aug 4, 2:14 pm, jzakiya mail.com> wrote:
> Marcel
>
> I hope this answers your questions.
>
>>I had some problems understanding what (or better *why*) your code
>>tried to do things.
>>The way a prime sieve gets used, e.g. in the Euler Project, I normally
>>allocate a 1 megabyte array, initialize it with boolean flags (true:
>>the value corresponding with this index is a prime, where the integer
>>to index code is "3 - 1 rshift"), and then use this boolean
>>array for the rest of the program. The setting up time of the Sieve is
>>truly insignificant compared to the run-time of the actual code that
>>uses the Sieve to determine if a given integer is prime.
>>(Of course, I uses Albert's van der Horst benchpin code to do the real
>>searching, the sieve array is only to weed out the common candidates.
>>If benchpin is not used, the Sieve might need to be hundredths of
>>megabytes in size for Euler Project programs.)
>
> The Forth versions also set up a boolean SIEVE array set to FALSE. ...
Show full article (6.83Kb)
no comments
Re: Ultimate Prime Sieve -- Sieve of Zakiya (SoZ)         


Author: Albert van der Horst
Date: Aug 5, 2008 10:42

In article a1g2000hsb.googlegroups.com>,
jzakiya mail.com> wrote:


>
>Jabari
>
>PS: Albert, I've run your benchpin.f code, as is, on 6 different
>forths. For straight Linux, it runs on gforth, pfe, and kforth, and
>using wine on Linux, it runs on Swiftforth, MPE, and Win32Forth.

As it is intended as an ISO benchmark, it would be truely embarassing
to find an ISO Forth it, that doesn't run it :-).

If you want to use gforth with even larger memory, use the -m option.
"gforth --help" gives a lot of information about options.

lina has a similar option, -g (grow). The lina64 can have
sieves in the gigabytes, as does 64-bit gforth.

Groetjes Albert
Show full article (0.91Kb)
no comments
Re: Ultimate Prime Sieve -- Sieve of Zakiya (SoZ)         


Author: jzakiya
Date: Aug 5, 2008 15:35

On Aug 5, 1:42 pm, Albert van der Horst
wrote:
> In article a1g2000hsb.googlegroups.com>,
>
> jzakiya  mail.com> wrote:
>
>
>
>
>
>>Jabari
>
>>PS: Albert, I've run your benchpin.f code, as is, on 6 different
>>forths. For straight Linux, it runs on gforth, pfe, and kforth, and
>>using wine on Linux, it runs on Swiftforth, MPE, and Win32Forth.
>
> As it is intended as an ISO benchmark, it would be truely embarassing
> to find an ISO Forth it, that doesn't run it :-).
>
> If you want to use gforth with even larger memory, use the -m option. ...
Show full article (2.71Kb)
10 Comments
Re: Ultimate Prime Sieve -- Sieve of Zakiya (SoZ)         


Author: Marcel Hendrix
Date: Aug 6, 2008 11:01

jzakiya gmail.com> writes Re: Ultimate Prime Sieve -- Sieve of Zakiya (SoZ)
[..]
> Here are results on my P4 2.8 GHz, 1GB laptop.
>
> num 500,000,007 700,000,007 900,000,007 1,000,000,007
> -----------------------------------------------------------------
> Pi(N) 26,355,868 36,252,932 46,009,215 50,847,535
> -----------------------------------------------------------------
> P3 48 68 91 98
> -----------------------------------------------------------------
> P5 38 55 71 80
> -----------------------------------------------------------------
> P7 34 47 61 69
> -----------------------------------------------------------------
> pi ...
Show full article (2.01Kb)
no comments

RELATED THREADS
SubjectArticles qty Group
Ultimate Prime Sieve -- Sieve Of Zakiya (SoZ)comp.lang.python ·
Re: ports/107352: [NEW PORT] mail/dovecot-sieve: A sieve plugin formailing.freebsd.ports-bugs ·
1 2