File indexing completed on 2026-05-19 08:08:31
0001
0002
0003 #ifndef _CL_NUMTHEORY_H
0004 #define _CL_NUMTHEORY_H
0005
0006 #include "cln/number.h"
0007 #include "cln/integer.h"
0008 #include "cln/modinteger.h"
0009 #include "cln/condition.h"
0010
0011 namespace cln {
0012
0013
0014
0015
0016
0017
0018 extern int jacobi (sintV a, sintV b);
0019 extern int jacobi (const cl_I& a, const cl_I& b);
0020
0021
0022
0023
0024 extern bool isprobprime (const cl_I& n);
0025
0026
0027 extern const cl_I nextprobprime (const cl_R& x);
0028
0029 #if 0
0030
0031
0032
0033
0034 struct primitive_root_t {
0035 cl_composite_condition* condition;
0036 cl_MI gen;
0037
0038 primitive_root_t (cl_composite_condition* c) : condition (c) {}
0039 primitive_root_t (const cl_MI& g) : condition (NULL), gen (g) {}
0040 };
0041 extern const primitive_root_t primitive_root (const cl_modint_ring& R);
0042 #endif
0043
0044
0045
0046
0047
0048 struct sqrt_mod_p_t {
0049 cl_composite_condition* condition;
0050
0051 int solutions;
0052 cl_I factor;
0053 cl_MI solution[2];
0054
0055 sqrt_mod_p_t () {}
0056 sqrt_mod_p_t (cl_composite_condition* c) : condition (c) {}
0057 sqrt_mod_p_t (int s) : condition (NULL), solutions (s) {}
0058 sqrt_mod_p_t (int s, const cl_MI& x0) : condition (NULL), solutions (s)
0059 { solution[0] = x0; }
0060 sqrt_mod_p_t (int s, const cl_MI& x0, const cl_MI& x1) : condition (NULL), solutions (s)
0061 { solution[0] = x0; solution[1] = x1; }
0062 };
0063 extern const sqrt_mod_p_t sqrt_mod_p (const cl_modint_ring& R, const cl_MI& x);
0064
0065
0066
0067
0068
0069
0070
0071 struct cornacchia_t {
0072 cl_composite_condition* condition;
0073
0074 int solutions;
0075
0076
0077 cl_I solution_x;
0078 cl_I solution_y;
0079
0080 cornacchia_t () {}
0081 cornacchia_t (cl_composite_condition* c) : condition (c) {}
0082 cornacchia_t (int s) : condition (NULL), solutions (s) {}
0083 cornacchia_t (int s, const cl_I& x, const cl_I& y) : condition (NULL), solutions (s), solution_x (x), solution_y (y) {}
0084 };
0085 extern const cornacchia_t cornacchia1 (const cl_I& d, const cl_I& p);
0086 extern const cornacchia_t cornacchia4 (const cl_I& d, const cl_I& p);
0087
0088 }
0089
0090 #endif