Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
Done SWI pack (SWI online packs just don't work).
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-diegidio committed Aug 27, 2016
1 parent 3b047cc commit 9c32382
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 82 deletions.
17 changes: 11 additions & 6 deletions Code/nan_numerics_prime.pl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
Example:
==
?- pack_install(nan_numerics_prime).
?- pack_install('nan_numerics_prime-1.2.zip').
true.
?- use_module(library(nan_numerics_prime)).
Expand All @@ -94,7 +94,7 @@
==
@author Julio P. Di Egidio
@version 1.0 (beta)
@version 1.2-beta
@copyright 2016 Julio P. Di Egidio
@license GNU GPLv3
@tbd Implement prime counting/n-th prime functions.
Expand Down Expand Up @@ -150,7 +150,7 @@
% Elements of PFs are of the form =|P^F|= with _P_ the prime divisor and
% _F_ the corresponding power.
%
% If N is =1= or a prime number, PFs is =|[N^1]|=.
% If N is equal to =1= or if N is a prime number, PFs is =|[N^1]|=.
%
% The corresponding _unsafe_ predicate is =|prime_lgc:fact_/2|=.

Expand All @@ -164,7 +164,8 @@
%
% Generates in _ascending_ order all prime numbers P, greater than or
% equal to Inf in the variants with arity =2= and =3=, and less than or
% equal to Sup in the variant with arity =3=.
% equal to Sup in the variant with arity =3=. Fails if the prime to the
% left of Sup is less than the prime to the right of Inf.
%
% The corresponding _unsafe_ predicates are =|prime_lgc:gen_/2-3|=, and
% =|prime_lgc:gen_p_/2-3|= if the bounds are definitely prime.
Expand All @@ -186,6 +187,8 @@
%
% Generates in _descending_ order all prime numbers P less than or equal
% to Sup, and greater than or equal to Inf in the variant with arity =3=.
% Fails if Sup is equal to =1= or if the prime to the left of Sup is less
% than the prime to the right of Inf.
%
% The corresponding _unsafe_ predicates are =|prime_lgc:gen_rev_/2-3|=,
% and =|prime_lgc:gen_rev_p_/2-3|= if the bounds are definitely prime.
Expand All @@ -212,7 +215,8 @@

%! prime_prev(+N:posint, -P:prime) is semidet.
%
% P is the greatest prime number less than N.
% P is the greatest prime number less than N. Fails if N is less than or
% equal to =2=.
%
% The corresponding _unsafe_ predicates are =|prime_lgc:prev_/2|=, and
% =|prime_lgc:prev_p_/2|= if N is definitely prime.
Expand All @@ -233,7 +237,8 @@

%! prime_left(+N:posint, -P:prime) is semidet.
%
% P is the greatest prime number less than or equal to N.
% P is the greatest prime number less than or equal to N. Fails if N is
% equal to =1=.
%
% The corresponding _unsafe_ predicate is =|prime_lgc:left_/2|=.

Expand Down
29 changes: 18 additions & 11 deletions Code/nan_numerics_prime_lgc.pl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
arguments and are not steadfast.
@author Julio P. Di Egidio
@version 1.0 (beta)
@version 1.2-beta
@copyright 2016 Julio P. Di Egidio
@license GNU GPLv3
@tbd Integrate =isqrt= function from GMP?
Expand Down Expand Up @@ -109,7 +109,7 @@
% Elements of PFs are of the form =|P^F|= with _P_ the prime divisor and
% _F_ the corresponding power.
%
% If N is =1= or a prime number, PFs is =|[N^1]|=.
% If N is equal to =1= or if N is a prime number, PFs is =|[N^1]|=.

fact_(N, PFs) :-
fact__sel_rev(N, [], PFsRev),
Expand All @@ -127,11 +127,12 @@
fact__pfs(P, PFs, [P^1| PFs]).

%! gen_(+Inf:posint, -P:prime) is multi.
%! gen_(+Inf:posint, +Sup:posint, -P:prime) is multi.
%! gen_(+Inf:posint, +Sup:posint, -P:prime) is nondet.
%
% Generates in _ascending_ order all prime numbers P greater than or
% equal to Inf, and less than or equal to Sup in the variant with arity
% =3=.
% =3=. Fails if the prime to the left of Sup is less than the prime to
% the right of Inf.

gen_(Inf, P) :-
right_(Inf, L),
Expand All @@ -148,10 +149,10 @@
H >= L.

%! gen_p_(+L:prime, -P:prime) is multi.
%! gen_p_(+L:prime, +H:prime, -P:prime) is multi.
%! gen_p_(+L:prime, +H:prime, -P:prime) is nondet.
%
% Generates in _ascending_ order all prime numbers P starting from L, and
% up to H in the variant with arity =3=.
% up to H in the variant with arity =3=. Fails if H is less than L.

gen_p_(P, P).
gen_p_(L, P) :-
Expand All @@ -164,11 +165,13 @@
next_p_(L, L1),
gen_p_(L1, H, P).

%! gen_rev_(+H:prime, -P:prime) is multi.
%! gen_rev_(+Sup:prime, -P:prime) is nondet.
%! gen_rev_(+Inf:posint, +Sup:posint, -P:prime) is nondet.
%
% Generates in _descending_ order all prime numbers P less than or equal
% to Sup, and greater than or equal to Inf in the variant with arity =3=.
% Fails if Sup is equal to =1= or if the prime to the left of Sup is less
% than the prime to the right of Inf.

gen_rev_(Sup, P) :-
left_(Sup, H),
Expand All @@ -182,7 +185,8 @@
%! gen_rev_p_(+L:prime, +H:prime, -P:prime) is nondet.
%
% Generates in _descending_ order all prime numbers P starting from H,
% and down to L in the variant with arity =3=.
% and down to L in the variant with arity =3=. Fails if H is less than
% L.

gen_rev_p_(2, 2) :- !.
gen_rev_p_(P, P).
Expand Down Expand Up @@ -221,7 +225,8 @@

%! prev_(+N:posint, -P:prime) is semidet.
%
% P is the greatest prime number less than N.
% P is the greatest prime number less than N. Fails if N is less than or
% equal to =2=.

prev_(N, P) :-
left_(N, P0),
Expand All @@ -233,7 +238,8 @@

%! prev_p_(+P0:prime, -P:prime) is semidet.
%
% P is the greatest prime number less than P0.
% P is the greatest prime number less than P0. Fails if P is equal to
% =2=.

prev_p_(P0, P) :-
prime_mem:get_(P, P0), !.
Expand All @@ -258,7 +264,8 @@

%! left_(+N:posint, -P:prime) is semidet.
%
% P is the greatest prime number less than or equal to N.
% P is the greatest prime number less than or equal to N. Fails if N is
% equal to =1=.

left_(N, P) :-
prime_whl:left_(N, W, Cert),
Expand Down
2 changes: 1 addition & 1 deletion Code/nan_numerics_prime_mem.pl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
*NOTE*: Predicates in this module are not meant for public use.
@author Julio P. Di Egidio
@version 1.0 (beta)
@version 1.2-beta
@copyright 2016 Julio P. Di Egidio
@license GNU GPLv3
@tbd Implement size limits?
Expand Down
2 changes: 1 addition & 1 deletion Code/nan_numerics_prime_pio.pl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
*NOTE*: Predicates in this module are not meant for public use.
@author Julio P. Di Egidio
@version 1.0 (beta)
@version 1.2-beta
@copyright 2016 Julio P. Di Egidio
@license GNU GPLv3
*/
Expand Down
2 changes: 1 addition & 1 deletion Code/nan_numerics_prime_prb.pl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
*NOTE*: Predicates in this module are not meant for public use.
@author Julio P. Di Egidio
@version 1.0 (beta)
@version 1.2-beta
@copyright 2016 Julio P. Di Egidio
@license GNU GPLv3
@tbd Implement test error estimates?
Expand Down
2 changes: 1 addition & 1 deletion Code/nan_numerics_prime_whl.pl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*NOTE*: Predicates in this module are not meant for public use.
@author Julio P. Di Egidio
@version 1.0 (beta)
@version 1.2-beta
@copyright 2016 Julio P. Di Egidio
@license GNU GPLv3
*/
Expand Down
8 changes: 1 addition & 7 deletions Deploy/pack.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ rem Requires PowerShell 4.0 and .NET 4.5
set name=nan_numerics_prime
set /P ver=Version ?

set swiplExe=C:\Program Files (x86)\swipl\bin\swipl
set scriptsDir=..\Resources\Nan.Windows.Scripts
set infoDir=..
set codeDir=..\Code
set workDir=.\.work
Expand All @@ -47,10 +45,6 @@ echo Copying prolog...

xcopy /Q "%codeDir%\*.*" "%workDir%\prolog\"

echo Generating doc...

"%swiplExe%" -q ".\pack_doc.pl"

echo Generating target...

if exist "%targetFile%" (
Expand All @@ -60,7 +54,7 @@ if exist "%targetFile%" (
PowerShell ^
-NoLogo -NonInteractive -NoProfile ^
-ExecutionPolicy Bypass ^
-File %scriptsDir%\zipDir.ps1 "%workDir%" "%targetFile%"
-File ".\zipDir.ps1" "%workDir%" "%targetFile%"

echo Cleaning up...

Expand Down
36 changes: 0 additions & 36 deletions Deploy/pack_doc.pl

This file was deleted.

32 changes: 18 additions & 14 deletions Resources/Nan.Windows.Scripts/zipDir.ps1 → Deploy/zipDir.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<# Nan.Windows.Scripts
<# Nan.Windows.Scripts
Windows PowerShell Scripts.
Copyright 2016 Julio P. Di Egidio
<mailto:[email protected]>
Expand All @@ -17,28 +17,32 @@
# Adapted from http://stackoverflow.com/a/27289116
# Requires PowerShell 4.0 and .NET 4.5

$encoderSource = @'
$peTypeSource = @'
using System.Text;
public class PathEncoder : UTF8Encoding
namespace Nan.Windows.Scripts
{
public PathEncoder() {}
public override byte[] GetBytes(string s)
public class PathEncoder : UTF8Encoding
{
s = s.Replace("\\", "/");
return base.GetBytes(s);
}
public PathEncoder() {}
public override byte[] GetBytes(string s)
{
s = s.Replace("\\", "/");
return base.GetBytes(s);
}
}
}
'@

Add-Type -AssemblyName 'System'
Add-Type -AssemblyName 'System.IO.Compression'
Add-Type -AssemblyName 'System.IO.Compression.FileSystem'
Add-Type -TypeDefinition $encoderSource
Add-Type -TypeDefinition $peTypeSource

$clType = [System.IO.Compression.CompressionLevel]
$zfType = [System.IO.Compression.ZipFile]
$encType = [PathEncoder]
$clType = [System.IO.Compression.CompressionLevel]
$peType = [Nan.Windows.Scripts.PathEncoder]

$encoder = New-Object $encType
$compression = $clType::Optimal
$cLev = $clType::Optimal
$pEnc = New-Object $peType

$zfType::CreateFromDirectory($Args[0], $Args[1], $compression, $false, $encoder)
$zfType::CreateFromDirectory($Args[0], $Args[1], $cLev, $false, $pEnc)
Binary file removed Publish/nan_numerics_prime-1.0.zip
Binary file not shown.
Binary file added Publish/nan_numerics_prime-1.2.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Nan.Numerics.Prime 1.0-beta
Nan.Numerics.Prime 1.2-beta
A simple prime number library
Copyright 2016 Julio P. Di Egidio
Licensed under GNU GPLv3.
Expand Down Expand Up @@ -29,7 +29,7 @@ SWI-Prolog 7.3.24: http://www.swi-prolog.org/
Example:

==
?- pack_install(nan_numerics_prime).
?- pack_install('nan_numerics_prime-1.2.zip').
true.

?- use_module(library(nan_numerics_prime)).
Expand Down
4 changes: 2 additions & 2 deletions pack.pl
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

name(nan_numerics_prime).
version('1.0'). % 1.0-beta
version('1.2'). % 1.2-beta
title('Nan.Numerics.Prime - A simple prime number library').
author('Julio P. Di Egidio', '[email protected]').
home('http://julio.diegidio.name/Projects/Nan.Numerics.Prime/').
download('https://julio.diegidio.name/Projects/Nan.Numerics.Prime/Prolog/nan_numerics_prime-*.zip').
download('http://julio.diegidio.name/Projects/Nan.Numerics.Prime/Prolog/nan_numerics_prime-*.zip').
provides(numerics).
provides(prime).
keywords([nan, numerics, prime]).
Expand Down

0 comments on commit 9c32382

Please sign in to comment.