1 #ifndef MPU_FACTOR_H 2 #define MPU_FACTOR_H 3 4 #include "ptypes.h" 5 6 #define MPU_MAX_FACTORS 64 7 8 extern int factor(UV n, UV *factors); 9 extern int factor_exp(UV n, UV *factors, UV* exponents); 10 extern int factor_one(UV n, UV *factors, int primality, int trial); 11 extern UV divisor_sum(UV n, UV k); 12 13 extern int trial_factor(UV n, UV *factors, UV first, UV last); 14 extern int fermat_factor(UV n, UV *factors, UV rounds); 15 extern int holf_factor(UV n, UV *factors, UV rounds); 16 extern int pbrent_factor(UV n, UV *factors, UV maxrounds, UV a); 17 extern int prho_factor(UV n, UV *factors, UV maxrounds); 18 extern int pminus1_factor(UV n, UV *factors, UV B1, UV B2); 19 extern int pplus1_factor(UV n, UV *factors, UV B); 20 extern int squfof_factor(UV n, UV *factors, UV rounds); 21 extern int lehman_factor(UV n, UV *factors, int dotrial); 22 23 extern UV* _divisor_list(UV n, UV *num_divisors); 24 25 /* Factoring all numbers in a range. */ 26 typedef struct { 27 UV lo; 28 UV hi; 29 UV n; 30 char is_square_free; 31 UV *factors; 32 UV _coffset; 33 UV _noffset; 34 UV *_farray; 35 UV *_nfactors; 36 } factor_range_context_t; 37 extern factor_range_context_t factor_range_init(UV lo, UV hi, int square_free); 38 extern int factor_range_next(factor_range_context_t *ctx); 39 extern void factor_range_destroy(factor_range_context_t *ctx); 40 41 /* 42 extern UV dlp_trial(UV a, UV g, UV p, UV maxrounds); 43 extern UV dlp_prho(UV a, UV g, UV p, UV n, UV maxrounds); 44 extern UV dlp_bsgs(UV a, UV g, UV p, UV n, UV maxent); 45 */ 46 extern UV znlog(UV a, UV g, UV p); 47 48 #endif 49