The cl-prime-maker Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The cl-prime-maker Reference Manual

This is the cl-prime-maker Reference Manual, version 0.2, generated automatically by Declt version 2.4 "Will Decker" on Wed Jun 20 11:19:38 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

cl-prime-maker

A simple library to generate big prime numbers in a fast way. But in some cases, the generated number is not a prime number (these are called pseudo-primes).

Translated from the erlang version: http://www.oschina.net/code/snippet_222150_8518

##About pseudo-primes## "The probability of mis-classifying a number is approximately 2^-100. So we can be fairly sure that the classification is correct."

##Usage##

###Load the library###

CL-USER> (ql:quickload "cl-prime-maker")
To load "cl-prime-maker":
  Load 1 ASDF system:
    cl-prime-maker

###Function: cl-prime-maker:make-prime### Generates a random prime P with at least K decimal digits. Returns nil when k <= 0. Returns NIL otherwise. K should be an INTEGER.

CL-USER> (cl-prime-maker:make-prime 10)
1028450429
CL-USER> (cl-prime-maker:make-prime 10)
247158671
CL-USER> (cl-prime-maker:make-prime 10)
9424855123
CL-USER> (cl-prime-maker:make-prime 100)
2527793987464535166219814069528290578410091106736510171938329845710426162526052832327367116801544019
CL-USER> (time (cl-prime-maker:make-prime 100))
(CL-PRIME-MAKER:MAKE-PRIME 100)
took 516 milliseconds (0.516 seconds) to run.
During that period, and with 2 available CPU cores,
     516 milliseconds (0.516 seconds) were spent in user mode
       0 milliseconds (0.000 seconds) were spent in system mode
 11,720,160 bytes of memory allocated.
5699885229276577728495724707769425629156908217502336077240701491905327286488809030648850373069454909

###Function: cl-prime-maker:primep### Tests if N is a prime number. Returns T if N is a prime number. Returns NIL otherwise.

NOTES

CL-USER> (time (cl-prime-maker:primep 5699885229276577728495724707769425629156908217502336077240701491905327286488809030648850373069454909))
(CL-PRIME-MAKER:PRIMEP 5699885229276577728495724707769425629156908217502336077240701491905327286488809030648850373069454909)
took 390 milliseconds (0.390 seconds) to run.
During that period, and with 2 available CPU cores,
     391 milliseconds (0.391 seconds) were spent in user mode
       0 milliseconds (0.000 seconds) were spent in system mode
 8,757,192 bytes of memory allocated.
T
CL-USER> (time (cl-prime-maker:primep 569988522927657772849572470776942562915690821750233607724070149190532728648880903064885037306945490))
(CL-PRIME-MAKER:PRIMEP 569988522927657772849572470776942562915690821750233607724070149190532728648880903064885037306945490)
took 0 milliseconds (0.000 seconds) to run.
During that period, and with 2 available CPU cores,
     0 milliseconds (0.000 seconds) were spent in user mode
     0 milliseconds (0.000 seconds) were spent in system mode
 89,992 bytes of memory allocated.
NIL


###Function: cl-prime-maker:get-nth-prime### Generate the Nth prime number when N >= 1. Otherwise, this function always returns 2.

NOTES

CL-USER> (loop for i from 1 to 10 do (print (cl-prime-maker:get-nth-prime i)))
2 
3 
5 
7 
11 
13 
17 
19 
23 
29 
NIL
CL-USER> (time (cl-prime-maker:get-nth-prime 4000))
(CL-PRIME-MAKER:GET-NTH-PRIME 4000)
took 9,435,975 microseconds (9.435975 seconds) to run.
       422,584 microseconds (0.422584 seconds, 4.48%) of which was spent in GC.
During that period, and with 4 available CPU cores,
     9,420,502 microseconds (9.420502 seconds) were spent in user mode
       100,228 microseconds (0.100228 seconds) were spent in system mode
 1,428,879,264 bytes of memory allocated.
 1,194 minor page faults, 0 major page faults, 0 swaps.
37813
CL-USER> (time (cl-prime-maker:get-nth-prime 4000))
(CL-PRIME-MAKER:GET-NTH-PRIME 4000)
took 16 microseconds (0.000016 seconds) to run.
During that period, and with 4 available CPU cores,
      0 microseconds (0.000000 seconds) were spent in user mode
      0 microseconds (0.000000 seconds) were spent in system mode
