Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JulStrat committed Jan 19, 2021
1 parent f3f5826 commit 43fdab2
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 62 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ uses primesieve;
type
PInt32 = ^Int32;
var
var
start, stop, n: UInt64;
i, size: NativeUInt;
primes: PInt32;
Expand All @@ -55,7 +55,7 @@ begin
start := 0;
stop := 1000;
(* store the primes below 1000 *)
(* store the primes below 1000 *)
primes := primesieve_generate_primes(start, stop, size, INT32_PRIMES);
for i := 0 to size-1 do
Expand All @@ -64,8 +64,8 @@ begin
primesieve_free(primes);
n := 1000;
(* store the first 1000 primes *)
primes := primesieve_generate_n_primes(n, start, INT_PRIMES);
(* store the first 1000 primes *)
primes := primesieve_generate_n_primes(n, start, INT32_PRIMES);
for i := 0 to n-1 do
WriteLn(primes[i]);
Expand All @@ -78,7 +78,7 @@ end.

Free Pascal compiler -
```
fpc -B -O3 -CX -XX examples/store_primes_in_array.pas
fpc -B -O2 -CX -XX examples/store_primes_in_array.pas
```

Embarcadero Delphi compiler -
Expand Down
Binary file modified docs/primesieve-pas.pdf
Binary file not shown.
18 changes: 0 additions & 18 deletions docs/primesieve-pas.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1131,12 +1131,6 @@ \subsection*{{\_}PRIMESIEVE{\_}VERSION}
\end{flushleft}
\fi

\par
\item[\textbf{Description}]
Warning: this symbol is deprecated.



\end{list}
\ifpdf
\subsection*{\large{\textbf{{\_}PRIMESIEVE{\_}VERSION{\_}MAJOR}}\normalsize\hspace{1ex}\hrulefill}
Expand Down Expand Up @@ -1166,12 +1160,6 @@ \subsection*{{\_}PRIMESIEVE{\_}VERSION{\_}MAJOR}
\end{flushleft}
\fi

\par
\item[\textbf{Description}]
Warning: this symbol is deprecated.



\end{list}
\ifpdf
\subsection*{\large{\textbf{{\_}PRIMESIEVE{\_}VERSION{\_}MINOR}}\normalsize\hspace{1ex}\hrulefill}
Expand Down Expand Up @@ -1201,12 +1189,6 @@ \subsection*{{\_}PRIMESIEVE{\_}VERSION{\_}MINOR}
\end{flushleft}
\fi

\par
\item[\textbf{Description}]
Warning: this symbol is deprecated.



\end{list}
\ifpdf
\subsection*{\large{\textbf{{\_}PRIMESIEVE{\_}PAS{\_}VERSION}}\normalsize\hspace{1ex}\hrulefill}
Expand Down
6 changes: 3 additions & 3 deletions docs/primesieve.html
Original file line number Diff line number Diff line change
Expand Up @@ -483,21 +483,21 @@ <h3 class="detail">Constants</h3>
<td class="itemcode"><span id="_PRIMESIEVE_VERSION"></span><code><b>_PRIMESIEVE_VERSION</b> = '7.6';</code></td>
</tr>
<tr><td colspan="1">
<p class="hint_directive">Warning: this symbol is deprecated.</p>&nbsp;</td></tr>
&nbsp;</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><span id="_PRIMESIEVE_VERSION_MAJOR"></span><code><b>_PRIMESIEVE_VERSION_MAJOR</b> = 7;</code></td>
</tr>
<tr><td colspan="1">
<p class="hint_directive">Warning: this symbol is deprecated.</p>&nbsp;</td></tr>
&nbsp;</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="itemcode"><span id="_PRIMESIEVE_VERSION_MINOR"></span><code><b>_PRIMESIEVE_VERSION_MINOR</b> = 6;</code></td>
</tr>
<tr><td colspan="1">
<p class="hint_directive">Warning: this symbol is deprecated.</p>&nbsp;</td></tr>
&nbsp;</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
Expand Down
3 changes: 1 addition & 2 deletions examples/count_primes.pas
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(* @example count_primes.pas
* Pascal program that shows how to count primes. *)
(* Pascal program that shows how to count primes. *)

program count_primes;
{$IF Defined(FPC)}
Expand Down
4 changes: 2 additions & 2 deletions examples/nth_prime.pas
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* @example nth_prime.pas
* Pascal program that finds the nth prime. *)
(* Pascal program that finds the nth prime. *)

program nth_prime;
{$IF Defined(FPC)}
{$MODE Delphi}
Expand Down
20 changes: 9 additions & 11 deletions examples/prev_prime.pas
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
(**
* @example prev_prime.pas
* Iterate backwards over primes using primesieve_iterator.
*
* Note that primesieve_next_prime() runs up to 2x faster and uses
* only half as much memory as primesieve_prev_prime(). Hence if
* it is possible to write the same algorithm using either
* primesieve_prev_prime() or primesieve_next_prime() then it is
* preferable to use primesieve_next_prime().
*)
(*
Iterate backwards over primes using primesieve_iterator.
Note that primesieve_next_prime() runs up to 2x faster and uses
only half as much memory as primesieve_prev_prime(). Hence if
it is possible to write the same algorithm using either
primesieve_prev_prime() or primesieve_next_prime() then it is
preferable to use primesieve_next_prime().
*)

