forked from danaj/Math-Prime-Util
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfactor.h
57 lines (48 loc) · 1.99 KB
/
factor.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
#ifndef MPU_FACTOR_H
#define MPU_FACTOR_H
#include "ptypes.h"
#define MPU_MAX_FACTORS 64
extern int factor(UV n, UV *factors);
extern int factor_exp(UV n, UV *factors, UV* exponents);
extern int factor_one(UV n, UV *factors, int primality, int trial);
extern UV divisor_sum(UV n, UV k);
extern int trial_factor(UV n, UV *factors, UV first, UV last);
extern int fermat_factor(UV n, UV *factors, UV rounds);
extern int holf_factor(UV n, UV *factors, UV rounds);
extern int pbrent_factor(UV n, UV *factors, UV maxrounds, UV a);
extern int prho_factor(UV n, UV *factors, UV maxrounds);
extern int pminus1_factor(UV n, UV *factors, UV B1, UV B2);
extern int pplus1_factor(UV n, UV *factors, UV B);
extern int squfof_factor(UV n, UV *factors, UV rounds);
extern int lehman_factor(UV n, UV *factors, int dotrial);
extern int cheb_factor(UV n, UV *factors, UV B, UV initx);
extern UV* divisor_list(UV n, UV *num_divisors, UV maxd);
extern int prime_omega(UV n); /* number of distinct prime factors */
extern int prime_bigomega(UV n); /* number of prime factors w/ multiplicity */
/* bigomega => with_multiplicity=1 omega => with_multiplicity=0 */
extern unsigned char* range_nfactor_sieve(UV lo, UV hi, int with_multiplicity);
/* Factoring all numbers in a range. */
typedef struct {
UV lo;
UV hi;
UV n;
char is_square_free;
UV *factors;
UV _coffset;
UV _noffset;
UV *_farray;
UV *_nfactors;
} factor_range_context_t;
extern factor_range_context_t factor_range_init(UV lo, UV hi, int square_free);
extern int factor_range_next(factor_range_context_t *ctx);
extern void factor_range_destroy(factor_range_context_t *ctx);
/*
extern UV dlp_trial(UV a, UV g, UV p, UV maxrounds);
extern UV dlp_prho(UV a, UV g, UV p, UV n, UV maxrounds);
extern UV dlp_bsgs(UV a, UV g, UV p, UV n, UV maxent);
*/
/* Generic znlog returns k that solves a = g^k mod p */
extern UV znlog(UV a, UV g, UV p);
/* znlog given prime gorder = znorder(g,p) */
extern UV znlog_solve(UV a, UV g, UV p, UV gorder);
#endif