-
Notifications
You must be signed in to change notification settings - Fork 1
/
riesel.h
64 lines (59 loc) · 2.36 KB
/
riesel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* riesel - implementaion of calc's setup functions in lucas.cal in C using gmp
*
* This code was converted by Konstantin Simeonov from the lucas.cal
* calc resource file as distrivurted by calc in version 2.12.6.7.
* For information on calc, see:
*
* http://www.isthe.com/chongo/tech/comp/calc/index.html
* https://github.com/lcn2/calc
*
* For information on lucas.cal see:
*
* https://github.com/lcn2/calc/blob/master/cal/lucas.cal
*
* For a general tutorial on how to find a new largest known prime, see:
*
* http://www.isthe.com/chongo/tech/math/prime/prime-tutorial.pdf
*
* Credit for C/gmp implemention: Konstantin Simeonov
* Credit for the original lucas.cal calc implementation: Landon Curt Noll
*
* Copyright (c) 2018,2020 by Konstantin Simeonov and Landon Curt Noll. All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that the above copyright, this permission notice and text
* this comment, and the disclaimer below appear in all of the following:
*
* supporting documentation
* source copies
* source works derived from this source
* binaries derived from this source or from derived source
*
* LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
* EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Share and enjoy! :-)
*/
#if !defined(INCLUDE_RIESEL_H)
#define INCLUDE_RIESEL_H
#include <stdint.h>
#include <gmp.h>
/*
* NOTE: In some litature they use U(0) or U(1) as the first term.
* We use U(2) so that U(N) is the critical value. I.e., the
* primality of h*2^n-1 depends in U(N) being a multiple of h*2^n-1.
*/
#define FIRST_TERM_INDEX (2) // first Lucas term is U(2), so first index is 2
/*
* external functions
*/
extern unsigned long gen_u2(uint64_t h, uint64_t n, mpz_t riesel_cand, mpz_t u2);
extern unsigned long gen_v1(uint64_t h, uint64_t n, mpz_t riesel_cand);
#endif /* INCLUDE_RIESEL_H */