37813

Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 cl-prime-maker

Author

Xiaofeng Yang <n.akr.akiiya at gmail.com>

License

BSD

Description

A simple library to generate big prime numbers in a fast way. But in some cases, the generated number is not a prime number (these are called pseudo-primes). "The probability of mis-classifying a number is approximately 2^-100. So we can be fairly sure that the classification is correct."

Version

0.2

Source

cl-prime-maker.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Modules

Modules are listed depth-first from the system components tree.


Next: , Previous: , Up: Modules   [Contents][Index]

3.1 cl-prime-maker/package-init

Parent

cl-prime-maker (system)

Location

src/

Component

packages.lisp (file)


Previous: , Up: Modules   [Contents][Index]

3.2 cl-prime-maker/sources

Dependency

package-init (module)

Parent

cl-prime-maker (system)

Location

src/

Components

Next: , Previous: , Up: Top   [Contents][Index]

4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

4.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.1 cl-prime-maker.asd

Location

cl-prime-maker.asd

Systems

cl-prime-maker (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.2 cl-prime-maker/package-init/packages.lisp

Parent

package-init (module)

Location

src/packages.lisp

Packages

cl-prime-maker


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.3 cl-prime-maker/sources/prime-maker.lisp

Parent

sources (module)

Location

src/prime-maker.lisp

Exported Definitions
Internal Definitions

Previous: , Up: Lisp files   [Contents][Index]

4.1.4 cl-prime-maker/sources/sm-ruiz-2000.lisp

Dependency

prime-maker.lisp (file)

Parent

sources (module)

Location

src/sm-ruiz-2000.lisp

Exported Definitions

get-nth-prime (function)

Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

5.1 cl-prime-maker

Source

packages.lisp (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

6.1 Exported definitions


Previous: , Up: Exported definitions   [Contents][Index]

6.1.1 Functions

Function: get-nth-prime N

Generate the Nth prime number when N >= 1. Otherwise this function always returns 2.

Package

cl-prime-maker

Source

sm-ruiz-2000.lisp (file)

Function: make-prime K

Generates a random prime P with at least K decimal digits. Returns nil when k <= 0. Returns NIL otherwise. K should be an INTEGER.

Package

cl-prime-maker

Source

prime-maker.lisp (file)

Function: primep N

Tests if N is a prime number. Returns T if N is a prime number. Returns NIL otherwise.
NOTES:
* If n <= 65535, the detection of whether a number is prime can always get the correct answer. * If n > 65535, the detection of whether a number is prime is based on the Fermat’s little theorem.

Package

cl-prime-maker

Source

prime-maker.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

6.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.1 Special variables

Special Variable: *ruiz-pis*
Package

cl-prime-maker

Source

sm-ruiz-2000.lisp (file)

Special Variable: *ruiz-pis-part1*
Package

cl-prime-maker

Source

sm-ruiz-2000.lisp (file)

Special Variable: *ruiz-results*
Package

cl-prime-maker

Source

sm-ruiz-2000.lisp (file)

Special Variable: +primes-below-65535+
Package

cl-prime-maker

Source

prime-maker.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

6.2.2 Functions

Function: compute-ruiz-pi K
Package

cl-prime-maker

Source

sm-ruiz-2000.lisp (file)

Function: compute-ruiz-pis-part1 J
Package

cl-prime-maker

Source

sm-ruiz-2000.lisp (file)

Function: make N

make(n) -> I: Generates a random integer I with N decimal digits.

Package

cl-prime-maker

Source

prime-maker.lisp (file)

Function: make-prime-list-for-range MAXIMUM
Package

cl-prime-maker

Source

prime-maker.lisp (file)

Function: make-prime/2 K P
Package

cl-prime-maker

Source

prime-maker.lisp (file)

Function: make/2 N D
Package

cl-prime-maker

Source

prime-maker.lisp (file)

Function: new-seed ()
Package

cl-prime-maker

Source

prime-maker.lisp (file)

Function: pow A B M

Computes V = (A^B) mod M. It’s much faster than (mod (expt a b) m).

Package

cl-prime-maker

Source

prime-maker.lisp (file)

Function: primep/2 D NTESTS
Package

cl-prime-maker

Source

prime-maker.lisp (file)

Function: primep/3 NTEST N LEN
Package

cl-prime-maker

Source

prime-maker.lisp (file)

Function: random-uniform N
Package

cl-prime-maker

Source

prime-maker.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   C   F   L   M  
Index Entry  Section

C
cl-prime-maker.asd: The cl-prime-maker<dot>asd file
cl-prime-maker/package-init: The cl-prime-maker/package-init module
cl-prime-maker/package-init/packages.lisp: The cl-prime-maker/package-init/packages<dot>lisp file
cl-prime-maker/sources: The cl-prime-maker/sources module
cl-prime-maker/sources/prime-maker.lisp: The cl-prime-maker/sources/prime-maker<dot>lisp file
cl-prime-maker/sources/sm-ruiz-2000.lisp: The cl-prime-maker/sources/sm-ruiz-2000<dot>lisp file

F
File, Lisp, cl-prime-maker.asd: The cl-prime-maker<dot>asd file
File, Lisp, cl-prime-maker/package-init/packages.lisp: The cl-prime-maker/package-init/packages<dot>lisp file
File, Lisp, cl-prime-maker/sources/prime-maker.lisp: The cl-prime-maker/sources/prime-maker<dot>lisp file
File, Lisp, cl-prime-maker/sources/sm-ruiz-2000.lisp: The cl-prime-maker/sources/sm-ruiz-2000<dot>lisp file

L
Lisp File, cl-prime-maker.asd: The cl-prime-maker<dot>asd file
Lisp File, cl-prime-maker/package-init/packages.lisp: The cl-prime-maker/package-init/packages<dot>lisp file
Lisp File, cl-prime-maker/sources/prime-maker.lisp: The cl-prime-maker/sources/prime-maker<dot>lisp file
Lisp File, cl-prime-maker/sources/sm-ruiz-2000.lisp: The cl-prime-maker/sources/sm-ruiz-2000<dot>lisp file

M
Module, cl-prime-maker/package-init: The cl-prime-maker/package-init module
Module, cl-prime-maker/sources: The cl-prime-maker/sources module

Jump to:   C   F   L   M  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   C   F   G   M   N   P   R  
Index Entry  Section

C
compute-ruiz-pi: Internal functions
compute-ruiz-pis-part1: Internal functions

F
Function, compute-ruiz-pi: Internal functions
Function, compute-ruiz-pis-part1: Internal functions
Function, get-nth-prime: Exported functions
Function, make: Internal functions
Function, make-prime: Exported functions
Function, make-prime-list-for-range: Internal functions
Function, make-prime/2: Internal functions
Function, make/2: Internal functions
Function, new-seed: Internal functions
Function, pow: Internal functions
Function, primep: Exported functions
Function, primep/2: Internal functions
Function, primep/3: Internal functions
Function, random-uniform: Internal functions

G
get-nth-prime: Exported functions

M
make: Internal functions
make-prime: Exported functions
make-prime-list-for-range: Internal functions
make-prime/2: Internal functions
make/2: Internal functions

N
new-seed: Internal functions

P
pow: Internal functions
primep: Exported functions
primep/2: Internal functions
primep/3: Internal functions

R
random-uniform: Internal functions

Jump to:   C   F   G   M   N   P   R  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *   +  
S  
Index Entry  Section

*
*ruiz-pis*: Internal special variables
*ruiz-pis-part1*: Internal special variables
*ruiz-results*: Internal special variables

+
+primes-below-65535+: Internal special variables

S
Special Variable, *ruiz-pis*: Internal special variables
Special Variable, *ruiz-pis-part1*: Internal special variables
Special Variable, *ruiz-results*: Internal special variables
Special Variable, +primes-below-65535+: Internal special variables

Jump to:   *   +  
S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   P   S  
Index Entry  Section

C
cl-prime-maker: The cl-prime-maker system
cl-prime-maker: The cl-prime-maker package

P
Package, cl-prime-maker: The cl-prime-maker package

S
System, cl-prime-maker: The cl-prime-maker system

Jump to:   C   P   S