program prev_prime;
{$IF Defined(FPC)}
Expand All @@ -30,7 +29,6 @@
primesieve_skipto(it, 2000, 1000);
(* iterate over primes from 2000 to 1000 *)
prime := primesieve_prev_prime(it);

while prime >= 1000 do
begin
WriteLn(prime);
Expand Down
10 changes: 4 additions & 6 deletions examples/primesieve_iterator.pas
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(* @example primesieve_iterator.pas
* Iterate over primes using primesieve_iterator. *)
(* Iterate over primes using primesieve_iterator. *)

program prime_iterator;
{$IF Defined(FPC)}
Expand All @@ -13,15 +12,14 @@

var
it: primesieve_iterator;
sum: UInt64;
prime: UInt64;
prime, sum: UInt64;

begin
sum := 0;
prime := 0;

primesieve_init(it);
(* iterate over the primes below 10^9 *)
(* iterate over the primes below 10^9 *)
prime := primesieve_next_prime(it);
while prime < 1000000000 do
begin
Expand All @@ -30,7 +28,7 @@
end;
WriteLn(Format('Sum of the primes below 10^9 = %d', [sum]));

(* generate primes > 1000 *)
(* generate primes > 1000 *)
primesieve_skipto(it, 1000, 1100);
prime := primesieve_next_prime(it);
while prime < 1100 do
Expand Down
10 changes: 5 additions & 5 deletions examples/store_primes_in_array.pas
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* @example store_primes_in_array.pas
* Store primes in a array. *)
(* Store primes in a array. *)

program store_primes_in_array;
{$IF Defined(FPC)}
{$MODE Delphi}
Expand All @@ -22,7 +22,7 @@
start := 0;
stop := 1000;

(* store the primes below 1000 *)
(* store the primes below 1000 *)
primes := primesieve_generate_primes(start, stop, size, INT32_PRIMES);

for i := 0 to size-1 do
Expand All @@ -31,8 +31,8 @@
primesieve_free(primes);
n := 1000;

(* store the first 1000 primes *)
primes := primesieve_generate_n_primes(n, start, INT_PRIMES);
(* store the first 1000 primes *)
primes := primesieve_generate_n_primes(n, start, INT32_PRIMES);

for i := 0 to n-1 do
WriteLn(primes[i]);
Expand Down
File renamed without changes.
13 changes: 5 additions & 8 deletions primesieve.pas
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
Pascal bindings for primesieve library.
primesieve - library for fast prime number generation.@br
Copyright (C) 2010 - 2021 Kim Walisch, <[email protected]>@br
https://github.com/kimwalisch/primesieve
primesieve-pas - FPC/Delphi API for primesieve library.@br
Copyright (C) 2020 - 2021 I. Kakoulidis, <[email protected]>@br
https://github.com/JulStrat/primesieve-pas
This file is distributed under the BSD 2-Clause License.
}

Expand Down Expand Up @@ -55,11 +55,8 @@ interface
{$REGION 'primesieve.h'}

const
(* @deprecated *)
_PRIMESIEVE_VERSION = '7.6';
(* @deprecated *)
_PRIMESIEVE_VERSION_MAJOR = 7;
(* @deprecated *)
_PRIMESIEVE_VERSION_MINOR = 6;

(* Pascal API version *)
Expand Down Expand Up @@ -440,7 +437,7 @@ implementation

{$POINTERMATH ON}

function primesieve_next_prime(var it: primesieve_iterator): UInt64; inline;
function primesieve_next_prime(var it: primesieve_iterator): UInt64;
begin
{$IF Defined(USE_ABI6)}
if it.i_ = it.last_idx_ then
Expand All @@ -457,7 +454,7 @@ function primesieve_next_prime(var it: primesieve_iterator): UInt64; inline;
{$ENDIF}
end;

function primesieve_prev_prime(var it: primesieve_iterator): UInt64; inline;
function primesieve_prev_prime(var it: primesieve_iterator): UInt64;
begin
{$IF Defined(USE_ABI6)}
if it.i_ = 0 then
Expand Down
5 changes: 3 additions & 2 deletions primesieve_info.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <inttypes.h>
#include <stdio.h>
#include <primesieve.h>

Expand All @@ -6,8 +7,8 @@ int main() {
printf("----------------------\n");
printf("Library version: %s\n", primesieve_version());
printf("API version: %s\n", PRIMESIEVE_VERSION);
printf("PRIMESIEVE_ERROR constant: %lX\n", PRIMESIEVE_ERROR);
printf("Largest valid stop number: %lX\n", primesieve_get_max_stop());
printf("PRIMESIEVE_ERROR constant: %" PRIX64 "\n", PRIMESIEVE_ERROR);
printf("Largest valid stop number: %" PRIX64 "\n", primesieve_get_max_stop());
printf("Current sieve size in KiB: %d\n", primesieve_get_sieve_size());
printf("Current number of threads: %d\n", primesieve_get_num_threads());
printf("SizeOf primesieve_iterator record: %ld\n", sizeof(primesieve_iterator));
Expand Down

0 comments on commit 43fdab2

Please sign in to comment.