diff --git a/Code/nan_numerics_prime.pl b/Code/nan_numerics_prime.pl index 9e719b8..b2f2446 100644 --- a/Code/nan_numerics_prime.pl +++ b/Code/nan_numerics_prime.pl @@ -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)). @@ -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. @@ -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|=. @@ -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. @@ -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. @@ -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. @@ -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|=. diff --git a/Code/nan_numerics_prime_lgc.pl b/Code/nan_numerics_prime_lgc.pl index a070f69..2e4e519 100644 --- a/Code/nan_numerics_prime_lgc.pl +++ b/Code/nan_numerics_prime_lgc.pl @@ -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? @@ -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), @@ -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), @@ -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) :- @@ -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), @@ -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). @@ -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), @@ -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), !. @@ -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), diff --git a/Code/nan_numerics_prime_mem.pl b/Code/nan_numerics_prime_mem.pl index 815cb17..809fa40 100644 --- a/Code/nan_numerics_prime_mem.pl +++ b/Code/nan_numerics_prime_mem.pl @@ -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? diff --git a/Code/nan_numerics_prime_pio.pl b/Code/nan_numerics_prime_pio.pl index 2f50dfd..a36fe98 100644 --- a/Code/nan_numerics_prime_pio.pl +++ b/Code/nan_numerics_prime_pio.pl @@ -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 */ diff --git a/Code/nan_numerics_prime_prb.pl b/Code/nan_numerics_prime_prb.pl index ee0cab4..cbfdd8d 100644 --- a/Code/nan_numerics_prime_prb.pl +++ b/Code/nan_numerics_prime_prb.pl @@ -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? diff --git a/Code/nan_numerics_prime_whl.pl b/Code/nan_numerics_prime_whl.pl index ab5b735..3b1d2ba 100644 --- a/Code/nan_numerics_prime_whl.pl +++ b/Code/nan_numerics_prime_whl.pl @@ -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 */ diff --git a/Deploy/pack.bat b/Deploy/pack.bat index fcf65c6..b5d0ebd 100644 --- a/Deploy/pack.bat +++ b/Deploy/pack.bat @@ -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 @@ -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%" ( @@ -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... diff --git a/Deploy/pack_doc.pl b/Deploy/pack_doc.pl deleted file mode 100644 index d43e181..0000000 --- a/Deploy/pack_doc.pl +++ /dev/null @@ -1,36 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -/* Nan.Numerics.Prime - A simple prime number library - Copyright 2016 Julio P. Di Egidio - - - - This file is part of Nan.Numerics.Prime. - - Nan.Numerics.Prime is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Nan.Numerics.Prime is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Nan.Numerics.Prime. If not, see . -*/ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -:- use_module(library(doc_files)). - -:- consult('../Code/nan_numerics_prime'). - -:- doc_save('../Code', - [ doc_root('.work/doc'), - title('Nan.Numerics.Prime') - ]). - -:- halt. - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/Resources/Nan.Windows.Scripts/zipDir.ps1 b/Deploy/zipDir.ps1 similarity index 62% rename from Resources/Nan.Windows.Scripts/zipDir.ps1 rename to Deploy/zipDir.ps1 index b13574f..6848fef 100644 --- a/Resources/Nan.Windows.Scripts/zipDir.ps1 +++ b/Deploy/zipDir.ps1 @@ -1,4 +1,4 @@ -<# Nan.Windows.Scripts +<# Nan.Windows.Scripts Windows PowerShell Scripts. Copyright 2016 Julio P. Di Egidio @@ -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) diff --git a/Publish/nan_numerics_prime-1.0.zip b/Publish/nan_numerics_prime-1.0.zip deleted file mode 100644 index e099780..0000000 Binary files a/Publish/nan_numerics_prime-1.0.zip and /dev/null differ diff --git a/Publish/nan_numerics_prime-1.2.zip b/Publish/nan_numerics_prime-1.2.zip new file mode 100644 index 0000000..4bae700 Binary files /dev/null and b/Publish/nan_numerics_prime-1.2.zip differ diff --git a/README b/README index 932219c..9c9614e 100644 --- a/README +++ b/README @@ -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. @@ -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)). diff --git a/pack.pl b/pack.pl index ed89378..5c3c1c1 100644 --- a/pack.pl +++ b/pack.pl @@ -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', 'julio@diegidio.name'). 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]).