-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcoultau.h
More file actions
65 lines (53 loc) · 1.72 KB
/
coultau.h
File metadata and controls
65 lines (53 loc) · 1.72 KB
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
65
#ifndef COULTAU_H
#define COULTAU_H
#include <gmp.h>
#include "types.h"
#include "ptypes.h"
typedef unsigned char bool;
typedef enum {
FS_INIT = 0,
FS_TRIAL,
FS_POWER,
FS_LARGE,
FS_TERM,
} fs_state_t;
#define MAX_FACTORS 128
typedef struct factor_state_s {
fs_state_t state;
mpz_t n; /* remaining number to be factored */
mpz_t f; /* new factor found */
int e; /* new exponent found */
int ef; /* exponent multiplier */
UV tlim; /* p^2 limit checked by trial division */
/* used only for trial division phase */
UV sp; /* smallprime index */
UV un;
/* used only after trial division phase */
int log; /* verbose_level */
int ntofac; /* number of additional factors in tofac_stack[] */
mpz_t tofac_stack[MAX_FACTORS];
} factor_state;
typedef struct s_tm {
mpz_t n; /* remaining value to test */
uint t; /* look for tau(n^e) = t */
uint vi; /* index of value being tested */
uint e; /* power found */
uint state; /* next factor test to try */
ulong bits; /* bitset showing which factor tests to try */
ulong B1; /* for ECM tests */
ulong tlim; /* checked to */
} t_tm;
extern t_tm *taum;
typedef uint (*tau_failure_handler)(uint count, t_tm *taum);
extern void init_tau(uint test_rough, uint flake);
extern void done_tau(void);
extern void fs_init(factor_state* fs);
extern void fs_clear(factor_state* fs);
extern int factor_one(factor_state* fs);
extern int is_taux(mpz_t n, uint32_t k, uint32_t x);
extern void alloc_taum(uint size);
extern bool tau_multi_prep(uint i);
extern uint tau_multi_run(uint i, tau_failure_handler tfh);
extern bool tau_prime_prep(uint i);
extern uint tau_prime_run(uint i);
#endif