diff --git a/cli/spiff/CMakeLists.txt b/cli/spiff/CMakeLists.txt index 58dcc61..ba09fb6 100644 --- a/cli/spiff/CMakeLists.txt +++ b/cli/spiff/CMakeLists.txt @@ -36,7 +36,7 @@ target_include_directories(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/../../src/intmath ${CMAKE_CURRENT_SOURCE_DIR}/../../src/polynomials ${CMAKE_CURRENT_SOURCE_DIR}/../../src/rationals - ${CMAKE_CURRENT_SOURCE_DIR}/../../src/qcyclo + ${CMAKE_CURRENT_SOURCE_DIR}/../../src/q_cyclo ${CMAKE_CURRENT_SOURCE_DIR}/../../src/random ${CMAKE_CURRENT_SOURCE_DIR}/../../src/factorization ${CMAKE_CURRENT_SOURCE_DIR}/../../src/units @@ -52,7 +52,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE intmath polynomials rationals - qcyclo + q_cyclo random factorization units diff --git a/cli/spiff/README.md b/cli/spiff/README.md index 25cb486..5e4848c 100644 --- a/cli/spiff/README.md +++ b/cli/spiff/README.md @@ -21,7 +21,7 @@ spffl::rationals::f2n_polyrat_t f2npr F_{2^n}(y) Quotient fiel // spffl::polynomials::fpn_poly_t fpnp F_{p^n}[y] Ring spffl::polynomials::fpn_polymod_t fpnpm F_{p^n}[y]/ Residue field -fpnpolyrat_t fpnpr F_{p^n}(y) Quotient field +fpn_polyrat_t fpnpr F_{p^n}(y) Quotient field ---------------------------------------------------------------- Rings: diff --git a/cli/spiff/f2_handlers.cpp b/cli/spiff/f2_handlers.cpp index e1aadce..083090a 100644 --- a/cli/spiff/f2_handlers.cpp +++ b/cli/spiff/f2_handlers.cpp @@ -7,18 +7,18 @@ #include "int_random.h" #include "tmatrix.h" -int f2op_main(int argc, char **argv, usage_t *pusage) { +int f2_op_main(int argc, char **argv, usage_t *pusage) { spffl::cliparser::cmd_line_parse( argc - 1, argv + 1, spffl::bits::bit_t(0), spffl::bits::bit_t(1)); return 0; } -void f2random_usage(char *argv0) { +void f2_random_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " [count]\n"; exit(1); } -int f2random_main(int argc, char **argv, usage_t *pusage) { +int f2_random_main(int argc, char **argv, usage_t *pusage) { int count = 1; if ((argc != 1) && (argc != 2)) @@ -34,24 +34,24 @@ int f2random_main(int argc, char **argv, usage_t *pusage) { return 0; } -int f2matop_main(int argc, char **argv, usage_t *pusage) { +int f2_mat_op_main(int argc, char **argv, usage_t *pusage) { spffl::cliparser::cmd_line_mat_parse( argc - 1, argv + 1, spffl::bits::bit_t(0), spffl::bits::bit_t(1)); return 0; } -int f2vecop_main(int argc, char **argv, usage_t *pusage) { +int f2_vec_op_main(int argc, char **argv, usage_t *pusage) { spffl::cliparser::cmd_line_vec_parse( argc - 1, argv + 1, spffl::bits::bit_t(0), spffl::bits::bit_t(1)); return 0; } -void f2matchpol_usage(char *argv0) { +void f2_mat_ch_pol_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {goes here}\n"; exit(1); } -int f2matchpol_main(int argc, char **argv, usage_t *pusage) { +int f2_mat_ch_pol_main(int argc, char **argv, usage_t *pusage) { tmatrix A; if (argc != 2) @@ -65,12 +65,12 @@ int f2matchpol_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2matord_usage(char *argv0) { +void f2_mat_ord_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {goes here}\n"; exit(1); } -int f2matord_main(int argc, char **argv, usage_t *pusage) { +int f2_mat_ord_main(int argc, char **argv, usage_t *pusage) { tmatrix A; if (argc != 1) @@ -104,12 +104,12 @@ int f2matord_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2matrandom_usage(char *argv0) { +void f2_mat_random_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {# rows} {# cols}\n"; exit(1); } -int f2matrandom_main(int argc, char **argv, usage_t *pusage) { +int f2_mat_random_main(int argc, char **argv, usage_t *pusage) { int nr, nc; if (argc != 3) diff --git a/cli/spiff/f2_handlers.h b/cli/spiff/f2_handlers.h index 26afd8a..324df1f 100644 --- a/cli/spiff/f2_handlers.h +++ b/cli/spiff/f2_handlers.h @@ -3,22 +3,22 @@ #include "handlers.h" -int f2op_main(int argc, char **argv, usage_t *pusage); +int f2_op_main(int argc, char **argv, usage_t *pusage); -void f2random_usage(char *argv0); -int f2random_main(int argc, char **argv, usage_t *pusage); +void f2_random_usage(char *argv0); +int f2_random_main(int argc, char **argv, usage_t *pusage); -int f2matop_main(int argc, char **argv, usage_t *pusage); +int f2_mat_op_main(int argc, char **argv, usage_t *pusage); -int f2vecop_main(int argc, char **argv, usage_t *pusage); +int f2_vec_op_main(int argc, char **argv, usage_t *pusage); -void f2matchpol_usage(char *argv0); -int f2matchpol_main(int argc, char **argv, usage_t *pusage); +void f2_mat_ch_pol_usage(char *argv0); +int f2_mat_ch_pol_main(int argc, char **argv, usage_t *pusage); -void f2matord_usage(char *argv0); -int f2matord_main(int argc, char **argv, usage_t *pusage); +void f2_mat_ord_usage(char *argv0); +int f2_mat_ord_main(int argc, char **argv, usage_t *pusage); -void f2matrandom_usage(char *argv0); -int f2matrandom_main(int argc, char **argv, usage_t *pusage); +void f2_mat_random_usage(char *argv0); +int f2_mat_random_main(int argc, char **argv, usage_t *pusage); #endif // F2_HANDLERS_H diff --git a/cli/spiff/f2_poly_handlers.cpp b/cli/spiff/f2_poly_handlers.cpp index e3c04b0..6db0ad0 100644 --- a/cli/spiff/f2_poly_handlers.cpp +++ b/cli/spiff/f2_poly_handlers.cpp @@ -17,12 +17,12 @@ #include "list_elements.h" #include "qff.h" -void f2plist_usage(char *argv0) { +void f2_p_list_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {deglo[-deghi]}\n"; exit(1); } -int f2plist_main(int argc, char **argv, usage_t *pusage) { +int f2_p_list_main(int argc, char **argv, usage_t *pusage) { int deglo, deghi; if (argc != 2) pusage(argv[0]); @@ -35,25 +35,25 @@ int f2plist_main(int argc, char **argv, usage_t *pusage) { pusage(argv[0]); for (int deg = deglo; deg <= deghi; deg++) { - tvector elts = spffl::list::f2poly_list(deg); + tvector elts = spffl::list::f2_poly_list(deg); elts.crout(std::cout); } return 0; } -int f2pop_main(int argc, char **argv, usage_t *pusage) { +int f2_p_op_main(int argc, char **argv, usage_t *pusage) { spffl::cliparser::cmd_line_parse( argc - 1, argv + 1, spffl::polynomials::f2_poly_t(0), spffl::polynomials::f2_poly_t(1)); return 0; } -void f2pdeg_usage(char *argv0) { +void f2_p_deg_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {polys ...}\n"; exit(1); } -int f2pdeg_main(int argc, char **argv, usage_t *pusage) { +int f2_p_deg_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t a; for (int argi = 1; argi < argc; argi++) { if (!a.from_string(argv[argi])) @@ -65,12 +65,12 @@ int f2pdeg_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2pgcd_usage(char *argv0) { +void f2_p_gcd_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " [-e] {poly1} {poly2}\n"; exit(1); } -int f2pgcd_main(int argc, char **argv, usage_t *pusage) { +int f2_p_gcd_main(int argc, char **argv, usage_t *pusage) { if ((argc >= 2) && (strcmp(argv[1], "-e") == 0)) { spffl::polynomials::f2_poly_t a, b, g, r, s; if (argc != 4) @@ -106,12 +106,12 @@ int f2pgcd_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2plcm_usage(char *argv0) { +void f2_p_lcm_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {polys ...}\n"; exit(1); } -int f2plcm_main(int argc, char **argv, usage_t *pusage) { +int f2_p_lcm_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t a, l; if (argc < 2) @@ -128,12 +128,12 @@ int f2plcm_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2ptotient_usage(char *argv0) { +void f2_p_totient_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {polys ...}\n"; exit(1); } -int f2ptotient_main(int argc, char **argv, usage_t *pusage) { +int f2_p_totient_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t a; int phi; if (argc < 2) @@ -149,13 +149,13 @@ int f2ptotient_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2ptest_usage(char *argv0) { +void f2_p_test_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {-i|-p|-ip} {polys ...}\n"; std::cerr << "-i: irreducible; -p: primitive.\n"; exit(1); } -int f2ptest_main(int argc, char **argv, usage_t *pusage) { +int f2_p_test_main(int argc, char **argv, usage_t *pusage) { bool do_irr = false, do_prim = false; if (argc < 3) pusage(argv[0]); @@ -180,7 +180,7 @@ int f2ptest_main(int argc, char **argv, usage_t *pusage) { if (argc > 2) std::cout << a << ": "; if (do_irr) { - if (spffl::factorization::f2poly_is_irreducible(a)) + if (spffl::factorization::f2_poly_is_irreducible(a)) std::cout << "IRREDUCIBLE"; else std::cout << "reducible"; @@ -188,7 +188,7 @@ int f2ptest_main(int argc, char **argv, usage_t *pusage) { if (do_irr && do_prim) std::cout << " "; if (do_prim) { - if (spffl::units::f2poly_is_primitive(a)) + if (spffl::units::f2_poly_is_primitive(a)) std::cout << "PRIMITIVE"; else std::cout << "imprimitive"; @@ -198,14 +198,14 @@ int f2ptest_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2pfind_usage(char *argv0) { +void f2_p_find_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {-1|-r} {-i|-p|-ip} {deglo[-deghi]}\n"; std::cerr << "-1: lowest degree; -r: random\n"; std::cerr << "-i: irreducible; -p: primitive\n"; exit(1); } -int f2pfind_main(int argc, char **argv, usage_t *pusage) { +int f2_p_find_main(int argc, char **argv, usage_t *pusage) { bool do_random = false; int deglo, deghi; bool do_irr = false, do_prim = false; @@ -242,40 +242,40 @@ int f2pfind_main(int argc, char **argv, usage_t *pusage) { for (int deg = deglo; deg <= deghi; deg++) { spffl::polynomials::f2_poly_t a; if (do_prim) { - a = do_random ? spffl::units::f2poly_random_prim(deg, do_irr) - : spffl::units::f2poly_find_prim(deg, do_irr); + a = do_random ? spffl::units::f2_poly_random_prim(deg, do_irr) + : spffl::units::f2_poly_find_prim(deg, do_irr); } else { - a = do_random ? spffl::factorization::f2poly_random_irr(deg) - : spffl::factorization::f2poly_find_irr(deg); + a = do_random ? spffl::factorization::f2_poly_random_irreducible(deg) + : spffl::factorization::f2_poly_find_irreducible(deg); } std::cout << a << std::endl; } return 0; } -void f2pperiod_usage(char *argv0) { +void f2_p_period_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {polys ...}\n"; exit(1); } -int f2pperiod_main(int argc, char **argv, usage_t *pusage) { +int f2_p_period_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t a; for (int argi = 1; argi < argc; argi++) { if (!a.from_string(argv[argi])) pusage(argv[0]); if (argc > 2) std::cout << a << ": "; - std::cout << spffl::units::f2poly_period(a) << std::endl; + std::cout << spffl::units::f2_poly_period(a) << std::endl; } return 0; } -void f2pfactor_usage(char *argv0) { +void f2_p_factor_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {polys ...}\n"; exit(1); } -int f2pfactor_main(int argc, char **argv, usage_t *pusage) { +int f2_p_factor_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t a; for (int argi = 1; argi < argc; argi++) { if (!a.from_string(argv[argi])) @@ -299,12 +299,12 @@ int f2pfactor_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2pdivisors_usage(char *argv0) { +void f2_p_divisors_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " [-mp] {polys ...}\n"; exit(1); } -int f2pdivisors_main(int argc, char **argv, usage_t *pusage) { +int f2_p_divisors_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t a; int argb = 1; int maximal_proper_only = 0; @@ -340,12 +340,12 @@ int f2pdivisors_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2peval_usage(char *argv0) { +void f2_p_eval_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {f} {elements of F2 ...}\n"; exit(1); } -int f2peval_main(int argc, char **argv, usage_t *pusage) { +int f2_p_eval_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t f; spffl::bits::bit_t a, b; @@ -363,12 +363,12 @@ int f2peval_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2prandom_usage(char *argv0) { +void f2_p_random_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {deg} [count]\n"; exit(1); } -int f2prandom_main(int argc, char **argv, usage_t *pusage) { +int f2_p_random_main(int argc, char **argv, usage_t *pusage) { int deg, count = 1; if ((argc != 2) && (argc != 3)) @@ -386,12 +386,12 @@ int f2prandom_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2pcompmx_usage(char *argv0) { +void f2_p_comp_mx_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {f2 chpoly}\n"; exit(1); } -int f2pcompmx_main(int argc, char **argv, usage_t *pusage) { +int f2_p_comp_mx_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t chpol; if (argc != 2) @@ -405,19 +405,19 @@ int f2pcompmx_main(int argc, char **argv, usage_t *pusage) { return 0; } -int f2pmatop_main(int argc, char **argv, usage_t *pusage) { +int f2_p_mat_op_main(int argc, char **argv, usage_t *pusage) { spffl::cliparser::cmd_line_mat_parse( argc - 1, argv + 1, spffl::polynomials::f2_poly_t(0), spffl::polynomials::f2_poly_t(1)); return 0; } -void f2pqp_usage(char *argv0) { +void f2_p_qp_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {qpolys ...}\n"; exit(1); } -int f2pqp_main(int argc, char **argv, usage_t *pusage) { +int f2_p_qp_main(int argc, char **argv, usage_t *pusage) { spffl::rationals::qpoly_t qp; spffl::polynomials::f2_poly_t f2p; if (argc < 2) @@ -425,7 +425,7 @@ int f2pqp_main(int argc, char **argv, usage_t *pusage) { for (int argi = 1; argi < argc; argi++) { if (!qp.from_string(argv[argi])) pusage(argv[0]); - f2p = spffl::qcyclo::f2poly_from_qpoly(qp); + f2p = spffl::q_cyclo::f2_poly_from_q_poly(qp); std::cout << f2p << std::endl; } return 0; diff --git a/cli/spiff/f2_poly_handlers.h b/cli/spiff/f2_poly_handlers.h index 76887e1..6c03742 100644 --- a/cli/spiff/f2_poly_handlers.h +++ b/cli/spiff/f2_poly_handlers.h @@ -9,50 +9,50 @@ #include "handlers.h" -void f2plist_usage(char *argv0); -int f2plist_main(int argc, char **argv, usage_t *pusage); +void f2_p_list_usage(char *argv0); +int f2_p_list_main(int argc, char **argv, usage_t *pusage); -int f2pop_main(int argc, char **argv, usage_t *pusage); +int f2_p_op_main(int argc, char **argv, usage_t *pusage); -void f2pdeg_usage(char *argv0); -int f2pdeg_main(int argc, char **argv, usage_t *pusage); +void f2_p_deg_usage(char *argv0); +int f2_p_deg_main(int argc, char **argv, usage_t *pusage); -void f2pgcd_usage(char *argv0); -int f2pgcd_main(int argc, char **argv, usage_t *pusage); +void f2_p_gcd_usage(char *argv0); +int f2_p_gcd_main(int argc, char **argv, usage_t *pusage); -void f2plcm_usage(char *argv0); -int f2plcm_main(int argc, char **argv, usage_t *pusage); +void f2_p_lcm_usage(char *argv0); +int f2_p_lcm_main(int argc, char **argv, usage_t *pusage); -void f2ptotient_usage(char *argv0); -int f2ptotient_main(int argc, char **argv, usage_t *pusage); +void f2_p_totient_usage(char *argv0); +int f2_p_totient_main(int argc, char **argv, usage_t *pusage); -void f2ptest_usage(char *argv0); -int f2ptest_main(int argc, char **argv, usage_t *pusage); +void f2_p_test_usage(char *argv0); +int f2_p_test_main(int argc, char **argv, usage_t *pusage); -void f2pfind_usage(char *argv0); -int f2pfind_main(int argc, char **argv, usage_t *pusage); +void f2_p_find_usage(char *argv0); +int f2_p_find_main(int argc, char **argv, usage_t *pusage); -void f2pperiod_usage(char *argv0); -int f2pperiod_main(int argc, char **argv, usage_t *pusage); +void f2_p_period_usage(char *argv0); +int f2_p_period_main(int argc, char **argv, usage_t *pusage); -void f2pfactor_usage(char *argv0); -int f2pfactor_main(int argc, char **argv, usage_t *pusage); +void f2_p_factor_usage(char *argv0); +int f2_p_factor_main(int argc, char **argv, usage_t *pusage); -void f2pdivisors_usage(char *argv0); -int f2pdivisors_main(int argc, char **argv, usage_t *pusage); +void f2_p_divisors_usage(char *argv0); +int f2_p_divisors_main(int argc, char **argv, usage_t *pusage); -void f2peval_usage(char *argv0); -int f2peval_main(int argc, char **argv, usage_t *pusage); +void f2_p_eval_usage(char *argv0); +int f2_p_eval_main(int argc, char **argv, usage_t *pusage); -void f2prandom_usage(char *argv0); -int f2prandom_main(int argc, char **argv, usage_t *pusage); +void f2_p_random_usage(char *argv0); +int f2_p_random_main(int argc, char **argv, usage_t *pusage); -void f2pcompmx_usage(char *argv0); -int f2pcompmx_main(int argc, char **argv, usage_t *pusage); +void f2_p_comp_mx_usage(char *argv0); +int f2_p_comp_mx_main(int argc, char **argv, usage_t *pusage); -int f2pmatop_main(int argc, char **argv, usage_t *pusage); +int f2_p_mat_op_main(int argc, char **argv, usage_t *pusage); -void f2pqp_usage(char *argv0); -int f2pqp_main(int argc, char **argv, usage_t *pusage); +void f2_p_qp_usage(char *argv0); +int f2_p_qp_main(int argc, char **argv, usage_t *pusage); #endif // F2POLY_HANDLERS_H diff --git a/cli/spiff/f2_polymod_handlers.cpp b/cli/spiff/f2_polymod_handlers.cpp index b524f79..c13b24c 100644 --- a/cli/spiff/f2_polymod_handlers.cpp +++ b/cli/spiff/f2_polymod_handlers.cpp @@ -11,12 +11,12 @@ #include "tbl_types.h" #include -void f2pmlist_usage(char *argv0) { +void f2_pm_list_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " [-a|-u] {m}\n"; exit(1); } -int f2pmlist_main(int argc, char **argv, usage_t *pusage) { +int f2_pm_list_main(int argc, char **argv, usage_t *pusage) { spffl::list::sp_list_type_t type = spffl::list::SP_LIST_ALL; spffl::polynomials::f2_poly_t m; if (argc == 3) { @@ -30,7 +30,7 @@ int f2pmlist_main(int argc, char **argv, usage_t *pusage) { pusage(argv[0]); if (!m.from_string(argv[2])) pusage(argv[0]); - tvector elts = f2polymod_list(m, type); + tvector elts = f2_polymod_list(m, type); elts.crout(std::cout); } else if (argc == 4) { spffl::polynomials::f2_polymod_t g; @@ -44,7 +44,7 @@ int f2pmlist_main(int argc, char **argv, usage_t *pusage) { pusage(argv[0]); if (!g.from_string(argv[2], m)) pusage(argv[0]); - tvector elts = f2polymod_glist(g, type); + tvector elts = f2_polymod_glist(g, type); elts.crout(std::cout); } else { pusage(argv[0]); @@ -52,12 +52,12 @@ int f2pmlist_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2pmop_usage(char *argv0) { +void f2_pm_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {a} {b}\n"; exit(1); } -int f2pmop_main(int argc, char **argv, usage_t *pusage) { +int f2_pm_op_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; if (argc < 2) pusage(argv[0]); @@ -70,12 +70,12 @@ int f2pmop_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2pmtbl_usage(char *argv0) { +void f2_pm_tbl_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {+|-|*|u*|/|log[:g]|alog[:g]}\n"; exit(1); } -int f2pmtbl_main(int argc, char **argv, usage_t *pusage) { +int f2_pm_tbl_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; spffl::polynomials::f2_polymod_t g; int tbl_type = TBL_TYPE_PLUS; @@ -104,7 +104,7 @@ int f2pmtbl_main(int argc, char **argv, usage_t *pusage) { pusage(argv[0]); tbl_type = TBL_TYPE_LOG; } else if (strcmp(argv[2], "log") == 0) { - if (!spffl::units::f2polymod_find_generator(m, g)) { + if (!spffl::units::f2_polymod_find_generator(m, g)) { std::cerr << "Couldn't find generator mod " << m << std::endl; exit(1); } @@ -114,7 +114,7 @@ int f2pmtbl_main(int argc, char **argv, usage_t *pusage) { pusage(argv[0]); tbl_type = TBL_TYPE_ALOG; } else if (strcmp(argv[2], "alog") == 0) { - if (!spffl::units::f2polymod_find_generator(m, g)) { + if (!spffl::units::f2_polymod_find_generator(m, g)) { std::cerr << "Couldn't find generator mod " << m << std::endl; exit(1); } @@ -125,16 +125,16 @@ int f2pmtbl_main(int argc, char **argv, usage_t *pusage) { tvector elts; if ((tbl_type == TBL_TYPE_UNIT_MUL) || (tbl_type == TBL_TYPE_UNIT_DIV) || (tbl_type == TBL_TYPE_LOG) || (tbl_type == TBL_TYPE_ALOG)) - elts = f2polymod_list(m, spffl::list::SP_LIST_UNITS); + elts = f2_polymod_list(m, spffl::list::SP_LIST_UNITS); else - elts = f2polymod_list(m, spffl::list::SP_LIST_ALL); + elts = f2_polymod_list(m, spffl::list::SP_LIST_ALL); int n = elts.get_num_elements(); if (tbl_type == TBL_TYPE_LOG) { std::cout << "element power\n"; std::cout << "------- -----\n"; for (int i = 0; i < n; i++) { - int e = spffl::units::f2polymod_log(g, elts[i]); + int e = spffl::units::f2_polymod_log(g, elts[i]); std::cout << elts[i] << " " << e << std::endl; } return 0; @@ -183,12 +183,12 @@ int f2pmtbl_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2pmord_usage(char *argv0) { +void f2_pm_ord_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {a}\n"; exit(1); } -int f2pmord_main(int argc, char **argv, usage_t *pusage) { +int f2_pm_ord_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; spffl::polynomials::f2_polymod_t a; if (argc < 3) @@ -200,17 +200,17 @@ int f2pmord_main(int argc, char **argv, usage_t *pusage) { pusage(argv[0]); if (argc > 3) std::cout << a << ": "; - std::cout << spffl::units::f2polymod_order(a) << std::endl; + std::cout << spffl::units::f2_polymod_order(a) << std::endl; } return 0; } -void f2pmfindgen_usage(char *argv0) { +void f2_pm_find_gen_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m}\n"; exit(1); } -int f2pmfindgen_main(int argc, char **argv, usage_t *pusage) { +int f2_pm_find_gen_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; spffl::polynomials::f2_polymod_t g; int rv = 0; @@ -221,7 +221,7 @@ int f2pmfindgen_main(int argc, char **argv, usage_t *pusage) { pusage(argv[0]); if (argc > 2) std::cout << m << ": "; - if (spffl::units::f2polymod_find_generator(m, g)) { + if (spffl::units::f2_polymod_find_generator(m, g)) { std::cout << g << std::endl; } else { std::cout << "Generator not found.\n"; @@ -231,12 +231,12 @@ int f2pmfindgen_main(int argc, char **argv, usage_t *pusage) { return rv; } -void f2pmlog_usage(char *argv0) { +void f2_pm_log_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {g} {a}\n"; exit(1); } -int f2pmlog_main(int argc, char **argv, usage_t *pusage) { +int f2_pm_log_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; spffl::polynomials::f2_polymod_t g, a; if (argc < 4) @@ -250,17 +250,17 @@ int f2pmlog_main(int argc, char **argv, usage_t *pusage) { pusage(argv[0]); if (argc > 4) std::cout << a << ": "; - std::cout << spffl::units::f2polymod_log(g, a) << std::endl; + std::cout << spffl::units::f2_polymod_log(g, a) << std::endl; } return 0; } -void f2pmchpol_usage(char *argv0) { +void f2_pm_ch_pol_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {residues ...}\n"; exit(1); } -int f2pmchpol_main(int argc, char **argv, usage_t *pusage) { +int f2_pm_ch_pol_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; spffl::polynomials::f2_polymod_t a; @@ -280,12 +280,12 @@ int f2pmchpol_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2pmminpol_usage(char *argv0) { +void f2_pm_min_pol_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {residues ...}\n"; exit(1); } -int f2pmminpol_main(int argc, char **argv, usage_t *pusage) { +int f2_pm_min_pol_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; spffl::polynomials::f2_polymod_t a; @@ -305,12 +305,12 @@ int f2pmminpol_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2pmconvert_usage(char *argv0) { +void f2_pm_convert_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m1} {m2} {residues ...}\n"; exit(1); } -int f2pmconvert_main(int argc, char **argv, usage_t *pusage) { +int f2_pm_convert_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m1, m2; spffl::polynomials::f2_polymod_t a1, a2, g1, g2; @@ -320,18 +320,18 @@ int f2pmconvert_main(int argc, char **argv, usage_t *pusage) { pusage(argv[0]); if (!m2.from_string(argv[2])) pusage(argv[0]); - if (!spffl::units::f2polymod_find_generator(m1, g1)) { + if (!spffl::units::f2_polymod_find_generator(m1, g1)) { std::cerr << "Can't find generator mod " << m1 << ".\n"; exit(1); } - if (!spffl::linalg::f2polymod_convert_prep(g1, m2, g2)) { + if (!spffl::linalg::f2_polymod_convert_prep(g1, m2, g2)) { std::cerr << "Can't find generator mod " << m2 << ".\n"; exit(1); } for (int argi = 3; argi < argc; argi++) { if (!a1.from_string(argv[argi], m1)) pusage(argv[0]); - a2 = spffl::linalg::f2polymod_convert_scalar(g1, g2, a1); + a2 = spffl::linalg::f2_polymod_convert_scalar(g1, g2, a1); if (argc > 4) std::cout << a1 << ": "; std::cout << a2 << std::endl; @@ -340,12 +340,12 @@ int f2pmconvert_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2pmrandom_usage(char *argv0) { +void f2_pm_random_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} [count]\n"; exit(1); } -int f2pmrandom_main(int argc, char **argv, usage_t *pusage) { +int f2_pm_random_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; int count = 1; @@ -364,12 +364,12 @@ int f2pmrandom_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2pmmatop_usage(char *argv0) { +void f2_pm_mat_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {goes here}\n"; exit(1); } -int f2pmmatop_main(int argc, char **argv, usage_t *pusage) { +int f2_pm_mat_op_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m = 0; spffl::polynomials::f2_polymod_t zero, one; @@ -384,12 +384,12 @@ int f2pmmatop_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2pmvecop_usage(char *argv0) { +void f2_pm_vec_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {goes here}\n"; exit(1); } -int f2pmvecop_main(int argc, char **argv, usage_t *pusage) { +int f2_pm_vec_op_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m = 0; spffl::polynomials::f2_polymod_t zero, one; @@ -404,13 +404,13 @@ int f2pmvecop_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2pmmatsolve_usage(char *argv0) { +void f2_pm_mat_solve_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {A} {b}\n"; std::cerr << "Solves A x = b for x, only when a unique solution exists.\n"; exit(1); } -int f2pmmatsolve_main(int argc, char **argv, usage_t *pusage) { +int f2_pm_mat_solve_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m = 0; spffl::polynomials::f2_polymod_t zero, one; @@ -441,12 +441,12 @@ int f2pmmatsolve_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2pmmatchpol_usage(char *argv0) { +void f2_pm_mat_ch_pol_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {goes here}\n"; exit(1); } -int f2pmmatchpol_main(int argc, char **argv, usage_t *pusage) { +int f2_pm_mat_ch_pol_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; tmatrix A; @@ -464,12 +464,12 @@ int f2pmmatchpol_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2pmmatdable_usage(char *argv0) { +void f2_pm_mat_dable_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {goes here}\n"; exit(1); } -int f2pmmatdable_main(int argc, char **argv, usage_t *pusage) { +int f2_pm_mat_dable_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; tmatrix A; @@ -498,12 +498,12 @@ int f2pmmatdable_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2pmmatord_usage(char *argv0) { +void f2_pm_mat_ord_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {goes here}\n"; exit(1); } -int f2pmmatord_main(int argc, char **argv, usage_t *pusage) { +int f2_pm_mat_ord_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; tmatrix A; @@ -541,12 +541,12 @@ int f2pmmatord_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2pmmatrandom_usage(char *argv0) { +void f2_pm_mat_random_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {# rows} {# cols}\n"; exit(1); } -int f2pmmatrandom_main(int argc, char **argv, usage_t *pusage) { +int f2_pm_mat_random_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; int nr, nc; diff --git a/cli/spiff/f2_polymod_handlers.h b/cli/spiff/f2_polymod_handlers.h index 2dd902b..e14eb3e 100644 --- a/cli/spiff/f2_polymod_handlers.h +++ b/cli/spiff/f2_polymod_handlers.h @@ -3,55 +3,55 @@ #include "handlers.h" -void f2pmlist_usage(char *argv0); -int f2pmlist_main(int argc, char **argv, usage_t *pusage); +void f2_pm_list_usage(char *argv0); +int f2_pm_list_main(int argc, char **argv, usage_t *pusage); -void f2pmop_usage(char *argv0); -int f2pmop_main(int argc, char **argv, usage_t *pusage); +void f2_pm_op_usage(char *argv0); +int f2_pm_op_main(int argc, char **argv, usage_t *pusage); -void f2pmtbl_usage(char *argv0); -int f2pmtbl_main(int argc, char **argv, usage_t *pusage); +void f2_pm_tbl_usage(char *argv0); +int f2_pm_tbl_main(int argc, char **argv, usage_t *pusage); -void f2pmord_usage(char *argv0); -int f2pmord_main(int argc, char **argv, usage_t *pusage); +void f2_pm_ord_usage(char *argv0); +int f2_pm_ord_main(int argc, char **argv, usage_t *pusage); -void f2pmfindgen_usage(char *argv0); -int f2pmfindgen_main(int argc, char **argv, usage_t *pusage); +void f2_pm_find_gen_usage(char *argv0); +int f2_pm_find_gen_main(int argc, char **argv, usage_t *pusage); -void f2pmlog_usage(char *argv0); -int f2pmlog_main(int argc, char **argv, usage_t *pusage); +void f2_pm_log_usage(char *argv0); +int f2_pm_log_main(int argc, char **argv, usage_t *pusage); -void f2pmchpol_usage(char *argv0); -int f2pmchpol_main(int argc, char **argv, usage_t *pusage); +void f2_pm_ch_pol_usage(char *argv0); +int f2_pm_ch_pol_main(int argc, char **argv, usage_t *pusage); -void f2pmminpol_usage(char *argv0); -int f2pmminpol_main(int argc, char **argv, usage_t *pusage); +void f2_pm_min_pol_usage(char *argv0); +int f2_pm_min_pol_main(int argc, char **argv, usage_t *pusage); -void f2pmconvert_usage(char *argv0); -int f2pmconvert_main(int argc, char **argv, usage_t *pusage); +void f2_pm_convert_usage(char *argv0); +int f2_pm_convert_main(int argc, char **argv, usage_t *pusage); -void f2pmrandom_usage(char *argv0); -int f2pmrandom_main(int argc, char **argv, usage_t *pusage); +void f2_pm_random_usage(char *argv0); +int f2_pm_random_main(int argc, char **argv, usage_t *pusage); -void f2pmmatop_usage(char *argv0); -int f2pmmatop_main(int argc, char **argv, usage_t *pusage); +void f2_pm_mat_op_usage(char *argv0); +int f2_pm_mat_op_main(int argc, char **argv, usage_t *pusage); -void f2pmvecop_usage(char *argv0); -int f2pmvecop_main(int argc, char **argv, usage_t *pusage); +void f2_pm_vec_op_usage(char *argv0); +int f2_pm_vec_op_main(int argc, char **argv, usage_t *pusage); -void f2pmmatsolve_usage(char *argv0); -int f2pmmatsolve_main(int argc, char **argv, usage_t *pusage); +void f2_pm_mat_solve_usage(char *argv0); +int f2_pm_mat_solve_main(int argc, char **argv, usage_t *pusage); -void f2pmmatchpol_usage(char *argv0); -int f2pmmatchpol_main(int argc, char **argv, usage_t *pusage); +void f2_pm_mat_ch_pol_usage(char *argv0); +int f2_pm_mat_ch_pol_main(int argc, char **argv, usage_t *pusage); -void f2pmmatdable_usage(char *argv0); -int f2pmmatdable_main(int argc, char **argv, usage_t *pusage); +void f2_pm_mat_dable_usage(char *argv0); +int f2_pm_mat_dable_main(int argc, char **argv, usage_t *pusage); -void f2pmmatord_usage(char *argv0); -int f2pmmatord_main(int argc, char **argv, usage_t *pusage); +void f2_pm_mat_ord_usage(char *argv0); +int f2_pm_mat_ord_main(int argc, char **argv, usage_t *pusage); -void f2pmmatrandom_usage(char *argv0); -int f2pmmatrandom_main(int argc, char **argv, usage_t *pusage); +void f2_pm_mat_random_usage(char *argv0); +int f2_pm_mat_random_main(int argc, char **argv, usage_t *pusage); #endif // F2POLYMOD_HANDLERS_H diff --git a/cli/spiff/f2_polyrat_handlers.cpp b/cli/spiff/f2_polyrat_handlers.cpp index 52932bf..b85a069 100644 --- a/cli/spiff/f2_polyrat_handlers.cpp +++ b/cli/spiff/f2_polyrat_handlers.cpp @@ -5,19 +5,19 @@ #include "f2_poly_random.h" #include "f2_polyrat_t.h" -int f2prop_main(int argc, char **argv, usage_t *pusage) { +int f2_pr_op_main(int argc, char **argv, usage_t *pusage) { spffl::cliparser::cmd_line_parse( argc - 1, argv + 1, spffl::rationals::f2_polyrat_t(0), spffl::rationals::f2_polyrat_t(1)); return 0; } -void f2prrandom_usage(char *argv0) { +void f2_pr_random_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {deg} [count]\n"; exit(1); } -int f2prrandom_main(int argc, char **argv, usage_t *pusage) { +int f2_pr_random_main(int argc, char **argv, usage_t *pusage) { int deg, count = 1; if ((argc != 2) && (argc != 3)) @@ -43,7 +43,7 @@ int f2prrandom_main(int argc, char **argv, usage_t *pusage) { return 0; } -int f2prmatop_main(int argc, char **argv, usage_t *pusage) { +int f2_pr_mat_op_main(int argc, char **argv, usage_t *pusage) { spffl::cliparser::cmd_line_mat_parse( argc - 1, argv + 1, spffl::rationals::f2_polyrat_t(spffl::polynomials::f2_poly_t(0)), @@ -51,12 +51,12 @@ int f2prmatop_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2prmatrandom_usage(char *argv0) { +void f2_pr_mat_random_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {deg} {num_rows} {num_cols}\n"; exit(1); } -int f2prmatrandom_main(int argc, char **argv, usage_t *pusage) { +int f2_pr_mat_random_main(int argc, char **argv, usage_t *pusage) { int deg, nr, nc; if (argc != 4) diff --git a/cli/spiff/f2_polyrat_handlers.h b/cli/spiff/f2_polyrat_handlers.h index fb277cd..6034e2b 100644 --- a/cli/spiff/f2_polyrat_handlers.h +++ b/cli/spiff/f2_polyrat_handlers.h @@ -3,13 +3,13 @@ #include "handlers.h" -int f2prop_main(int argc, char **argv, usage_t *pusage); -void f2prrandom_usage(char *argv0); +int f2_pr_op_main(int argc, char **argv, usage_t *pusage); +void f2_pr_random_usage(char *argv0); -int f2prrandom_main(int argc, char **argv, usage_t *pusage); -int f2prmatop_main(int argc, char **argv, usage_t *pusage); +int f2_pr_random_main(int argc, char **argv, usage_t *pusage); +int f2_pr_mat_op_main(int argc, char **argv, usage_t *pusage); -void f2prmatrandom_usage(char *argv0); -int f2prmatrandom_main(int argc, char **argv, usage_t *pusage); +void f2_pr_mat_random_usage(char *argv0); +int f2_pr_mat_random_main(int argc, char **argv, usage_t *pusage); #endif // F2POLYRAT_HANDLERS_H diff --git a/cli/spiff/f2n_poly_handlers.cpp b/cli/spiff/f2n_poly_handlers.cpp index 9e543f6..6167c89 100644 --- a/cli/spiff/f2n_poly_handlers.cpp +++ b/cli/spiff/f2n_poly_handlers.cpp @@ -13,12 +13,12 @@ #include "tbl_types.h" #include -void f2nplist_usage(char *argv0) { +void f2n_p_list_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {deglo[-deghi]}\n"; exit(1); } -int f2nplist_main(int argc, char **argv, usage_t *pusage) { +int f2n_p_list_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; int deglo, deghi; if (argc != 3) @@ -34,18 +34,18 @@ int f2nplist_main(int argc, char **argv, usage_t *pusage) { pusage(argv[0]); for (int deg = deglo; deg <= deghi; deg++) { tvector elts = - spffl::list::f2npoly_list(m, deg); + spffl::list::f2n_poly_list(m, deg); elts.crout(std::cout); } return 0; } -void f2npop_usage(char *argv0) { +void f2n_p_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {...}\n"; exit(1); } -int f2npop_main(int argc, char **argv, usage_t *pusage) { +int f2n_p_op_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; if (argc < 2) pusage(argv[0]); @@ -60,12 +60,12 @@ int f2npop_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2npdeg_usage(char *argv0) { +void f2n_p_deg_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {polys ...}\n"; exit(1); } -int f2npdeg_main(int argc, char **argv, usage_t *pusage) { +int f2n_p_deg_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; if (argc < 2) pusage(argv[0]); @@ -83,12 +83,12 @@ int f2npdeg_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2npgcd_usage(char *argv0) { +void f2n_p_gcd_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " [-e] {m} {a} {b}\n"; exit(1); } -int f2npgcd_main(int argc, char **argv, usage_t *pusage) { +int f2n_p_gcd_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; spffl::polynomials::f2n_poly_t a, b, g, r, s; @@ -128,12 +128,12 @@ int f2npgcd_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2nplcm_usage(char *argv0) { +void f2n_p_lcm_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {polys ...}\n"; exit(1); } -int f2nplcm_main(int argc, char **argv, usage_t *pusage) { +int f2n_p_lcm_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; spffl::polynomials::f2n_poly_t a, l; @@ -153,12 +153,12 @@ int f2nplcm_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2nptotient_usage(char *argv0) { +void f2n_p_totient_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {polys ...}\n"; exit(1); } -int f2nptotient_main(int argc, char **argv, usage_t *pusage) { +int f2n_p_totient_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; spffl::polynomials::f2n_poly_t a; int phi; @@ -177,12 +177,12 @@ int f2nptotient_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2nptest_usage(char *argv0) { +void f2n_p_test_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {polys ...}\n"; exit(1); } -int f2nptest_main(int argc, char **argv, usage_t *pusage) { +int f2n_p_test_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; if (argc < 2) pusage(argv[0]); @@ -195,7 +195,7 @@ int f2nptest_main(int argc, char **argv, usage_t *pusage) { pusage(argv[0]); if (argc > 3) std::cout << a << ": "; - if (spffl::factorization::f2npoly_is_irreducible(a)) + if (spffl::factorization::f2n_poly_is_irreducible(a)) std::cout << "IRREDUCIBLE\n"; else std::cout << "reducible\n"; @@ -203,12 +203,12 @@ int f2nptest_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2npfind_usage(char *argv0) { +void f2n_p_find_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " [-1|-r] {m} {deglo[-deghi]}\n"; exit(1); } -int f2npfind_main(int argc, char **argv, usage_t *pusage) { +int f2n_p_find_main(int argc, char **argv, usage_t *pusage) { bool do_random = false; int deglo, deghi; spffl::polynomials::f2_poly_t m; @@ -234,20 +234,20 @@ int f2npfind_main(int argc, char **argv, usage_t *pusage) { for (int deg = deglo; deg <= deghi; deg++) { spffl::polynomials::f2n_poly_t a; if (do_random) - a = spffl::factorization::f2npoly_random_irr(m, deg); + a = spffl::factorization::f2n_poly_random_irr(m, deg); else - a = spffl::factorization::f2npoly_find_irr(m, deg); + a = spffl::factorization::f2n_poly_find_irr(m, deg); std::cout << a << std::endl; } return 0; } -void f2npfactor_usage(char *argv0) { +void f2n_p_factor_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {polys ...}\n"; exit(1); } -int f2npfactor_main(int argc, char **argv, usage_t *pusage) { +int f2n_p_factor_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; if (argc < 2) pusage(argv[0]); @@ -278,12 +278,12 @@ int f2npfactor_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2npdivisors_usage(char *argv0) { +void f2n_p_divisors_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " [-mp] {m} {polys ...}\n"; exit(1); } -int f2npdivisors_main(int argc, char **argv, usage_t *pusage) { +int f2n_p_divisors_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; spffl::polynomials::f2n_poly_t a; int argb = 1; @@ -326,12 +326,12 @@ int f2npdivisors_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2npeval_usage(char *argv0) { +void f2n_p_eval_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {f} {elements of Fq ...}\n"; exit(1); } -int f2npeval_main(int argc, char **argv, usage_t *pusage) { +int f2n_p_eval_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; spffl::polynomials::f2n_poly_t f; spffl::polynomials::f2_polymod_t a, b; @@ -352,12 +352,12 @@ int f2npeval_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2nprandom_usage(char *argv0) { +void f2n_p_random_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {deg} [count]\n"; exit(1); } -int f2nprandom_main(int argc, char **argv, usage_t *pusage) { +int f2n_p_random_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; int deg, count = 1; @@ -378,12 +378,12 @@ int f2nprandom_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2npcompmx_usage(char *argv0) { +void f2n_p_comp_mx_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {poly}\n"; exit(1); } -int f2npcompmx_main(int argc, char **argv, usage_t *pusage) { +int f2n_p_comp_mx_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; spffl::polynomials::f2n_poly_t chpol; @@ -401,12 +401,12 @@ int f2npcompmx_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2npqp_usage(char *argv0) { +void f2n_p_qp_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {qpolys ...}\n"; exit(1); } -int f2npqp_main(int argc, char **argv, usage_t *pusage) { +int f2n_p_qp_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; spffl::rationals::qpoly_t qp; spffl::polynomials::f2n_poly_t f2np; @@ -417,18 +417,18 @@ int f2npqp_main(int argc, char **argv, usage_t *pusage) { for (int argi = 2; argi < argc; argi++) { if (!qp.from_string(argv[argi])) pusage(argv[0]); - f2np = spffl::qcyclo::f2npoly_from_qpoly(qp, m); + f2np = spffl::q_cyclo::f2n_poly_from_qpoly(qp, m); std::cout << f2np << std::endl; } return 0; } -void f2npmatop_usage(char *argv0) { +void f2n_p_mat_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {...}\n"; exit(1); } -int f2npmatop_main(int argc, char **argv, usage_t *pusage) { +int f2n_p_mat_op_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; if (argc < 2) pusage(argv[0]); diff --git a/cli/spiff/f2n_poly_handlers.h b/cli/spiff/f2n_poly_handlers.h index 81d6600..588c95a 100644 --- a/cli/spiff/f2n_poly_handlers.h +++ b/cli/spiff/f2n_poly_handlers.h @@ -3,52 +3,52 @@ #include "handlers.h" -void f2nplist_usage(char *argv0); -int f2nplist_main(int argc, char **argv, usage_t *pusage); +void f2n_p_list_usage(char *argv0); +int f2n_p_list_main(int argc, char **argv, usage_t *pusage); -void f2npop_usage(char *argv0); -int f2npop_main(int argc, char **argv, usage_t *pusage); +void f2n_p_op_usage(char *argv0); +int f2n_p_op_main(int argc, char **argv, usage_t *pusage); -void f2npmatop_usage(char *argv0); -int f2npmatop_main(int argc, char **argv, usage_t *pusage); +void f2n_p_mat_op_usage(char *argv0); +int f2n_p_mat_op_main(int argc, char **argv, usage_t *pusage); -void f2npdeg_usage(char *argv0); -int f2npdeg_main(int argc, char **argv, usage_t *pusage); +void f2n_p_deg_usage(char *argv0); +int f2n_p_deg_main(int argc, char **argv, usage_t *pusage); -void f2npgcd_usage(char *argv0); -int f2npgcd_main(int argc, char **argv, usage_t *pusage); +void f2n_p_gcd_usage(char *argv0); +int f2n_p_gcd_main(int argc, char **argv, usage_t *pusage); -void f2nplcm_usage(char *argv0); -int f2nplcm_main(int argc, char **argv, usage_t *pusage); +void f2n_p_lcm_usage(char *argv0); +int f2n_p_lcm_main(int argc, char **argv, usage_t *pusage); -void f2nptotient_usage(char *argv0); -int f2nptotient_main(int argc, char **argv, usage_t *pusage); +void f2n_p_totient_usage(char *argv0); +int f2n_p_totient_main(int argc, char **argv, usage_t *pusage); -void f2nptest_usage(char *argv0); -int f2nptest_main(int argc, char **argv, usage_t *pusage); +void f2n_p_test_usage(char *argv0); +int f2n_p_test_main(int argc, char **argv, usage_t *pusage); -void f2npfind_usage(char *argv0); -int f2npfind_main(int argc, char **argv, usage_t *pusage); +void f2n_p_find_usage(char *argv0); +int f2n_p_find_main(int argc, char **argv, usage_t *pusage); -void f2npfactor_usage(char *argv0); -int f2npfactor_main(int argc, char **argv, usage_t *pusage); +void f2n_p_factor_usage(char *argv0); +int f2n_p_factor_main(int argc, char **argv, usage_t *pusage); -void f2npdivisors_usage(char *argv0); -int f2npdivisors_main(int argc, char **argv, usage_t *pusage); +void f2n_p_divisors_usage(char *argv0); +int f2n_p_divisors_main(int argc, char **argv, usage_t *pusage); -void f2npeval_usage(char *argv0); -int f2npeval_main(int argc, char **argv, usage_t *pusage); +void f2n_p_eval_usage(char *argv0); +int f2n_p_eval_main(int argc, char **argv, usage_t *pusage); -void f2nprandom_usage(char *argv0); -int f2nprandom_main(int argc, char **argv, usage_t *pusage); +void f2n_p_random_usage(char *argv0); +int f2n_p_random_main(int argc, char **argv, usage_t *pusage); -void f2npcompmx_usage(char *argv0); -int f2npcompmx_main(int argc, char **argv, usage_t *pusage); +void f2n_p_comp_mx_usage(char *argv0); +int f2n_p_comp_mx_main(int argc, char **argv, usage_t *pusage); -void f2npqp_usage(char *argv0); -int f2npqp_main(int argc, char **argv, usage_t *pusage); +void f2n_p_qp_usage(char *argv0); +int f2n_p_qp_main(int argc, char **argv, usage_t *pusage); -void f2npmatop_usage(char *argv0); -int f2npmatop_main(int argc, char **argv, usage_t *pusage); +void f2n_p_mat_op_usage(char *argv0); +int f2n_p_mat_op_main(int argc, char **argv, usage_t *pusage); #endif // F2NPOLY_HANDLERS_H diff --git a/cli/spiff/f2n_polymod_handlers.cpp b/cli/spiff/f2n_polymod_handlers.cpp index 4623a05..2d9c655 100644 --- a/cli/spiff/f2n_polymod_handlers.cpp +++ b/cli/spiff/f2n_polymod_handlers.cpp @@ -11,12 +11,12 @@ #include "min_char_polys.h" #include "tbl_types.h" -void f2npmlist_usage(char *argv0) { +void f2n_pm_list_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " [-a|-u] {im} {om}\n"; exit(1); } -int f2npmlist_main(int argc, char **argv, usage_t *pusage) { +int f2n_pm_list_main(int argc, char **argv, usage_t *pusage) { spffl::list::sp_list_type_t type = spffl::list::SP_LIST_ALL; spffl::polynomials::f2_poly_t im; spffl::polynomials::f2n_poly_t om; @@ -34,17 +34,17 @@ int f2npmlist_main(int argc, char **argv, usage_t *pusage) { pusage(argv[0]); if (!om.from_string(argv[3], im)) pusage(argv[0]); - tvector elts = f2npolymod_list(om, type); + tvector elts = f2n_polymod_list(om, type); elts.crout(std::cout); return 0; } -void f2npmop_usage(char *argv0) { +void f2n_pm_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {inner m} {outer m} {...}\n"; exit(1); } -int f2npmop_main(int argc, char **argv, usage_t *pusage) { +int f2n_pm_op_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t im; spffl::polynomials::f2n_poly_t om; if (argc < 3) @@ -62,13 +62,13 @@ int f2npmop_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2npmtbl_usage(char *argv0) { +void f2n_pm_tbl_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {im} {om} {+|-|*|u*|/|log[:g]|alog[:g]}\n"; exit(1); } -int f2npmtbl_main(int argc, char **argv, usage_t *pusage) { +int f2n_pm_tbl_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t im; spffl::polynomials::f2n_poly_t om; spffl::polynomials::f2n_polymod_t g; @@ -100,7 +100,7 @@ int f2npmtbl_main(int argc, char **argv, usage_t *pusage) { pusage(argv[0]); tbl_type = TBL_TYPE_LOG; } else if (strcmp(argv[3], "log") == 0) { - if (!spffl::units::f2npolymod_find_generator(om, g)) { + if (!spffl::units::f2n_polymod_find_generator(om, g)) { std::cerr << "Couldn't find generator mod " << om << "\n"; exit(1); } @@ -110,7 +110,7 @@ int f2npmtbl_main(int argc, char **argv, usage_t *pusage) { pusage(argv[0]); tbl_type = TBL_TYPE_ALOG; } else if (strcmp(argv[3], "alog") == 0) { - if (!spffl::units::f2npolymod_find_generator(om, g)) { + if (!spffl::units::f2n_polymod_find_generator(om, g)) { std::cerr << "Couldn't find generator mod " << om << "\n"; exit(1); } @@ -121,16 +121,16 @@ int f2npmtbl_main(int argc, char **argv, usage_t *pusage) { tvector elts; if ((tbl_type == TBL_TYPE_UNIT_MUL) || (tbl_type == TBL_TYPE_UNIT_DIV) || (tbl_type == TBL_TYPE_LOG) || (tbl_type == TBL_TYPE_ALOG)) - elts = f2npolymod_list(om, spffl::list::SP_LIST_UNITS); + elts = f2n_polymod_list(om, spffl::list::SP_LIST_UNITS); else - elts = f2npolymod_list(om, spffl::list::SP_LIST_ALL); + elts = f2n_polymod_list(om, spffl::list::SP_LIST_ALL); int n = elts.get_num_elements(); if (tbl_type == TBL_TYPE_LOG) { std::cout << "element power\n"; std::cout << "------- -----\n"; for (int i = 0; i < n; i++) { - int e = spffl::units::f2npolymod_log(g, elts[i]); + int e = spffl::units::f2n_polymod_log(g, elts[i]); std::cout << elts[i] << " " << e << "\n"; } return 0; @@ -179,12 +179,12 @@ int f2npmtbl_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2npmord_usage(char *argv0) { +void f2n_pm_ord_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {im} {om} {a}\n"; exit(1); } -int f2npmord_main(int argc, char **argv, usage_t *pusage) { +int f2n_pm_ord_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t im; spffl::polynomials::f2n_poly_t om; spffl::polynomials::f2n_polymod_t a; @@ -199,17 +199,17 @@ int f2npmord_main(int argc, char **argv, usage_t *pusage) { pusage(argv[0]); if (argc > 4) std::cout << a << ": "; - std::cout << spffl::units::f2npolymod_order(a) << "\n"; + std::cout << spffl::units::f2n_polymod_order(a) << "\n"; } return 0; } -void f2npmfindgen_usage(char *argv0) { +void f2n_pm_find_gen_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {im} {om}\n"; exit(1); } -int f2npmfindgen_main(int argc, char **argv, usage_t *pusage) { +int f2n_pm_find_gen_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t im; spffl::polynomials::f2n_poly_t om; spffl::polynomials::f2n_polymod_t g; @@ -223,7 +223,7 @@ int f2npmfindgen_main(int argc, char **argv, usage_t *pusage) { pusage(argv[0]); if (argc > 3) std::cout << om << ": "; - if (spffl::units::f2npolymod_find_generator(om, g)) { + if (spffl::units::f2n_polymod_find_generator(om, g)) { std::cout << g << "\n"; } else { std::cout << "Generator not found.\n"; @@ -233,12 +233,12 @@ int f2npmfindgen_main(int argc, char **argv, usage_t *pusage) { return rv; } -void f2npmlog_usage(char *argv0) { +void f2n_pm_log_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {im} {om} {g} {a}\n"; exit(1); } -int f2npmlog_main(int argc, char **argv, usage_t *pusage) { +int f2n_pm_log_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t im; spffl::polynomials::f2n_poly_t om; spffl::polynomials::f2n_polymod_t g, a; @@ -255,17 +255,17 @@ int f2npmlog_main(int argc, char **argv, usage_t *pusage) { pusage(argv[0]); if (argc > 5) std::cout << a << ": "; - std::cout << spffl::units::f2npolymod_log(g, a) << "\n"; + std::cout << spffl::units::f2n_polymod_log(g, a) << "\n"; } return 0; } -void f2npmchpol_usage(char *argv0) { +void f2n_pm_ch_pol_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {im} {m} {residues ...}\n"; exit(1); } -int f2npmchpol_main(int argc, char **argv, usage_t *pusage) { +int f2n_pm_ch_pol_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t im; spffl::polynomials::f2n_poly_t m; spffl::polynomials::f2n_polymod_t a; @@ -288,12 +288,12 @@ int f2npmchpol_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2npmminpol_usage(char *argv0) { +void f2n_pm_min_pol_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {im} {m} {residues ...}\n"; exit(1); } -int f2npmminpol_main(int argc, char **argv, usage_t *pusage) { +int f2n_pm_min_pol_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t im; spffl::polynomials::f2n_poly_t m; spffl::polynomials::f2n_polymod_t a; @@ -316,12 +316,12 @@ int f2npmminpol_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2npmrandom_usage(char *argv0) { +void f2n_pm_random_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {inner m} {outer m} [count]\n"; exit(1); } -int f2npmrandom_main(int argc, char **argv, usage_t *pusage) { +int f2n_pm_random_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t im; spffl::polynomials::f2n_poly_t om; int count = 1; @@ -343,12 +343,12 @@ int f2npmrandom_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2npmmatop_usage(char *argv0) { +void f2n_pm_mat_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {inner m} {outer m} {...}\n"; exit(1); } -int f2npmmatop_main(int argc, char **argv, usage_t *pusage) { +int f2n_pm_mat_op_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t im; spffl::polynomials::f2n_poly_t om; if (argc < 3) @@ -366,12 +366,12 @@ int f2npmmatop_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2npmvecop_usage(char *argv0) { +void f2n_pm_vec_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {inner m} {outer m} {...}\n"; exit(1); } -int f2npmvecop_main(int argc, char **argv, usage_t *pusage) { +int f2n_pm_vec_op_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t im; spffl::polynomials::f2n_poly_t om; if (argc < 3) @@ -389,12 +389,12 @@ int f2npmvecop_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2npmmatrandom_usage(char *argv0) { +void f2n_pm_mat_random_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {inner m} {outer m} {# rows} {# cols}\n"; exit(1); } -int f2npmmatrandom_main(int argc, char **argv, usage_t *pusage) { +int f2n_pm_mat_random_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t im; spffl::polynomials::f2n_poly_t om; int nr, nc; diff --git a/cli/spiff/f2n_polymod_handlers.h b/cli/spiff/f2n_polymod_handlers.h index 9de861c..30c5865 100644 --- a/cli/spiff/f2n_polymod_handlers.h +++ b/cli/spiff/f2n_polymod_handlers.h @@ -3,40 +3,40 @@ #include "handlers.h" -void f2npmlist_usage(char *argv0); -int f2npmlist_main(int argc, char **argv, usage_t *pusage); +void f2n_pm_list_usage(char *argv0); +int f2n_pm_list_main(int argc, char **argv, usage_t *pusage); -void f2npmop_usage(char *argv0); -int f2npmop_main(int argc, char **argv, usage_t *pusage); +void f2n_pm_op_usage(char *argv0); +int f2n_pm_op_main(int argc, char **argv, usage_t *pusage); -void f2npmtbl_usage(char *argv0); -int f2npmtbl_main(int argc, char **argv, usage_t *pusage); +void f2n_pm_tbl_usage(char *argv0); +int f2n_pm_tbl_main(int argc, char **argv, usage_t *pusage); -void f2npmord_usage(char *argv0); -int f2npmord_main(int argc, char **argv, usage_t *pusage); +void f2n_pm_ord_usage(char *argv0); +int f2n_pm_ord_main(int argc, char **argv, usage_t *pusage); -void f2npmfindgen_usage(char *argv0); -int f2npmfindgen_main(int argc, char **argv, usage_t *pusage); +void f2n_pm_find_gen_usage(char *argv0); +int f2n_pm_find_gen_main(int argc, char **argv, usage_t *pusage); -void f2npmlog_usage(char *argv0); -int f2npmlog_main(int argc, char **argv, usage_t *pusage); +void f2n_pm_log_usage(char *argv0); +int f2n_pm_log_main(int argc, char **argv, usage_t *pusage); -void f2npmchpol_usage(char *argv0); -int f2npmchpol_main(int argc, char **argv, usage_t *pusage); +void f2n_pm_ch_pol_usage(char *argv0); +int f2n_pm_ch_pol_main(int argc, char **argv, usage_t *pusage); -void f2npmminpol_usage(char *argv0); -int f2npmminpol_main(int argc, char **argv, usage_t *pusage); +void f2n_pm_min_pol_usage(char *argv0); +int f2n_pm_min_pol_main(int argc, char **argv, usage_t *pusage); -void f2npmrandom_usage(char *argv0); -int f2npmrandom_main(int argc, char **argv, usage_t *pusage); +void f2n_pm_random_usage(char *argv0); +int f2n_pm_random_main(int argc, char **argv, usage_t *pusage); -void f2npmmatop_usage(char *argv0); -int f2npmmatop_main(int argc, char **argv, usage_t *pusage); +void f2n_pm_mat_op_usage(char *argv0); +int f2n_pm_mat_op_main(int argc, char **argv, usage_t *pusage); -void f2npmvecop_usage(char *argv0); -int f2npmvecop_main(int argc, char **argv, usage_t *pusage); +void f2n_pm_vec_op_usage(char *argv0); +int f2n_pm_vec_op_main(int argc, char **argv, usage_t *pusage); -void f2npmmatrandom_usage(char *argv0); -int f2npmmatrandom_main(int argc, char **argv, usage_t *pusage); +void f2n_pm_mat_random_usage(char *argv0); +int f2n_pm_mat_random_main(int argc, char **argv, usage_t *pusage); #endif // F2NPOLYMOD_HANDLERS_H diff --git a/cli/spiff/f2n_polyrat_handlers.cpp b/cli/spiff/f2n_polyrat_handlers.cpp index 0dfdf88..3a9c3ec 100644 --- a/cli/spiff/f2n_polyrat_handlers.cpp +++ b/cli/spiff/f2n_polyrat_handlers.cpp @@ -4,11 +4,11 @@ #include "cmd_line_vector_ops.h" #include "f2n_polyrat_t.h" -void f2nprop_usage(char *argv0) { +void f2n_pr_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} {...}\n"; exit(1); } -int f2nprop_main(int argc, char **argv, usage_t *pusage) { +int f2n_pr_op_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; if (argc < 2) pusage(argv[0]); @@ -23,12 +23,12 @@ int f2nprop_main(int argc, char **argv, usage_t *pusage) { return 0; } -void f2nprmatop_usage(char *argv0) { +void f2n_pr_mat_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {inner m} {...}\n"; exit(1); } -int f2nprmatop_main(int argc, char **argv, usage_t *pusage) { +int f2n_pr_mat_op_main(int argc, char **argv, usage_t *pusage) { spffl::polynomials::f2_poly_t m; if (argc < 2) pusage(argv[0]); diff --git a/cli/spiff/f2n_polyrat_handlers.h b/cli/spiff/f2n_polyrat_handlers.h index 3e6278c..2cb9e5d 100644 --- a/cli/spiff/f2n_polyrat_handlers.h +++ b/cli/spiff/f2n_polyrat_handlers.h @@ -3,10 +3,10 @@ #include "handlers.h" -void f2nprop_usage(char *argv0); -int f2nprop_main(int argc, char **argv, usage_t *pusage); +void f2n_pr_op_usage(char *argv0); +int f2n_pr_op_main(int argc, char **argv, usage_t *pusage); -void f2nprmatop_usage(char *argv0); -int f2nprmatop_main(int argc, char **argv, usage_t *pusage); +void f2n_pr_mat_op_usage(char *argv0); +int f2n_pr_mat_op_main(int argc, char **argv, usage_t *pusage); #endif // F2NPOLYRAT_HANDLERS_H diff --git a/cli/spiff/fp_handlers.cpp b/cli/spiff/fp_handlers.cpp index 14f9d07..7b4b6ed 100644 --- a/cli/spiff/fp_handlers.cpp +++ b/cli/spiff/fp_handlers.cpp @@ -11,12 +11,12 @@ #include "tmatrix.h" #include -void fplist_usage(char *argv0) { +void fp_list_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " [-a|-u] {p}\n"; exit(1); } -int fplist_main(int argc, char **argv, usage_t *pusage) { +int fp_list_main(int argc, char **argv, usage_t *pusage) { spffl::list::sp_list_type_t type = spffl::list::SP_LIST_ALL; int m; // -g @@ -53,12 +53,12 @@ int fplist_main(int argc, char **argv, usage_t *pusage) { } return 0; } -void fpop_usage(char *argv0) { +void fp_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {...}\n"; exit(1); } -int fpop_main(int argc, char **argv, usage_t *pusage) { +int fp_op_main(int argc, char **argv, usage_t *pusage) { int p; if (argc < 2) pusage(argv[0]); @@ -70,12 +70,12 @@ int fpop_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fptbl_usage(char *argv0) { +void fp_tbl_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {+|-|*|u*|/|log[:g]|alog[:g]}\n"; exit(1); } -int fptbl_main(int argc, char **argv, usage_t *pusage) { +int fp_tbl_main(int argc, char **argv, usage_t *pusage) { int p; int tbl_type = TBL_TYPE_PLUS; spffl::intmath::intmod_t g; @@ -184,12 +184,12 @@ int fptbl_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fpord_usage(char *argv0) { +void fp_ord_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {a}\n"; exit(1); } -int fpord_main(int argc, char **argv, usage_t *pusage) { +int fp_ord_main(int argc, char **argv, usage_t *pusage) { int p; spffl::intmath::intmod_t a; if (argc < 3) @@ -206,12 +206,12 @@ int fpord_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fpmaxord_usage(char *argv0) { +void fp_max_ord_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p}\n"; exit(1); } -int fpmaxord_main(int argc, char **argv, usage_t *pusage) { +int fp_max_ord_main(int argc, char **argv, usage_t *pusage) { int p; if (argc != 2) pusage(argv[0]); @@ -230,12 +230,12 @@ int fpmaxord_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fporbit_usage(char *argv0) { +void fp_orbit_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {a} [a0]\n"; exit(1); } -int fporbit_main(int argc, char **argv, usage_t *pusage) { +int fp_orbit_main(int argc, char **argv, usage_t *pusage) { int p, a, apower; int a0 = 1; if ((argc != 3) && (argc != 4)) @@ -249,7 +249,7 @@ int fporbit_main(int argc, char **argv, usage_t *pusage) { pusage(argv[0]); } if (gcd(a, p) != 1) { - std::cerr << "fporbit_main: a must be coprime to p.\n"; + std::cerr << "fp_orbit_main: a must be coprime to p.\n"; exit(1); } @@ -277,12 +277,12 @@ int fporbit_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fpfindgen_usage(char *argv0) { +void fp_find_gen_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p}\n"; exit(1); } -int fpfindgen_main(int argc, char **argv, usage_t *pusage) { +int fp_find_gen_main(int argc, char **argv, usage_t *pusage) { int p; spffl::intmath::intmod_t g; int rv = 0; @@ -303,12 +303,12 @@ int fpfindgen_main(int argc, char **argv, usage_t *pusage) { return rv; } -void fplog_usage(char *argv0) { +void fp_log_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {g} {a}\n"; exit(1); } -int fplog_main(int argc, char **argv, usage_t *pusage) { +int fp_log_main(int argc, char **argv, usage_t *pusage) { int p; spffl::intmath::intmod_t g, a; if (argc < 4) @@ -327,12 +327,12 @@ int fplog_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fprandom_usage(char *argv0) { +void fp_random_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {m} [count]\n"; exit(1); } -int fprandom_main(int argc, char **argv, usage_t *pusage) { +int fp_random_main(int argc, char **argv, usage_t *pusage) { int m, count = 1; if ((argc != 2) && (argc != 3)) @@ -350,12 +350,12 @@ int fprandom_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fpmatop_usage(char *argv0) { +void fp_mat_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {goes here}\n"; exit(1); } -int fpmatop_main(int argc, char **argv, usage_t *pusage) { +int fp_mat_op_main(int argc, char **argv, usage_t *pusage) { int p = 0; if (argc < 2) pusage(argv[0]); @@ -367,12 +367,12 @@ int fpmatop_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fpvecop_usage(char *argv0) { +void fp_vec_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {goes here}\n"; exit(1); } -int fpvecop_main(int argc, char **argv, usage_t *pusage) { +int fp_vec_op_main(int argc, char **argv, usage_t *pusage) { int p = 0; if (argc < 2) pusage(argv[0]); @@ -384,12 +384,12 @@ int fpvecop_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fpmatchpol_usage(char *argv0) { +void fp_mat_ch_pol_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {goes here}\n"; exit(1); } -int fpmatchpol_main(int argc, char **argv, usage_t *pusage) { +int fp_mat_ch_pol_main(int argc, char **argv, usage_t *pusage) { int p; tmatrix A; @@ -407,12 +407,12 @@ int fpmatchpol_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fpmatord_usage(char *argv0) { +void fp_mat_ord_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {goes here}\n"; exit(1); } -int fpmatord_main(int argc, char **argv, usage_t *pusage) { +int fp_mat_ord_main(int argc, char **argv, usage_t *pusage) { int p; tmatrix A; @@ -449,12 +449,12 @@ int fpmatord_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fpmatrandom_usage(char *argv0) { +void fp_mat_random_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {# rows} {# cols}\n"; exit(1); } -int fpmatrandom_main(int argc, char **argv, usage_t *pusage) { +int fp_mat_random_main(int argc, char **argv, usage_t *pusage) { int p, nr, nc; if (argc != 4) diff --git a/cli/spiff/fp_handlers.h b/cli/spiff/fp_handlers.h index 1be998e..4b9aaab 100644 --- a/cli/spiff/fp_handlers.h +++ b/cli/spiff/fp_handlers.h @@ -3,46 +3,46 @@ #include "handlers.h" -void fplist_usage(char *argv0); -int fplist_main(int argc, char **argv, usage_t *pusage); +void fp_list_usage(char *argv0); +int fp_list_main(int argc, char **argv, usage_t *pusage); -void fpop_usage(char *argv0); -int fpop_main(int argc, char **argv, usage_t *pusage); +void fp_op_usage(char *argv0); +int fp_op_main(int argc, char **argv, usage_t *pusage); -void fptbl_usage(char *argv0); -int fptbl_main(int argc, char **argv, usage_t *pusage); +void fp_tbl_usage(char *argv0); +int fp_tbl_main(int argc, char **argv, usage_t *pusage); -void fpord_usage(char *argv0); -int fpord_main(int argc, char **argv, usage_t *pusage); +void fp_ord_usage(char *argv0); +int fp_ord_main(int argc, char **argv, usage_t *pusage); -void fpmaxord_usage(char *argv0); -int fpmaxord_main(int argc, char **argv, usage_t *pusage); +void fp_max_ord_usage(char *argv0); +int fp_max_ord_main(int argc, char **argv, usage_t *pusage); -void fporbit_usage(char *argv0); -int fporbit_main(int argc, char **argv, usage_t *pusage); +void fp_orbit_usage(char *argv0); +int fp_orbit_main(int argc, char **argv, usage_t *pusage); -void fpfindgen_usage(char *argv0); -int fpfindgen_main(int argc, char **argv, usage_t *pusage); +void fp_find_gen_usage(char *argv0); +int fp_find_gen_main(int argc, char **argv, usage_t *pusage); -void fplog_usage(char *argv0); -int fplog_main(int argc, char **argv, usage_t *pusage); +void fp_log_usage(char *argv0); +int fp_log_main(int argc, char **argv, usage_t *pusage); -void fprandom_usage(char *argv0); -int fprandom_main(int argc, char **argv, usage_t *pusage); +void fp_random_usage(char *argv0); +int fp_random_main(int argc, char **argv, usage_t *pusage); -void fpmatop_usage(char *argv0); -int fpmatop_main(int argc, char **argv, usage_t *pusage); +void fp_mat_op_usage(char *argv0); +int fp_mat_op_main(int argc, char **argv, usage_t *pusage); -void fpvecop_usage(char *argv0); -int fpvecop_main(int argc, char **argv, usage_t *pusage); +void fp_vec_op_usage(char *argv0); +int fp_vec_op_main(int argc, char **argv, usage_t *pusage); -void fpmatchpol_usage(char *argv0); -int fpmatchpol_main(int argc, char **argv, usage_t *pusage); +void fp_mat_ch_pol_usage(char *argv0); +int fp_mat_ch_pol_main(int argc, char **argv, usage_t *pusage); -void fpmatord_usage(char *argv0); -int fpmatord_main(int argc, char **argv, usage_t *pusage); +void fp_mat_ord_usage(char *argv0); +int fp_mat_ord_main(int argc, char **argv, usage_t *pusage); -void fpmatrandom_usage(char *argv0); -int fpmatrandom_main(int argc, char **argv, usage_t *pusage); +void fp_mat_random_usage(char *argv0); +int fp_mat_random_main(int argc, char **argv, usage_t *pusage); #endif // FP_HANDLERS_H diff --git a/cli/spiff/fp_poly_handlers.cpp b/cli/spiff/fp_poly_handlers.cpp index 650009f..ea236af 100644 --- a/cli/spiff/fp_poly_handlers.cpp +++ b/cli/spiff/fp_poly_handlers.cpp @@ -11,12 +11,12 @@ #include "qff.h" #include -void fpplist_usage(char *argv0) { +void fp_p_list_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {deglo[-deghi]}\n"; exit(1); } -int fpplist_main(int argc, char **argv, usage_t *pusage) { +int fp_p_list_main(int argc, char **argv, usage_t *pusage) { int p, deglo, deghi; if (argc != 3) pusage(argv[0]); @@ -30,18 +30,18 @@ int fpplist_main(int argc, char **argv, usage_t *pusage) { pusage(argv[0]); for (int deg = deglo; deg <= deghi; deg++) { tvector elts = - spffl::list::fppoly_list(p, deg); + spffl::list::fp_poly_list(p, deg); elts.crout(std::cout); } return 0; } -void fppop_usage(char *argv0) { +void fp_p_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {polys ...}\n"; exit(1); } -int fppop_main(int argc, char **argv, usage_t *pusage) { +int fp_p_op_main(int argc, char **argv, usage_t *pusage) { int p; if (argc < 2) pusage(argv[0]); @@ -53,12 +53,12 @@ int fppop_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fppmatop_usage(char *argv0) { +void fp_p_mat_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {polys ...}\n"; exit(1); } -int fppmatop_main(int argc, char **argv, usage_t *pusage) { +int fp_p_mat_op_main(int argc, char **argv, usage_t *pusage) { int p; if (argc < 2) pusage(argv[0]); @@ -70,12 +70,12 @@ int fppmatop_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fppcompmx_usage(char *argv0) { +void fp_p_comp_mx_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {poly}\n"; exit(1); } -int fppcompmx_main(int argc, char **argv, usage_t *pusage) { +int fp_p_comp_mx_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t chpol; @@ -93,12 +93,12 @@ int fppcompmx_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fppdeg_usage(char *argv0) { +void fp_p_deg_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {polys ...}\n"; exit(1); } -int fppdeg_main(int argc, char **argv, usage_t *pusage) { +int fp_p_deg_main(int argc, char **argv, usage_t *pusage) { int p; if (argc < 2) pusage(argv[0]); @@ -116,12 +116,12 @@ int fppdeg_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fppgcd_usage(char *argv0) { +void fp_p_gcd_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} [-e] {a} {b}\n"; exit(1); } -int fppgcd_main(int argc, char **argv, usage_t *pusage) { +int fp_p_gcd_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t a, b, g, r, s; @@ -153,12 +153,12 @@ int fppgcd_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fpplcm_usage(char *argv0) { +void fp_p_lcm_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {polys ...}\n"; exit(1); } -int fpplcm_main(int argc, char **argv, usage_t *pusage) { +int fp_p_lcm_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t a, l; @@ -178,12 +178,12 @@ int fpplcm_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fpptotient_usage(char *argv0) { +void fp_p_totient_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {polys ...}\n"; exit(1); } -int fpptotient_main(int argc, char **argv, usage_t *pusage) { +int fp_p_totient_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t a; int phi; @@ -202,12 +202,12 @@ int fpptotient_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fpptest_usage(char *argv0) { +void fp_p_test_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {polys ...}\n"; exit(1); } -int fpptest_main(int argc, char **argv, usage_t *pusage) { +int fp_p_test_main(int argc, char **argv, usage_t *pusage) { int p; if (argc < 2) pusage(argv[0]); @@ -220,7 +220,7 @@ int fpptest_main(int argc, char **argv, usage_t *pusage) { pusage(argv[0]); if (argc > 3) std::cout << a << ": "; - if (spffl::factorization::fppoly_is_irreducible(a)) + if (spffl::factorization::fp_poly_is_irreducible(a)) std::cout << "IRREDUCIBLE\n"; else std::cout << "reducible\n"; @@ -228,12 +228,12 @@ int fpptest_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fppfind_usage(char *argv0) { +void fp_p_find_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " [-1|-r] {p} {deglo[-deghi]}\n"; exit(1); } -int fppfind_main(int argc, char **argv, usage_t *pusage) { +int fp_p_find_main(int argc, char **argv, usage_t *pusage) { bool do_random = false; int deglo, deghi; int p; @@ -259,20 +259,20 @@ int fppfind_main(int argc, char **argv, usage_t *pusage) { for (int deg = deglo; deg <= deghi; deg++) { spffl::polynomials::fp_poly_t a; if (do_random) - a = spffl::factorization::fppoly_random_irr(p, deg); + a = spffl::factorization::fp_poly_random_irr(p, deg); else - a = spffl::factorization::fppoly_find_irr(p, deg); + a = spffl::factorization::fp_poly_find_irr(p, deg); std::cout << a << "\n"; } return 0; } -void fppfactor_usage(char *argv0) { +void fp_p_factor_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {polys ...}\n"; exit(1); } -int fppfactor_main(int argc, char **argv, usage_t *pusage) { +int fp_p_factor_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t a; @@ -303,12 +303,12 @@ int fppfactor_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fppdivisors_usage(char *argv0) { +void fp_p_divisors_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " [-mp] {p} {polys ...}\n"; exit(1); } -int fppdivisors_main(int argc, char **argv, usage_t *pusage) { +int fp_p_divisors_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t a; int argb = 1; @@ -350,12 +350,12 @@ int fppdivisors_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fppeval_usage(char *argv0) { +void fp_p_eval_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {f} {elements of Fp ...}\n"; exit(1); } -int fppeval_main(int argc, char **argv, usage_t *pusage) { +int fp_p_eval_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t f; spffl::intmath::intmod_t a, b; @@ -376,12 +376,12 @@ int fppeval_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fpprandom_usage(char *argv0) { +void fp_p_random_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {deg} [count]\n"; exit(1); } -int fpprandom_main(int argc, char **argv, usage_t *pusage) { +int fp_p_random_main(int argc, char **argv, usage_t *pusage) { int p, deg, count = 1; if ((argc != 3) && (argc != 4)) @@ -401,12 +401,12 @@ int fpprandom_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fppqp_usage(char *argv0) { +void fp_p_qp_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {qpolys ...}\n"; exit(1); } -int fppqp_main(int argc, char **argv, usage_t *pusage) { +int fp_p_qp_main(int argc, char **argv, usage_t *pusage) { int p; spffl::rationals::qpoly_t qp; spffl::polynomials::fp_poly_t fpp; @@ -417,7 +417,7 @@ int fppqp_main(int argc, char **argv, usage_t *pusage) { for (int argi = 2; argi < argc; argi++) { if (!qp.from_string(argv[argi])) pusage(argv[0]); - fpp = spffl::qcyclo::fppoly_from_qpoly(qp, p); + fpp = spffl::q_cyclo::fp_poly_from_qpoly(qp, p); std::cout << fpp << "\n"; } return 0; diff --git a/cli/spiff/fp_poly_handlers.h b/cli/spiff/fp_poly_handlers.h index 6487a27..d58c1cb 100644 --- a/cli/spiff/fp_poly_handlers.h +++ b/cli/spiff/fp_poly_handlers.h @@ -3,49 +3,49 @@ #include "handlers.h" -void fpplist_usage(char *argv0); -int fpplist_main(int argc, char **argv, usage_t *pusage); +void fp_p_list_usage(char *argv0); +int fp_p_list_main(int argc, char **argv, usage_t *pusage); -void fppop_usage(char *argv0); -int fppop_main(int argc, char **argv, usage_t *pusage); +void fp_p_op_usage(char *argv0); +int fp_p_op_main(int argc, char **argv, usage_t *pusage); -void fppmatop_usage(char *argv0); -int fppmatop_main(int argc, char **argv, usage_t *pusage); +void fp_p_mat_op_usage(char *argv0); +int fp_p_mat_op_main(int argc, char **argv, usage_t *pusage); -void fppcompmx_usage(char *argv0); -int fppcompmx_main(int argc, char **argv, usage_t *pusage); +void fp_p_comp_mx_usage(char *argv0); +int fp_p_comp_mx_main(int argc, char **argv, usage_t *pusage); -void fppdeg_usage(char *argv0); -int fppdeg_main(int argc, char **argv, usage_t *pusage); +void fp_p_deg_usage(char *argv0); +int fp_p_deg_main(int argc, char **argv, usage_t *pusage); -void fppgcd_usage(char *argv0); -int fppgcd_main(int argc, char **argv, usage_t *pusage); +void fp_p_gcd_usage(char *argv0); +int fp_p_gcd_main(int argc, char **argv, usage_t *pusage); -void fpplcm_usage(char *argv0); -int fpplcm_main(int argc, char **argv, usage_t *pusage); +void fp_p_lcm_usage(char *argv0); +int fp_p_lcm_main(int argc, char **argv, usage_t *pusage); -void fpptotient_usage(char *argv0); -int fpptotient_main(int argc, char **argv, usage_t *pusage); +void fp_p_totient_usage(char *argv0); +int fp_p_totient_main(int argc, char **argv, usage_t *pusage); -void fpptest_usage(char *argv0); -int fpptest_main(int argc, char **argv, usage_t *pusage); +void fp_p_test_usage(char *argv0); +int fp_p_test_main(int argc, char **argv, usage_t *pusage); -void fppfind_usage(char *argv0); -int fppfind_main(int argc, char **argv, usage_t *pusage); +void fp_p_find_usage(char *argv0); +int fp_p_find_main(int argc, char **argv, usage_t *pusage); -void fppfactor_usage(char *argv0); -int fppfactor_main(int argc, char **argv, usage_t *pusage); +void fp_p_factor_usage(char *argv0); +int fp_p_factor_main(int argc, char **argv, usage_t *pusage); -void fppdivisors_usage(char *argv0); -int fppdivisors_main(int argc, char **argv, usage_t *pusage); +void fp_p_divisors_usage(char *argv0); +int fp_p_divisors_main(int argc, char **argv, usage_t *pusage); -void fppeval_usage(char *argv0); -int fppeval_main(int argc, char **argv, usage_t *pusage); +void fp_p_eval_usage(char *argv0); +int fp_p_eval_main(int argc, char **argv, usage_t *pusage); -void fpprandom_usage(char *argv0); -int fpprandom_main(int argc, char **argv, usage_t *pusage); +void fp_p_random_usage(char *argv0); +int fp_p_random_main(int argc, char **argv, usage_t *pusage); -void fppqp_usage(char *argv0); -int fppqp_main(int argc, char **argv, usage_t *pusage); +void fp_p_qp_usage(char *argv0); +int fp_p_qp_main(int argc, char **argv, usage_t *pusage); #endif // FPPOLY_HANDLERS_H diff --git a/cli/spiff/fp_polymod_handlers.cpp b/cli/spiff/fp_polymod_handlers.cpp index a0b4d1f..e938d08 100644 --- a/cli/spiff/fp_polymod_handlers.cpp +++ b/cli/spiff/fp_polymod_handlers.cpp @@ -10,12 +10,12 @@ #include "min_char_polys.h" #include "tbl_types.h" -void fppmlist_usage(char *argv0) { +void fp_pm_list_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " [-a|-u] {p} {m}\n"; exit(1); } -int fppmlist_main(int argc, char **argv, usage_t *pusage) { +int fp_pm_list_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t m; spffl::list::sp_list_type_t type = spffl::list::SP_LIST_ALL; @@ -33,17 +33,17 @@ int fppmlist_main(int argc, char **argv, usage_t *pusage) { pusage(argv[0]); if (!m.from_string(argv[3], p)) pusage(argv[0]); - tvector elts = fppolymod_list(m, type); + tvector elts = fp_polymod_list(m, type); elts.crout(std::cout); return 0; } -void fppmop_usage(char *argv0) { +void fp_pm_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {m} {...}\n"; exit(1); } -int fppmop_main(int argc, char **argv, usage_t *pusage) { +int fp_pm_op_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t m; @@ -60,12 +60,12 @@ int fppmop_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fppmtbl_usage(char *argv0) { +void fp_pm_tbl_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {m} {+|-|*|u*|/}\n"; exit(1); } -int fppmtbl_main(int argc, char **argv, usage_t *pusage) { +int fp_pm_tbl_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t m; spffl::polynomials::fp_polymod_t g; @@ -100,7 +100,7 @@ int fppmtbl_main(int argc, char **argv, usage_t *pusage) { tbl_type = TBL_TYPE_LOG; } else if (strcmp(argv[3], "log") == 0) { - if (!fppolymod_find_generator(m, g)) { + if (!fp_polymod_find_generator(m, g)) { std::cerr << "Couldn't find generator mod " << m << "\n"; exit(1); @@ -113,7 +113,7 @@ int fppmtbl_main(int argc, char **argv, usage_t *pusage) { tbl_type = TBL_TYPE_ALOG; } else if (strcmp(argv[3], "alog") == 0) { - if (!fppolymod_find_generator(m, g)) { + if (!fp_polymod_find_generator(m, g)) { std::cerr << "Couldn't find generator mod " << m << "\n"; exit(1); @@ -127,9 +127,9 @@ int fppmtbl_main(int argc, char **argv, usage_t *pusage) { tvector elts; if ((tbl_type == TBL_TYPE_UNIT_MUL) || (tbl_type == TBL_TYPE_UNIT_DIV) || (tbl_type == TBL_TYPE_LOG) || (tbl_type == TBL_TYPE_ALOG)) - elts = fppolymod_list(m, spffl::list::SP_LIST_UNITS); + elts = fp_polymod_list(m, spffl::list::SP_LIST_UNITS); else - elts = fppolymod_list(m, spffl::list::SP_LIST_ALL); + elts = fp_polymod_list(m, spffl::list::SP_LIST_ALL); int n = elts.get_num_elements(); #if 0 @@ -137,7 +137,7 @@ int fppmtbl_main(int argc, char **argv, usage_t *pusage) { std::cout << "element power\n"; std::cout << "------- -----\n"; for (int i = 0; i < n; i++) { - int e = fppolymod_log(g, elts[i]); + int e = fp_polymod_log(g, elts[i]); std::cout << elts[i] << " " << e << "\n"; } return 0; @@ -187,7 +187,7 @@ int fppmtbl_main(int argc, char **argv, usage_t *pusage) { return 0; } -int fppmmatop_main(int argc, char **argv, usage_t *pusage) { +int fp_pm_mat_op_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t m; @@ -204,7 +204,7 @@ int fppmmatop_main(int argc, char **argv, usage_t *pusage) { return 0; } -int fppmvecop_main(int argc, char **argv, usage_t *pusage) { +int fp_pm_vecop_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t m; @@ -221,12 +221,12 @@ int fppmvecop_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fppmmatord_usage(char *argv0) { +void fp_pm_mat_ord_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {m} {goes here}\n"; exit(1); } -int fppmmatord_main(int argc, char **argv, usage_t *pusage) { +int fp_pm_mat_ord_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t m; @@ -269,12 +269,12 @@ int fppmmatord_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fppmmatrandom_usage(char *argv0) { +void fp_pm_mat_random_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {m} {# rows} {# cols}\n"; exit(1); } -int fppmmatrandom_main(int argc, char **argv, usage_t *pusage) { +int fp_pm_mat_random_main(int argc, char **argv, usage_t *pusage) { int p, nr, nc; spffl::polynomials::fp_poly_t m; @@ -298,12 +298,12 @@ int fppmmatrandom_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fppmord_usage(char *argv0) { +void fp_pm_ord_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {m} {a}\n"; exit(1); } -int fppmord_main(int argc, char **argv, usage_t *pusage) { +int fp_pm_ord_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t m; spffl::polynomials::fp_polymod_t a; @@ -342,12 +342,12 @@ int fppmord_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fppmchpol_usage(char *argv0) { +void fp_pm_ch_pol_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {m} {residues ...}\n"; exit(1); } -int fppmchpol_main(int argc, char **argv, usage_t *pusage) { +int fp_pm_ch_pol_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t m; spffl::polynomials::fp_polymod_t a; @@ -370,12 +370,12 @@ int fppmchpol_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fppmminpol_usage(char *argv0) { +void fp_pm_min_pol_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {m} {residues ...}\n"; exit(1); } -int fppmminpol_main(int argc, char **argv, usage_t *pusage) { +int fp_pm_min_pol_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t m; spffl::polynomials::fp_polymod_t a; @@ -398,12 +398,12 @@ int fppmminpol_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fppmrandom_usage(char *argv0) { +void fp_pm_random_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {m} [count]\n"; exit(1); } -int fppmrandom_main(int argc, char **argv, usage_t *pusage) { +int fp_pm_random_main(int argc, char **argv, usage_t *pusage) { int p, count = 1; spffl::polynomials::fp_poly_t m; diff --git a/cli/spiff/fp_polymod_handlers.h b/cli/spiff/fp_polymod_handlers.h index 4924aab..4e3133e 100644 --- a/cli/spiff/fp_polymod_handlers.h +++ b/cli/spiff/fp_polymod_handlers.h @@ -3,35 +3,35 @@ #include "handlers.h" -void fppmlist_usage(char *argv0); -int fppmlist_main(int argc, char **argv, usage_t *pusage); +void fp_pm_list_usage(char *argv0); +int fp_pm_list_main(int argc, char **argv, usage_t *pusage); -void fppmop_usage(char *argv0); -int fppmop_main(int argc, char **argv, usage_t *pusage); +void fp_pm_op_usage(char *argv0); +int fp_pm_op_main(int argc, char **argv, usage_t *pusage); -void fppmtbl_usage(char *argv0); -int fppmtbl_main(int argc, char **argv, usage_t *pusage); +void fp_pm_tbl_usage(char *argv0); +int fp_pm_tbl_main(int argc, char **argv, usage_t *pusage); -int fppmmatop_main(int argc, char **argv, usage_t *pusage); +int fp_pm_mat_op_main(int argc, char **argv, usage_t *pusage); -int fppmvecop_main(int argc, char **argv, usage_t *pusage); +int fp_pm_vecop_main(int argc, char **argv, usage_t *pusage); -void fppmmatord_usage(char *argv0); -int fppmmatord_main(int argc, char **argv, usage_t *pusage); +void fp_pm_mat_ord_usage(char *argv0); +int fp_pm_mat_ord_main(int argc, char **argv, usage_t *pusage); -void fppmmatrandom_usage(char *argv0); -int fppmmatrandom_main(int argc, char **argv, usage_t *pusage); +void fp_pm_mat_random_usage(char *argv0); +int fp_pm_mat_random_main(int argc, char **argv, usage_t *pusage); -void fppmord_usage(char *argv0); -int fppmord_main(int argc, char **argv, usage_t *pusage); +void fp_pm_ord_usage(char *argv0); +int fp_pm_ord_main(int argc, char **argv, usage_t *pusage); -void fppmchpol_usage(char *argv0); -int fppmchpol_main(int argc, char **argv, usage_t *pusage); +void fp_pm_ch_pol_usage(char *argv0); +int fp_pm_ch_pol_main(int argc, char **argv, usage_t *pusage); -void fppmminpol_usage(char *argv0); -int fppmminpol_main(int argc, char **argv, usage_t *pusage); +void fp_pm_min_pol_usage(char *argv0); +int fp_pm_min_pol_main(int argc, char **argv, usage_t *pusage); -void fppmrandom_usage(char *argv0); -int fppmrandom_main(int argc, char **argv, usage_t *pusage); +void fp_pm_random_usage(char *argv0); +int fp_pm_random_main(int argc, char **argv, usage_t *pusage); #endif // FPPOLYMOD_HANDLERS_H diff --git a/cli/spiff/fp_polyrat_handlers.cpp b/cli/spiff/fp_polyrat_handlers.cpp index be3fd4a..f02bec8 100644 --- a/cli/spiff/fp_polyrat_handlers.cpp +++ b/cli/spiff/fp_polyrat_handlers.cpp @@ -4,12 +4,12 @@ #include "cmd_line_vector_ops.h" #include "fp_polyrat_t.h" -void fpprop_usage(char *argv0) { +void fp_pr_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {...}\n"; exit(1); } -int fpprop_main(int argc, char **argv, usage_t *pusage) { +int fp_pr_op_main(int argc, char **argv, usage_t *pusage) { int p; if (argc < 2) pusage(argv[0]); @@ -21,12 +21,12 @@ int fpprop_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fpprmatop_usage(char *argv0) { +void fp_pr_mat_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {...}\n"; exit(1); } -int fpprmatop_main(int argc, char **argv, usage_t *pusage) { +int fp_pr_mat_op_main(int argc, char **argv, usage_t *pusage) { int p; if (argc < 2) pusage(argv[0]); diff --git a/cli/spiff/fp_polyrat_handlers.h b/cli/spiff/fp_polyrat_handlers.h index 2f2f67e..0e8218f 100644 --- a/cli/spiff/fp_polyrat_handlers.h +++ b/cli/spiff/fp_polyrat_handlers.h @@ -3,10 +3,10 @@ #include "handlers.h" -void fpprop_usage(char *argv0); -int fpprop_main(int argc, char **argv, usage_t *pusage); +void fp_pr_op_usage(char *argv0); +int fp_pr_op_main(int argc, char **argv, usage_t *pusage); -void fpprmatop_usage(char *argv0); -int fpprmatop_main(int argc, char **argv, usage_t *pusage); +void fp_pr_mat_op_usage(char *argv0); +int fp_pr_mat_op_main(int argc, char **argv, usage_t *pusage); #endif // FPPOLYRAT_HANDLERS_H diff --git a/cli/spiff/fpn_poly_handlers.cpp b/cli/spiff/fpn_poly_handlers.cpp index 04811cb..e53d244 100644 --- a/cli/spiff/fpn_poly_handlers.cpp +++ b/cli/spiff/fpn_poly_handlers.cpp @@ -5,12 +5,12 @@ #include // ---------------------------------------------------------------- -void fpnpop_usage(char *argv0) { +void fpn_p_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {im} {...}\n"; exit(1); } -int fpnpop_main(int argc, char **argv, usage_t *pusage) { +int fpn_p_op_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t im; if (argc < 3) @@ -29,12 +29,12 @@ int fpnpop_main(int argc, char **argv, usage_t *pusage) { } // ---------------------------------------------------------------- -void fpnpmatop_usage(char *argv0) { +void fpn_p_mat_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {im} {...}\n"; exit(1); } -int fpnpmatop_main(int argc, char **argv, usage_t *pusage) { +int fpn_p_mat_op_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t im; if (argc < 3) @@ -52,12 +52,12 @@ int fpnpmatop_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fpnpgcd_usage(char *argv0) { +void fpn_p_gcd_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " [-e] {p} {im} {a} {b}\n"; exit(1); } -int fpnpgcd_main(int argc, char **argv, usage_t *pusage) { +int fpn_p_gcd_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t im; spffl::polynomials::fpn_poly_t a, b, g, r, s; @@ -94,12 +94,12 @@ int fpnpgcd_main(int argc, char **argv, usage_t *pusage) { return 0; } -void fpnpqp_usage(char *argv0) { +void fpn_p_qp_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {m} {qpolys ...}\n"; exit(1); } -int fpnpqp_main(int argc, char **argv, usage_t *pusage) { +int fpn_p_qp_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t m; spffl::rationals::qpoly_t qp; @@ -113,7 +113,7 @@ int fpnpqp_main(int argc, char **argv, usage_t *pusage) { for (int argi = 3; argi < argc; argi++) { if (!qp.from_string(argv[argi])) pusage(argv[0]); - fpnp = spffl::qcyclo::fpnpoly_from_qpoly(qp, m); + fpnp = spffl::q_cyclo::fpn_poly_from_qpoly(qp, m); std::cout << fpnp << "\n"; } return 0; diff --git a/cli/spiff/fpn_poly_handlers.h b/cli/spiff/fpn_poly_handlers.h index 79efe09..b34b6a1 100644 --- a/cli/spiff/fpn_poly_handlers.h +++ b/cli/spiff/fpn_poly_handlers.h @@ -3,16 +3,16 @@ #include "handlers.h" -void fpnpop_usage(char *argv0); -int fpnpop_main(int argc, char **argv, usage_t *pusage); +void fpn_p_op_usage(char *argv0); +int fpn_p_op_main(int argc, char **argv, usage_t *pusage); -void fpnpmatop_usage(char *argv0); -int fpnpmatop_main(int argc, char **argv, usage_t *pusage); +void fpn_p_mat_op_usage(char *argv0); +int fpn_p_mat_op_main(int argc, char **argv, usage_t *pusage); -void fpnpgcd_usage(char *argv0); -int fpnpgcd_main(int argc, char **argv, usage_t *pusage); +void fpn_p_gcd_usage(char *argv0); +int fpn_p_gcd_main(int argc, char **argv, usage_t *pusage); -void fpnpqp_usage(char *argv0); -int fpnpqp_main(int argc, char **argv, usage_t *pusage); +void fpn_p_qp_usage(char *argv0); +int fpn_p_qp_main(int argc, char **argv, usage_t *pusage); #endif // FPNPOLY_HANDLERS_H diff --git a/cli/spiff/fpn_polymod_handlers.cpp b/cli/spiff/fpn_polymod_handlers.cpp index c85ff54..816ef98 100644 --- a/cli/spiff/fpn_polymod_handlers.cpp +++ b/cli/spiff/fpn_polymod_handlers.cpp @@ -5,12 +5,12 @@ #include "fpn_polymod_t.h" // ---------------------------------------------------------------- -void fpnpmop_usage(char *argv0) { +void fpn_pm_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {im} {om} {...}\n"; exit(1); } -int fpnpmop_main(int argc, char **argv, usage_t *pusage) { +int fpn_pm_op_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t im; spffl::polynomials::fpn_poly_t om; @@ -32,12 +32,12 @@ int fpnpmop_main(int argc, char **argv, usage_t *pusage) { } // ---------------------------------------------------------------- -void fpnpmmatop_usage(char *argv0) { +void fpn_pm_mat_op_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {p} {im} {om} {...}\n"; exit(1); } -int fpnpmmatop_main(int argc, char **argv, usage_t *pusage) { +int fpn_pm_mat_op_main(int argc, char **argv, usage_t *pusage) { int p; spffl::polynomials::fp_poly_t im; spffl::polynomials::fpn_poly_t om; diff --git a/cli/spiff/fpn_polymod_handlers.h b/cli/spiff/fpn_polymod_handlers.h index cf4e55f..9e553c2 100644 --- a/cli/spiff/fpn_polymod_handlers.h +++ b/cli/spiff/fpn_polymod_handlers.h @@ -3,10 +3,10 @@ #include "handlers.h" -void fpnpmop_usage(char *argv0); -int fpnpmop_main(int argc, char **argv, usage_t *pusage); +void fpn_pm_op_usage(char *argv0); +int fpn_pm_op_main(int argc, char **argv, usage_t *pusage); -void fpnpmmatop_usage(char *argv0); -int fpnpmmatop_main(int argc, char **argv, usage_t *pusage); +void fpn_pm_mat_op_usage(char *argv0); +int fpn_pm_mat_op_main(int argc, char **argv, usage_t *pusage); #endif // FPNPOLYMOD_HANDLERS_H diff --git a/cli/spiff/q_handlers.cpp b/cli/spiff/q_handlers.cpp index c6e1a1e..9312ae1 100644 --- a/cli/spiff/q_handlers.cpp +++ b/cli/spiff/q_handlers.cpp @@ -5,33 +5,33 @@ #include "intrat_t.h" #include "qpoly_t.h" -int qop_main(int argc, char **argv, usage_t *pusage) { +int q_op_main(int argc, char **argv, usage_t *pusage) { spffl::cliparser::cmd_line_parse( argc - 1, argv + 1, spffl::rationals::intrat_t(0), spffl::rationals::intrat_t(1)); return 0; } -int qmatop_main(int argc, char **argv, usage_t *pusage) { +int q_mat_op_main(int argc, char **argv, usage_t *pusage) { spffl::cliparser::cmd_line_mat_parse( argc - 1, argv + 1, spffl::rationals::intrat_t(0), spffl::rationals::intrat_t(1)); return 0; } -int qvecop_main(int argc, char **argv, usage_t *pusage) { +int q_vec_op_main(int argc, char **argv, usage_t *pusage) { spffl::cliparser::cmd_line_vec_parse( argc - 1, argv + 1, spffl::rationals::intrat_t(0), spffl::rationals::intrat_t(1)); return 0; } -void qcyclo_usage(char *argv0) { +void q_cyclo_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {n}\n"; exit(1); } -int qpop_main(int argc, char **argv, usage_t *pusage) { +int q_p_op_main(int argc, char **argv, usage_t *pusage) { spffl::cliparser::cmd_line_parse( argc - 1, argv + 1, spffl::rationals::qpoly_t(spffl::rationals::intrat_t(0)), @@ -39,14 +39,14 @@ int qpop_main(int argc, char **argv, usage_t *pusage) { return 0; } -int qcyclo_main(int argc, char **argv, usage_t *pusage) { +int q_cyclo_main(int argc, char **argv, usage_t *pusage) { int n; if (argc < 2) pusage(argv[0]); for (int argi = 1; argi < argc; argi++) { if (sscanf(argv[argi], "%d", &n) != 1) pusage(argv[0]); - std::cout << spffl::qcyclo::get_cyclo_qpoly(n) << std::endl; + std::cout << spffl::q_cyclo::get_cyclo_qpoly(n) << std::endl; } return 0; } diff --git a/cli/spiff/q_handlers.h b/cli/spiff/q_handlers.h index 0606f05..44ac33c 100644 --- a/cli/spiff/q_handlers.h +++ b/cli/spiff/q_handlers.h @@ -3,15 +3,15 @@ #include "handlers.h" -int qop_main(int argc, char **argv, usage_t *pusage); +int q_op_main(int argc, char **argv, usage_t *pusage); -int qmatop_main(int argc, char **argv, usage_t *pusage); +int q_mat_op_main(int argc, char **argv, usage_t *pusage); -int qvecop_main(int argc, char **argv, usage_t *pusage); +int q_vec_op_main(int argc, char **argv, usage_t *pusage); -int qpop_main(int argc, char **argv, usage_t *pusage); +int q_p_op_main(int argc, char **argv, usage_t *pusage); -void qcyclo_usage(char *argv0); -int qcyclo_main(int argc, char **argv, usage_t *pusage); +void q_cyclo_usage(char *argv0); +int q_cyclo_main(int argc, char **argv, usage_t *pusage); #endif // Q_HANDLERS_H diff --git a/cli/spiff/spiff_main.cpp b/cli/spiff/spiff_main.cpp index d72667b..0a0e184 100644 --- a/cli/spiff/spiff_main.cpp +++ b/cli/spiff/spiff_main.cpp @@ -45,184 +45,184 @@ typedef struct _lookup_t { lookup_t lookups[] = { - {"zop", zop_main, 0 /*zop_usage*/}, - {"zgcd", zgcd_main, zgcd_usage}, - {"zlcm", zlcm_main, zlcm_usage}, - {"ztotient", ztotient_main, ztotient_usage}, - {"ztestprime", ztestprime_main, ztestprime_usage}, - {"spffl::intmath::nth_prime", nthprime_main, nthprime_usage}, - {"zlist", zlist_main, zlist_usage}, - {"zfactor", zfactor_main, zfactor_usage}, - {"zdivisors", zdivisors_main, zdivisors_usage}, - {"zmatop", zmatop_main, 0 /*zmatop_usage*/}, - - {"qop", qop_main, 0 /*qop_usage*/}, - {"qvecop", qvecop_main, 0 /*qvecop_usage*/}, - {"qmatop", qmatop_main, 0 /*qmatop_usage*/}, - - {"qcyclo", qcyclo_main, qcyclo_usage}, - {"qpop", qpop_main, 0 /*qcyclo_usage*/}, - - {"f2op", f2op_main, 0 /*f2op_usage*/}, - {"f2random", f2random_main, f2random_usage}, - - {"f2vecop", f2vecop_main, 0 /*f2vecop_usage*/}, - {"f2matop", f2matop_main, 0 /*f2matop_usage*/}, - {"f2matchpol", f2matchpol_main, f2matchpol_usage}, - {"f2matord", f2matord_main, f2matord_usage}, - {"f2matrandom", f2matrandom_main, f2matrandom_usage}, - - {"f2plist", f2plist_main, f2plist_usage}, - {"f2pop", f2pop_main, 0 /*f2pop_usage*/}, - {"f2pdeg", f2pdeg_main, f2pdeg_usage}, - {"f2pgcd", f2pgcd_main, f2pgcd_usage}, - {"f2plcm", f2plcm_main, f2plcm_usage}, - {"f2ptotient", f2ptotient_main, f2ptotient_usage}, - {"f2ptest", f2ptest_main, f2ptest_usage}, - {"f2pfind", f2pfind_main, f2pfind_usage}, - {"f2pperiod", f2pperiod_main, f2pperiod_usage}, - {"f2pfactor", f2pfactor_main, f2pfactor_usage}, - {"f2pdivisors", f2pdivisors_main, f2pdivisors_usage}, - {"f2peval", f2peval_main, f2peval_usage}, - {"f2prandom", f2prandom_main, f2prandom_usage}, - {"f2pqp", f2pqp_main, f2pqp_usage}, - {"f2pmatop", f2pmatop_main, 0 /*f2pmatop_usage*/}, - {"f2pcompmx", f2pcompmx_main, f2pcompmx_usage}, - - {"f2pmlist", f2pmlist_main, f2pmlist_usage}, - {"f2pmop", f2pmop_main, f2pmop_usage}, - {"f2pmtbl", f2pmtbl_main, f2pmtbl_usage}, - {"f2pmord", f2pmord_main, f2pmord_usage}, - {"f2pmfindgen", f2pmfindgen_main, f2pmfindgen_usage}, - {"f2pmlog", f2pmlog_main, f2pmlog_usage}, - {"f2pmchpol", f2pmchpol_main, f2pmchpol_usage}, - {"f2pmminpol", f2pmminpol_main, f2pmminpol_usage}, - {"f2pmconvert", f2pmconvert_main, f2pmconvert_usage}, - {"f2pmrandom", f2pmrandom_main, f2pmrandom_usage}, - - {"f2pmmatop", f2pmmatop_main, f2pmmatop_usage}, - {"f2pmvecop", f2pmvecop_main, f2pmvecop_usage}, - {"f2pmmatsolve", f2pmmatsolve_main, f2pmmatsolve_usage}, - {"f2pmmatchpol", f2pmmatchpol_main, f2pmmatchpol_usage}, - {"f2pmmatdable", f2pmmatdable_main, f2pmmatdable_usage}, - {"f2pmmatord", f2pmmatord_main, f2pmmatord_usage}, - {"f2pmmatrandom", f2pmmatrandom_main, f2pmmatrandom_usage}, - - {"f2prop", f2prop_main, 0 /*f2prop_usage*/}, - {"f2prrandom", f2prrandom_main, f2prrandom_usage}, - {"f2prmatop", f2prmatop_main, 0 /*f2prmatop_usage*/}, - {"f2prmatrandom", f2prmatrandom_main, f2prmatrandom_usage}, - - {"f2nplist", f2nplist_main, f2nplist_usage}, - {"f2npop", f2npop_main, f2npop_usage}, - {"f2npmatop", f2npmatop_main, f2npmatop_usage}, - {"f2npdeg", f2npdeg_main, f2npdeg_usage}, - {"f2npgcd", f2npgcd_main, f2npgcd_usage}, - {"f2nplcm", f2nplcm_main, f2nplcm_usage}, - {"f2nptotient", f2nptotient_main, f2nptotient_usage}, - {"f2nptest", f2nptest_main, f2nptest_usage}, - {"f2npfind", f2npfind_main, f2npfind_usage}, - {"f2npfactor", f2npfactor_main, f2npfactor_usage}, - {"f2npdivisors", f2npdivisors_main, f2npdivisors_usage}, - {"f2npeval", f2npeval_main, f2npeval_usage}, - {"f2nprandom", f2nprandom_main, f2nprandom_usage}, - {"f2npcompmx", f2npcompmx_main, f2npcompmx_usage}, - - {"f2npmlist", f2npmlist_main, f2npmlist_usage}, - {"f2npmop", f2npmop_main, f2npmop_usage}, - {"f2npmtbl", f2npmtbl_main, f2npmtbl_usage}, - {"f2npmord", f2npmord_main, f2npmord_usage}, - {"f2npmfindgen", f2npmfindgen_main, f2npmfindgen_usage}, - {"f2npmlog", f2npmlog_main, f2npmlog_usage}, - {"f2npmchpol", f2npmchpol_main, f2npmchpol_usage}, - {"f2npmminpol", f2npmminpol_main, f2npmminpol_usage}, - {"f2npmrandom", f2npmrandom_main, f2npmrandom_usage}, - {"f2npqp", f2npqp_main, f2npqp_usage}, - - {"f2npmmatop", f2npmmatop_main, f2npmmatop_usage}, - {"f2npmvecop", f2npmvecop_main, f2npmvecop_usage}, - {"f2npmmatrandom", f2npmmatrandom_main, f2npmmatrandom_usage}, - - {"f2nprop", f2nprop_main, f2nprop_usage}, - {"f2nprmatop", f2nprmatop_main, f2nprmatop_usage}, - - {"fplist", fplist_main, fplist_usage}, - {"fpop", fpop_main, fpop_usage}, - {"fptbl", fptbl_main, fptbl_usage}, - {"fpord", fpord_main, fpord_usage}, - {"fpmaxord", fpmaxord_main, fpmaxord_usage}, - {"fporbit", fporbit_main, fporbit_usage}, - {"fpfindgen", fpfindgen_main, fpfindgen_usage}, - {"fplog", fplog_main, fplog_usage}, - {"fprandom", fprandom_main, fprandom_usage}, - - {"fpmatop", fpmatop_main, fpmatop_usage}, - {"fpvecop", fpvecop_main, fpvecop_usage}, - {"fpmatchpol", fpmatchpol_main, fpmatchpol_usage}, - {"fpmatord", fpmatord_main, fpmatord_usage}, - {"fpmatrandom", fpmatrandom_main, fpmatrandom_usage}, - - {"fpplist", fpplist_main, fpplist_usage}, - {"fppop", fppop_main, fppop_usage}, - {"fppmatop", fppmatop_main, fppmatop_usage}, - {"fppcompmx", fppcompmx_main, fppcompmx_usage}, - {"fppdeg", fppdeg_main, fppdeg_usage}, - {"fppgcd", fppgcd_main, fppgcd_usage}, - {"fpplcm", fpplcm_main, fpplcm_usage}, - {"fpptotient", fpptotient_main, fpptotient_usage}, - {"fpptest", fpptest_main, fpptest_usage}, - {"fppfind", fppfind_main, fppfind_usage}, - {"fppfactor", fppfactor_main, fppfactor_usage}, - {"fppdivisors", fppdivisors_main, fppdivisors_usage}, - {"fppeval", fppeval_main, fppeval_usage}, - {"fpprandom", fpprandom_main, fpprandom_usage}, - {"fppqp", fppqp_main, fppqp_usage}, - - {"fppmlist", fppmlist_main, fppmlist_usage}, - {"fppmop", fppmop_main, fppmop_usage}, - {"fppmtbl", fppmtbl_main, fppmtbl_usage}, - {"fppmord", fppmord_main, fppmord_usage}, - {"fppmchpol", fppmchpol_main, fppmchpol_usage}, - {"fppmminpol", fppmminpol_main, fppmminpol_usage}, - {"fppmrandom", fppmrandom_main, fppmrandom_usage}, - - {"fppmmatop", fppmmatop_main, 0 /*fppmmatop_usage*/}, - {"fppmvecop", fppmvecop_main, 0 /*fppmvecop_usage*/}, - {"fppmmatord", fppmmatord_main, fppmmatord_usage}, - {"fppmmatrandom", fppmmatrandom_main, fppmmatrandom_usage}, - - {"fpprop", fpprop_main, fpprop_usage}, - {"fpprmatop", fpprmatop_main, fpprmatop_usage}, - - {"fpnpop", fpnpop_main, fpnpop_usage}, - {"fpnpmatop", fpnpmatop_main, fpnpmatop_usage}, - {"fpnpgcd", fpnpgcd_main, fpnpgcd_usage}, - {"fpnpqp", fpnpqp_main, fpnpqp_usage}, + {"z_op", z_op_main, 0 /*zop_usage*/}, + {"z_gcd", z_gcd_main, z_gcd_usage}, + {"z_lcm", z_lcm_main, z_lcm_usage}, + {"z_totient", z_totient_main, z_totient_usage}, + {"z_test_prime", z_test_prime_main, z_test_prime_usage}, + {"spffl::intmath::nth_prime", nth_prime_main, nth_prime_usage}, + {"z_list", z_list_main, z_list_usage}, + {"z_factor", z_factor_main, z_factor_usage}, + {"z_divisors", z_divisors_main, z_divisors_usage}, + {"z_mat_op", z_mat_op_main, 0 /*zmatop_usage*/}, + + {"q_op", q_op_main, 0 /*qop_usage*/}, + {"q_vec_op", q_vec_op_main, 0 /*qvecop_usage*/}, + {"q_mat_op", q_mat_op_main, 0 /*qmatop_usage*/}, + + {"q_cyclo", q_cyclo_main, q_cyclo_usage}, + {"q_p_op", q_p_op_main, 0 /*q_cyclo_usage*/}, + + {"f2_op", f2_op_main, 0 /*f2op_usage*/}, + {"f2_random", f2_random_main, f2_random_usage}, + + {"f2_vec_op", f2_vec_op_main, 0 /*f2vecop_usage*/}, + {"f2_mat_op", f2_mat_op_main, 0 /*f2matop_usage*/}, + {"f2_mat_ch_pol", f2_mat_ch_pol_main, f2_mat_ch_pol_usage}, + {"f2_mat_ord", f2_mat_ord_main, f2_mat_ord_usage}, + {"f2_mat_random", f2_mat_random_main, f2_mat_random_usage}, + + {"f2_p_list", f2_p_list_main, f2_p_list_usage}, + {"f2_p_op", f2_p_op_main, 0 /*f2pop_usage*/}, + {"f2_p_deg", f2_p_deg_main, f2_p_deg_usage}, + {"f2_p_gcd", f2_p_gcd_main, f2_p_gcd_usage}, + {"f2_p_lcm", f2_p_lcm_main, f2_p_lcm_usage}, + {"f2_p_totient", f2_p_totient_main, f2_p_totient_usage}, + {"f2_p_test", f2_p_test_main, f2_p_test_usage}, + {"f2_p_find", f2_p_find_main, f2_p_find_usage}, + {"f2_p_period", f2_p_period_main, f2_p_period_usage}, + {"f2_p_factor", f2_p_factor_main, f2_p_factor_usage}, + {"f2_p_divisors", f2_p_divisors_main, f2_p_divisors_usage}, + {"f2_p_eval", f2_p_eval_main, f2_p_eval_usage}, + {"f2_p_random", f2_p_random_main, f2_p_random_usage}, + {"f2_p_qp", f2_p_qp_main, f2_p_qp_usage}, + {"f2_p_mat_op", f2_p_mat_op_main, 0 /*f2pmatop_usage*/}, + {"f2_p_comp_mx", f2_p_comp_mx_main, f2_p_comp_mx_usage}, + + {"f2_pm_list", f2_pm_list_main, f2_pm_list_usage}, + {"f2_pm_op", f2_pm_op_main, f2_pm_op_usage}, + {"f2_pm_tbl", f2_pm_tbl_main, f2_pm_tbl_usage}, + {"f2_pm_ord", f2_pm_ord_main, f2_pm_ord_usage}, + {"f2_pm_find_gen", f2_pm_find_gen_main, f2_pm_find_gen_usage}, + {"f2_pm_log", f2_pm_log_main, f2_pm_log_usage}, + {"f2_pm_ch_pol", f2_pm_ch_pol_main, f2_pm_ch_pol_usage}, + {"f2_pm_min_pol", f2_pm_min_pol_main, f2_pm_min_pol_usage}, + {"f2_pm_convert", f2_pm_convert_main, f2_pm_convert_usage}, + {"f2_pm_random", f2_pm_random_main, f2_pm_random_usage}, + + {"f2_pm_mat_op", f2_pm_mat_op_main, f2_pm_mat_op_usage}, + {"f2_pm_vec_op", f2_pm_vec_op_main, f2_pm_vec_op_usage}, + {"f2_pm_mat_solve", f2_pm_mat_solve_main, f2_pm_mat_solve_usage}, + {"f2_pm_mat_ch_pol", f2_pm_mat_ch_pol_main, f2_pm_mat_ch_pol_usage}, + {"f2_pm_mat_dable", f2_pm_mat_dable_main, f2_pm_mat_dable_usage}, + {"f2_pm_mat_ord", f2_pm_mat_ord_main, f2_pm_mat_ord_usage}, + {"f2_pm_mat_random", f2_pm_mat_random_main, f2_pm_mat_random_usage}, + + {"f2_pr_op", f2_pr_op_main, 0 /*f2prop_usage*/}, + {"f2_pr_random", f2_pr_random_main, f2_pr_random_usage}, + {"f2_pr_mat_op", f2_pr_mat_op_main, 0 /*f2prmatop_usage*/}, + {"f2_pr_mat_random", f2_pr_mat_random_main, f2_pr_mat_random_usage}, + + {"f2n_p_list", f2n_p_list_main, f2n_p_list_usage}, + {"f2n_p_op", f2n_p_op_main, f2n_p_op_usage}, + {"f2n_p_mat_op", f2n_p_mat_op_main, f2n_p_mat_op_usage}, + {"f2n_p_deg", f2n_p_deg_main, f2n_p_deg_usage}, + {"f2n_p_gcd", f2n_p_gcd_main, f2n_p_gcd_usage}, + {"f2n_p_lcm", f2n_p_lcm_main, f2n_p_lcm_usage}, + {"f2n_p_totient", f2n_p_totient_main, f2n_p_totient_usage}, + {"f2n_p_test", f2n_p_test_main, f2n_p_test_usage}, + {"f2n_p_find", f2n_p_find_main, f2n_p_find_usage}, + {"f2n_p_factor", f2n_p_factor_main, f2n_p_factor_usage}, + {"f2n_p_divisors", f2n_p_divisors_main, f2n_p_divisors_usage}, + {"f2n_p_eval", f2n_p_eval_main, f2n_p_eval_usage}, + {"f2n_p_random", f2n_p_random_main, f2n_p_random_usage}, + {"f2n_p_comp_mx", f2n_p_comp_mx_main, f2n_p_comp_mx_usage}, + + {"f2n_pm_list", f2n_pm_list_main, f2n_pm_list_usage}, + {"f2n_pm_op", f2n_pm_op_main, f2n_pm_op_usage}, + {"f2n_pm_tbl", f2n_pm_tbl_main, f2n_pm_tbl_usage}, + {"f2n_pm_ord", f2n_pm_ord_main, f2n_pm_ord_usage}, + {"f2n_pm_find_gen", f2n_pm_find_gen_main, f2n_pm_find_gen_usage}, + {"f2n_pm_log", f2n_pm_log_main, f2n_pm_log_usage}, + {"f2n_pm_ch_pol", f2n_pm_ch_pol_main, f2n_pm_ch_pol_usage}, + {"f2n_pm_min_pol", f2n_pm_min_pol_main, f2n_pm_min_pol_usage}, + {"f2n_pm_random", f2n_pm_random_main, f2n_pm_random_usage}, + {"f2n_p_qp", f2n_p_qp_main, f2n_p_qp_usage}, + + {"f2n_pm_mat_op", f2n_pm_mat_op_main, f2n_pm_mat_op_usage}, + {"f2n_pm_vec_op", f2n_pm_vec_op_main, f2n_pm_vec_op_usage}, + {"f2n_pm_mat_random", f2n_pm_mat_random_main, f2n_pm_mat_random_usage}, + + {"f2n_pr_op", f2n_pr_op_main, f2n_pr_op_usage}, + {"f2n_pr_mat_op", f2n_pr_mat_op_main, f2n_pr_mat_op_usage}, + + {"fp_list", fp_list_main, fp_list_usage}, + {"fp_op", fp_op_main, fp_op_usage}, + {"fp_tbl", fp_tbl_main, fp_tbl_usage}, + {"fp_ord", fp_ord_main, fp_ord_usage}, + {"fp_max_ord", fp_max_ord_main, fp_max_ord_usage}, + {"fp_orbit", fp_orbit_main, fp_orbit_usage}, + {"fp_find_gen", fp_find_gen_main, fp_find_gen_usage}, + {"fp_log", fp_log_main, fp_log_usage}, + {"fp_random", fp_random_main, fp_random_usage}, + + {"fp_mat_op", fp_mat_op_main, fp_mat_op_usage}, + {"fp_vec_op", fp_vec_op_main, fp_vec_op_usage}, + {"fp_mat_ch_pol", fp_mat_ch_pol_main, fp_mat_ch_pol_usage}, + {"fp_mat_ord", fp_mat_ord_main, fp_mat_ord_usage}, + {"fp_mat_random", fp_mat_random_main, fp_mat_random_usage}, + + {"fp_p_list", fp_p_list_main, fp_p_list_usage}, + {"fp_p_op", fp_p_op_main, fp_p_op_usage}, + {"fp_p_mat_op", fp_p_mat_op_main, fp_p_mat_op_usage}, + {"fp_p_comp_mx", fp_p_comp_mx_main, fp_p_comp_mx_usage}, + {"fp_p_deg", fp_p_deg_main, fp_p_deg_usage}, + {"fp_p_gcd", fp_p_gcd_main, fp_p_gcd_usage}, + {"fp_p_lcm", fp_p_lcm_main, fp_p_lcm_usage}, + {"fp_p_totient", fp_p_totient_main, fp_p_totient_usage}, + {"fp_p_test", fp_p_test_main, fp_p_test_usage}, + {"fp_p_find", fp_p_find_main, fp_p_find_usage}, + {"fp_p_factor", fp_p_factor_main, fp_p_factor_usage}, + {"fp_p_divisors", fp_p_divisors_main, fp_p_divisors_usage}, + {"fp_p_eval", fp_p_eval_main, fp_p_eval_usage}, + {"fp_p_random", fp_p_random_main, fp_p_random_usage}, + {"fp_p_qp", fp_p_qp_main, fp_p_qp_usage}, + + {"fp_pm_list", fp_pm_list_main, fp_pm_list_usage}, + {"fp_pm_op", fp_pm_op_main, fp_pm_op_usage}, + {"fp_pm_tbl", fp_pm_tbl_main, fp_pm_tbl_usage}, + {"fp_pm_ord", fp_pm_ord_main, fp_pm_ord_usage}, + {"fp_pm_ch_pol", fp_pm_ch_pol_main, fp_pm_ch_pol_usage}, + {"fp_pm_min_pol", fp_pm_min_pol_main, fp_pm_min_pol_usage}, + {"fp_pm_random", fp_pm_random_main, fp_pm_random_usage}, + + {"fp_pm_mat_op", fp_pm_mat_op_main, 0 /*fppmmatop_usage*/}, + {"fp_pm_vecop", fp_pm_vecop_main, 0 /*fppmvecop_usage*/}, + {"fp_pm_mat_ord", fp_pm_mat_ord_main, fp_pm_mat_ord_usage}, + {"fp_pm_mat_random", fp_pm_mat_random_main, fp_pm_mat_random_usage}, + + {"fp_pr_op", fp_pr_op_main, fp_pr_op_usage}, + {"fp_pr_mat_op", fp_pr_mat_op_main, fp_pr_mat_op_usage}, + + {"fpn_p_op", fpn_p_op_main, fpn_p_op_usage}, + {"fpn_p_mat_op", fpn_p_mat_op_main, fpn_p_mat_op_usage}, + {"fpn_p_gcd", fpn_p_gcd_main, fpn_p_gcd_usage}, + {"fpn_p_qp", fpn_p_qp_main, fpn_p_qp_usage}, // To do: - //{"fpnplist", fpnplist_main, fpnplist_usage}, - //{"fpnpcompmx", fpnpcompmx_main, fpnpcompmx_usage}, - //{"fpnpdeg", fpnpdeg_main, fpnpdeg_usage}, - //{"fpnplcm", fpnplcm_main, fpnplcm_usage}, - //{"fpnptotient", fpnptotient_main, fpnptotient_usage}, - //{"fpnptest", fpnptest_main, fpnptest_usage}, - //{"fpnpfind", fpnpfind_main, fpnpfind_usage}, - //{"fpnpfactor", fpnpfactor_main, fpnpfactor_usage}, - //{"fpnpdivisors", fpnpdivisors_main, fpnpdivisors_usage}, - //{"fpnpeval", fpnpeval_main, fpnpeval_usage}, - //{"fpnprandom", fpnprandom_main, fpnprandom_usage}, - - {"fpnpmop", fpnpmop_main, fpnpmop_usage}, - {"fpnpmmatop", fpnpmmatop_main, fpnpmmatop_usage}, + //{"fpn_p_list", fpn_p_list_main, fpn_p_list_usage}, + //{"fpn_p_comp_mx", fpn_p_comp_mx_main, fpn_p_comp_mx_usage}, + //{"fpn_p_deg", fpn_p_deg_main, fpn_p_deg_usage}, + //{"fpn_p_lcm", fpn_p_lcm_main, fpn_p_lcm_usage}, + //{"fpn_p_totient", fpn_p_totient_main, fpn_p_totient_usage}, + //{"fpn_p_test", fpn_p_test_main, fpn_p_test_usage}, + //{"fpn_p_find", fpn_p_find_main, fpn_p_find_usage}, + //{"fpn_p_factor", fpn_p_factor_main, fpn_p_factor_usage}, + //{"fpn_p_divisors", fpn_p_divisors_main, fpn_p_divisors_usage}, + //{"fpn_p_eval", fpn_p_eval_main, fpn_p_eval_usage}, + //{"fpn_p_random", fpn_p_random_main, fpn_p_random_usage}, + + {"fpn_pm_op", fpn_pm_op_main, fpn_pm_op_usage}, + {"fpn_pm_mat_op", fpn_pm_mat_op_main, fpn_pm_mat_op_usage}, // To do: - //{"fpnpmlist", fpnpmlist_main, fpnpmlist_usage}, - //{"fpnpmtbl", fpnpmtbl_main, fpnpmtbl_usage}, - //{"fpnpmord", fpnpmord_main, fpnpmord_usage}, - //{"fpnpmchpol", fpnpmchpol_main, fpnpmchpol_usage}, - //{"fpnpmminpol", fpnpmminpol_main, fpnpmminpol_usage}, - //{"fpnpmrandom", fpnpmrandom_main, fpnpmrandom_usage}, - //{"fpnpmmatrandom", fpnpmmatrandom_main, fpnpmmatrandom_usage}, + //{"fpn_pm_list", fpn_pm_list_main, fpn_pm_list_usage}, + //{"fpn_pm_tbl", fpn_pm_tbl_main, fpn_pm_tbl_usage}, + //{"fpn_pm_ord", fpn_pm_ord_main, fpn_pm_ord_usage}, + //{"fpn_pm_ch_pol", fpn_pm_ch_pol_main, fpn_pm_ch_pol_usage}, + //{"fpn_pm_min_pol", fpn_pm_min_pol_main, fpn_pm_min_pol_usage}, + //{"fpn_pm_random", fpn_pm_random_main, fpn_pm_random_usage}, + //{"fpn_pm_mat_random", fpn_pm_mat_random_main, fpn_pm_mat_random_usage}, {0, 0, 0} // MUST be null-terminated. }; @@ -243,7 +243,7 @@ int main(int argc, char **argv) { argc--, argv++; // Recursively invokes this program to handle {} pairs, e.g. - // spiff f2pdeg { f2pfactor { f2pop 2 ^ 127 - 1 } } + // spiff f2_p_deg { f2_p_factor { f2_p_op 2 ^ 127 - 1 } } spffl::cliparser::cmd_interpolate(exename, argc, argv); if (argc < 1) diff --git a/cli/spiff/z_handlers.cpp b/cli/spiff/z_handlers.cpp index 8657b53..2c9bd66 100644 --- a/cli/spiff/z_handlers.cpp +++ b/cli/spiff/z_handlers.cpp @@ -15,17 +15,17 @@ #include "is_prime.h" #include "tfacinfo.h" -int zop_main(int argc, char **argv, usage_t *pusage) { +int z_op_main(int argc, char **argv, usage_t *pusage) { spffl::cliparser::cmd_line_parse(argc - 1, argv + 1, 0, 1); return 0; } -void zgcd_usage(char *argv0) { +void z_gcd_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " [-e] {a} {b}\n"; exit(1); } -int zgcd_main(int argc, char **argv, usage_t *pusage) { +int z_gcd_main(int argc, char **argv, usage_t *pusage) { if ((argc >= 2) && (strcmp(argv[1], "-e") == 0)) { int a, b, g, r, s; if (argc != 4) @@ -61,12 +61,12 @@ int zgcd_main(int argc, char **argv, usage_t *pusage) { return 0; } -void zlcm_usage(char *argv0) { +void z_lcm_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {integers ...}\n"; exit(1); } -int zlcm_main(int argc, char **argv, usage_t *pusage) { +int z_lcm_main(int argc, char **argv, usage_t *pusage) { int a, l; if (argc < 2) pusage(argv[0]); @@ -82,12 +82,12 @@ int zlcm_main(int argc, char **argv, usage_t *pusage) { return 0; } -void ztotient_usage(char *argv0) { +void z_totient_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {integers ...}\n"; exit(1); } -int ztotient_main(int argc, char **argv, usage_t *pusage) { +int z_totient_main(int argc, char **argv, usage_t *pusage) { int a, phi; if (argc < 2) pusage(argv[0]); @@ -102,12 +102,12 @@ int ztotient_main(int argc, char **argv, usage_t *pusage) { return 0; } -void ztestprime_usage(char *argv0) { +void z_test_prime_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {integers ...}\n"; exit(1); } -int ztestprime_main(int argc, char **argv, usage_t *pusage) { +int z_test_prime_main(int argc, char **argv, usage_t *pusage) { int a; for (int argi = 1; argi < argc; argi++) { if (sscanf(argv[argi], "%d", &a) != 1) @@ -122,12 +122,12 @@ int ztestprime_main(int argc, char **argv, usage_t *pusage) { return 0; } -void nthprime_usage(char *argv0) { +void nth_prime_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {n[-m]}\n"; exit(1); } -int nthprime_main(int argc, char **argv, usage_t *pusage) { +int nth_prime_main(int argc, char **argv, usage_t *pusage) { if (argc < 2) pusage(argv[0]); for (int argi = 1; argi < argc; argi++) { @@ -145,12 +145,12 @@ int nthprime_main(int argc, char **argv, usage_t *pusage) { return 0; } -void zlist_usage(char *argv0) { +void z_list_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {start [reps [stride]]}\n"; exit(1); } -int zlist_main(int argc, char **argv, usage_t *pusage) { +int z_list_main(int argc, char **argv, usage_t *pusage) { int walker = 1; int reps = 1; int stride = 1; @@ -179,12 +179,12 @@ int zlist_main(int argc, char **argv, usage_t *pusage) { return 0; } -void zfactor_usage(char *argv0) { +void z_factor_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " {integers ...}\n"; exit(1); } -int zfactor_main(int argc, char **argv, usage_t *pusage) { +int z_factor_main(int argc, char **argv, usage_t *pusage) { int a; for (int argi = 1; argi < argc; argi++) { if (sscanf(argv[argi], "%d", &a) != 1) @@ -196,7 +196,7 @@ int zfactor_main(int argc, char **argv, usage_t *pusage) { int check = finfo.unfactor(1); if (check != a) { - std::cerr << "Coding error in zfactor.\n"; + std::cerr << "Coding error in z_factor.\n"; std::cerr << " Input: " << a << std::endl; std::cerr << " Check: " << check << std::endl; std::cerr << " Factors: " << finfo << std::endl; @@ -206,12 +206,12 @@ int zfactor_main(int argc, char **argv, usage_t *pusage) { return 0; } -void zdivisors_usage(char *argv0) { +void z_divisors_usage(char *argv0) { std::cerr << "Usage: " << argv0 << " [-mp] {integers ...}\n"; exit(1); } -int zdivisors_main(int argc, char **argv, usage_t *pusage) { +int z_divisors_main(int argc, char **argv, usage_t *pusage) { int a; int argb = 1; int maximal_proper_only = 0; @@ -247,7 +247,7 @@ int zdivisors_main(int argc, char **argv, usage_t *pusage) { return 0; } -int zmatop_main(int argc, char **argv, usage_t *pusage) { +int z_mat_op_main(int argc, char **argv, usage_t *pusage) { spffl::cliparser::cmd_line_mat_parse(argc - 1, argv + 1, 0, 1); return 0; } diff --git a/cli/spiff/z_handlers.h b/cli/spiff/z_handlers.h index 2366e3a..386dc0f 100644 --- a/cli/spiff/z_handlers.h +++ b/cli/spiff/z_handlers.h @@ -9,32 +9,32 @@ #include "handlers.h" -int zop_main(int argc, char **argv, usage_t *pusage); +int z_op_main(int argc, char **argv, usage_t *pusage); -void zgcd_usage(char *argv0); -int zgcd_main(int argc, char **argv, usage_t *pusage); +void z_gcd_usage(char *argv0); +int z_gcd_main(int argc, char **argv, usage_t *pusage); -void zlcm_usage(char *argv0); -int zlcm_main(int argc, char **argv, usage_t *pusage); +void z_lcm_usage(char *argv0); +int z_lcm_main(int argc, char **argv, usage_t *pusage); -void ztotient_usage(char *argv0); -int ztotient_main(int argc, char **argv, usage_t *pusage); +void z_totient_usage(char *argv0); +int z_totient_main(int argc, char **argv, usage_t *pusage); -void ztestprime_usage(char *argv0); -int ztestprime_main(int argc, char **argv, usage_t *pusage); +void z_test_prime_usage(char *argv0); +int z_test_prime_main(int argc, char **argv, usage_t *pusage); -void nthprime_usage(char *argv0); -int nthprime_main(int argc, char **argv, usage_t *pusage); +void nth_prime_usage(char *argv0); +int nth_prime_main(int argc, char **argv, usage_t *pusage); -void zlist_usage(char *argv0); -int zlist_main(int argc, char **argv, usage_t *pusage); +void z_list_usage(char *argv0); +int z_list_main(int argc, char **argv, usage_t *pusage); -void zfactor_usage(char *argv0); -int zfactor_main(int argc, char **argv, usage_t *pusage); +void z_factor_usage(char *argv0); +int z_factor_main(int argc, char **argv, usage_t *pusage); -void zdivisors_usage(char *argv0); -int zdivisors_main(int argc, char **argv, usage_t *pusage); +void z_divisors_usage(char *argv0); +int z_divisors_main(int argc, char **argv, usage_t *pusage); -int zmatop_main(int argc, char **argv, usage_t *pusage); +int z_mat_op_main(int argc, char **argv, usage_t *pusage); #endif // Z_HANDLERS_H diff --git a/pre-cmake/apps/agff/agff.cpp b/pre-cmake/apps/agff/agff.cpp index d7f25fb..e046578 100644 --- a/pre-cmake/apps/agff/agff.cpp +++ b/pre-cmake/apps/agff/agff.cpp @@ -18,7 +18,7 @@ static tmvpoly F2_Fq_embed( f2_polymod_t & Fq_zero, f2_polymod_t & Fq_one); -// xxx move to fppolymod_convert.cpp +// xxx move to fp_polymod_convert.cpp static tmvpoly Fp_Fq_embed( tmvpoly & f, fp_poly_t & m); @@ -95,7 +95,7 @@ int f2aplist_main(int argc, char ** argv) // Scan the functions. tvector< tmvpoly > arg_f(num_F); for (argi = argfb, i = 0; i < num_F; i++, argi++) { - if (!tmvpoly_f2polymod_from_string(arg_f[i], argv[argi], F2_m)) { + if (!tmvpoly_f2_polymod_from_string(arg_f[i], argv[argi], F2_m)) { std::cerr << "Couldn't scan polynomial.\n"; exit(1); } @@ -156,7 +156,7 @@ int f2aplist_main(int argc, char ** argv) std::cerr << "Couldn't parse \"" << argi << "\".\n"; exit(1); } - Fq_m = f2poly_find_irr(deg); + Fq_m = f2_poly_find_irreducible(deg); } int n = Fq_m.find_degree(); int q = 1 << n; @@ -173,9 +173,9 @@ int f2aplist_main(int argc, char ** argv) tmatrix space; // A^n(F_q) or P^n(F_q) if (homogenize) - space = f2polymod_Pn_list(Fq_m, nv-1); + space = f2_polymod_Pn_list(Fq_m, nv-1); else - space = f2polymod_An_list(Fq_m, nv); + space = f2_polymod_An_list(Fq_m, nv); int oS = space.get_num_rows(); unsigned char * marks = new unsigned char[oS]; for (j = 0; j < oS; j++) @@ -268,7 +268,7 @@ int f2apolist_main(int argc, char ** argv) f2_polymod_t F2_one = f2_polymod_t::prime_sfld_elt(1, F2_m); tmvpoly F2_f; - if (!tmvpoly_f2polymod_from_string(F2_f, fstring, F2_m)) { + if (!tmvpoly_f2_polymod_from_string(F2_f, fstring, F2_m)) { std::cerr << "Couldn't scan polynomial.\n"; exit(1); } @@ -295,7 +295,7 @@ int f2apolist_main(int argc, char ** argv) std::cerr << "Couldn't parse \"" << argi << "\".\n"; exit(1); } - Fq_m = f2poly_find_irr(deg); + Fq_m = f2_poly_find_irreducible(deg); } f2_polymod_t Fq_zero = f2_polymod_t::prime_sfld_elt(0, Fq_m); @@ -321,7 +321,7 @@ int f2apolist_main(int argc, char ** argv) std::cout << "Affine zeroes:\n"; } - tmatrix An_Fq = f2polymod_An_list(Fq_m, nv); + tmatrix An_Fq = f2_polymod_An_list(Fq_m, nv); int qn = An_Fq.get_num_rows(); for (int i = 0; i < qn; i++) { @@ -338,7 +338,7 @@ int f2apolist_main(int argc, char ** argv) std::cout << "Projective zeroes:\n"; } - tmatrix Pn_Fq = f2polymod_Pn_list(Fq_m, nv); + tmatrix Pn_Fq = f2_polymod_Pn_list(Fq_m, nv); int oP = Pn_Fq.get_num_rows(); for (int i = 0; i < oP; i++) { @@ -396,7 +396,7 @@ int f2apsing_main(int argc, char ** argv) f2_polymod_t F2_one = f2_polymod_t::prime_sfld_elt(1, F2_m); tmvpoly F2_f; - if (!tmvpoly_f2polymod_from_string(F2_f, fstring, F2_m)) { + if (!tmvpoly_f2_polymod_from_string(F2_f, fstring, F2_m)) { std::cerr << "Couldn't scan polynomial.\n"; exit(1); } @@ -427,7 +427,7 @@ int f2apsing_main(int argc, char ** argv) std::cerr << "Couldn't parse \"" << argi << "\".\n"; exit(1); } - Fq_m = f2poly_find_irr(deg); + Fq_m = f2_poly_find_irreducible(deg); } f2_polymod_t Fq_zero = f2_polymod_t::prime_sfld_elt(0, Fq_m); @@ -453,7 +453,7 @@ int f2apsing_main(int argc, char ** argv) std::cout << "Affine space:\n"; } - tmatrix An_Fq = f2polymod_An_list(Fq_m, nv); + tmatrix An_Fq = f2_polymod_An_list(Fq_m, nv); int qn = An_Fq.get_num_rows(); tmvpoly * funcs = new tmvpoly[nv+1]; @@ -486,7 +486,7 @@ int f2apsing_main(int argc, char ** argv) std::cout << "Projective space:\n"; } - tmatrix Pn_Fq = f2polymod_Pn_list(Fq_m, nv); + tmatrix Pn_Fq = f2_polymod_Pn_list(Fq_m, nv); int oP = Pn_Fq.get_num_rows(); funcs = new tmvpoly[nv+2]; @@ -567,7 +567,7 @@ int f2apjac_main(int argc, char ** argv) f2_polymod_t F2_one = f2_polymod_t::prime_sfld_elt(1, F2_m); tmvpoly F2_f; - if (!tmvpoly_f2polymod_from_string(F2_f, fstring, F2_m)) { + if (!tmvpoly_f2_polymod_from_string(F2_f, fstring, F2_m)) { std::cerr << "Couldn't scan polynomial.\n"; exit(1); } @@ -595,7 +595,7 @@ int f2apjac_main(int argc, char ** argv) std::cerr << "Couldn't parse \"" << argi << "\".\n"; exit(1); } - Fq_m = f2poly_find_irr(deg); + Fq_m = f2_poly_find_irreducible(deg); } f2_polymod_t Fq_zero = f2_polymod_t::prime_sfld_elt(0, Fq_m); @@ -620,7 +620,7 @@ int f2apjac_main(int argc, char ** argv) std::cout << "Affine space:\n"; } - tmatrix An_Fq = f2polymod_An_list(Fq_m, nv); + tmatrix An_Fq = f2_polymod_An_list(Fq_m, nv); int qn = An_Fq.get_num_rows(); tmvpoly * funcs = new tmvpoly[nv+1]; @@ -653,7 +653,7 @@ int f2apjac_main(int argc, char ** argv) std::cout << "Projective space:\n"; } - tmatrix Pn_Fq = f2polymod_Pn_list(Fq_m, nv); + tmatrix Pn_Fq = f2_polymod_Pn_list(Fq_m, nv); int oP = Pn_Fq.get_num_rows(); funcs = new tmvpoly[nv+2]; @@ -732,10 +732,10 @@ int fpaplist_main(int argc, char ** argv) const char * fstring = argv[argb]; argb++; - fp_poly_t Fp_m = fppoly_find_irr(p, 1); + fp_poly_t Fp_m = fp_poly_find_irr(p, 1); tmvpoly Fp_f; - if (!tmvpoly_fppolymod_from_string(Fp_f, fstring, Fp_m)) { + if (!tmvpoly_fp_polymod_from_string(Fp_f, fstring, Fp_m)) { std::cerr << "Couldn't scan polynomial.\n"; exit(1); } @@ -769,7 +769,7 @@ int fpaplist_main(int argc, char ** argv) std::cerr << "Couldn't parse \"" << argi << "\".\n"; exit(1); } - Fq_m = fppoly_find_irr(p, deg); + Fq_m = fp_poly_find_irr(p, deg); } fp_polymod_t Fq_zero = fp_polymod_t::prime_sfld_elt(0, Fq_m); tmvpoly f = Fp_Fq_embed(Fp_f, Fq_m); @@ -791,7 +791,7 @@ int fpaplist_main(int argc, char ** argv) std::cout << "Affine zeroes:\n"; } - tmatrix An_Fq = fppolymod_An_list(Fq_m, nv); + tmatrix An_Fq = fp_polymod_An_list(Fq_m, nv); int qn = An_Fq.get_num_rows(); for (int i = 0; i < qn; i++) { @@ -808,7 +808,7 @@ int fpaplist_main(int argc, char ** argv) std::cout << "Projective zeroes:\n"; } - tmatrix Pn_Fq = fppolymod_Pn_list(Fq_m, nv); + tmatrix Pn_Fq = fp_polymod_Pn_list(Fq_m, nv); int oP = Pn_Fq.get_num_rows(); for (int i = 0; i < oP; i++) { @@ -865,10 +865,10 @@ int fpapsing_main(int argc, char ** argv) char * fstring = argv[argb]; argb++; - fp_poly_t Fp_m = fppoly_find_irr(p, 1); + fp_poly_t Fp_m = fp_poly_find_irr(p, 1); tmvpoly Fp_f; - if (!tmvpoly_fppolymod_from_string(Fp_f, fstring, Fp_m)) { + if (!tmvpoly_fp_polymod_from_string(Fp_f, fstring, Fp_m)) { std::cerr << "Couldn't scan polynomial.\n"; exit(1); } @@ -894,7 +894,7 @@ int fpapsing_main(int argc, char ** argv) std::cerr << "Couldn't parse \"" << argi << "\".\n"; exit(1); } - Fq_m = fppoly_find_irr(p, deg); + Fq_m = fp_poly_find_irr(p, deg); } fp_polymod_t Fq_zero = fp_polymod_t::prime_sfld_elt(0, Fq_m); fp_polymod_t Fq_one = fp_polymod_t::prime_sfld_elt(1, Fq_m); @@ -918,7 +918,7 @@ int fpapsing_main(int argc, char ** argv) std::cout << "Affine space:\n"; } - tmatrix An_Fq = fppolymod_An_list(Fq_m, nv); + tmatrix An_Fq = fp_polymod_An_list(Fq_m, nv); int qn = An_Fq.get_num_rows(); tmvpoly * funcs = new tmvpoly[nv+1]; @@ -951,7 +951,7 @@ int fpapsing_main(int argc, char ** argv) std::cout << "Projective space:\n"; } - tmatrix Pn_Fq = fppolymod_Pn_list(Fq_m, nv); + tmatrix Pn_Fq = fp_polymod_Pn_list(Fq_m, nv); int oP = Pn_Fq.get_num_rows(); funcs = new tmvpoly[nv+2]; @@ -1009,7 +1009,7 @@ int f2nmvpeval_main(int argc, char ** argv) f2nmvpeval_usage(argv[0]); if (!m.from_string(argv[1])) f2nmvpeval_usage(argv[0]); - if (!tmvpoly_f2polymod_from_string(f, argv[2], m)) + if (!tmvpoly_f2_polymod_from_string(f, argv[2], m)) f2nmvpeval_usage(argv[0]); zero = f2_polymod_t::prime_sfld_elt(0, m); @@ -1048,7 +1048,7 @@ int f2nmvreval_main(int argc, char ** argv) f2nmvreval_usage(argv[0]); if (!m.from_string(argv[1])) f2nmvreval_usage(argv[0]); - if (!tmvrat_f2polymod_from_string(f, argv[2], m)) + if (!tmvrat_f2_polymod_from_string(f, argv[2], m)) f2nmvreval_usage(argv[0]); zero = f2_polymod_t::prime_sfld_elt(0, m); diff --git a/pre-cmake/apps/ell/ftellpts.cpp b/pre-cmake/apps/ell/ftellpts.cpp index b2ff9f2..19a6ffc 100644 --- a/pre-cmake/apps/ell/ftellpts.cpp +++ b/pre-cmake/apps/ell/ftellpts.cpp @@ -40,7 +40,7 @@ int main(int argc, char ** argv) if (!ft_scan_quintuple(argv[2], m, a1, a2, a3, a4, a6)) usage(argv[0]); - tvector Fq = f2polymod_list(m, SP_LIST_ALL); + tvector Fq = f2_polymod_list(m, SP_LIST_ALL); int q = Fq.get_num_elements(); // x=* y=1 z=0 diff --git a/pre-cmake/classes/tests/ttmv03.cpp b/pre-cmake/classes/tests/ttmv03.cpp index c4a97bd..328d8f4 100644 --- a/pre-cmake/classes/tests/ttmv03.cpp +++ b/pre-cmake/classes/tests/ttmv03.cpp @@ -39,7 +39,7 @@ int main(int argc, char ** argv) std::cout << "F = " << F << "\n"; std::cout << "\n"; - tvector Fq = f2polymod_list(m, 0); + tvector Fq = f2_polymod_list(m, 0); int oFq = Fq.get_num_elements(); for (int i = 0; i < oFq; i++) { diff --git a/pre-cmake/classes/tests/ttmv04.cpp b/pre-cmake/classes/tests/ttmv04.cpp index d06604b..1b41151 100644 --- a/pre-cmake/classes/tests/ttmv04.cpp +++ b/pre-cmake/classes/tests/ttmv04.cpp @@ -98,7 +98,7 @@ int main(int argc, char ** argv) std::cout << "Affine zeroes:\n"; std::cout << "f = " << f << "\n"; - tvector Fq = f2polymod_list(m, 0); + tvector Fq = f2_polymod_list(m, 0); int oFq = Fq.get_num_elements(); for (int i = 0; i < oFq; i++) { diff --git a/pre-cmake/classes/tests/ttmv05.cpp b/pre-cmake/classes/tests/ttmv05.cpp index 53f958e..4022ba0 100644 --- a/pre-cmake/classes/tests/ttmv05.cpp +++ b/pre-cmake/classes/tests/ttmv05.cpp @@ -137,10 +137,10 @@ int main(int argc, char ** argv) std::cout << "Affine zeroes:\n"; std::cout << "f = " << f << "\n"; - tvector Fq = f2polymod_list(Fq_m, 0); + tvector Fq = f2_polymod_list(Fq_m, 0); int oFq = Fq.get_num_elements(); - tmatrix Fq_n = f2polymod_An_list(Fq_m, 2); + tmatrix Fq_n = f2_polymod_An_list(Fq_m, 2); for (int i = 0; i < oFq; i++) { for (int j = 0; j < oFq; j++) { diff --git a/pre-cmake/classes/tests/ttmv06.cpp b/pre-cmake/classes/tests/ttmv06.cpp index a003ba6..68197e1 100644 --- a/pre-cmake/classes/tests/ttmv06.cpp +++ b/pre-cmake/classes/tests/ttmv06.cpp @@ -125,7 +125,7 @@ int main(int argc, char ** argv) std::cout << "Affine zeroes:\n"; std::cout << "f = " << f << "\n"; - tmatrix Fq_n = f2polymod_An_list(Fq_m, n); + tmatrix Fq_n = f2_polymod_An_list(Fq_m, n); int qn = Fq_n.get_num_rows(); for (int i = 0; i < qn; i++) { @@ -138,7 +138,7 @@ int main(int argc, char ** argv) std::cout << "Projective zeroes:\n"; std::cout << "F = " << F << "\n"; - tmatrix Pn_Fq = f2polymod_Pn_list(Fq_m, n); + tmatrix Pn_Fq = f2_polymod_Pn_list(Fq_m, n); int oP = Pn_Fq.get_num_rows(); for (int i = 0; i < oP; i++) { diff --git a/pre-cmake/classes/tests/ttmv07.cpp b/pre-cmake/classes/tests/ttmv07.cpp index e93582b..d5b13af 100644 --- a/pre-cmake/classes/tests/ttmv07.cpp +++ b/pre-cmake/classes/tests/ttmv07.cpp @@ -152,7 +152,7 @@ int main(int argc, char ** argv) } std::cout << "f = " << f << "\n"; - tmatrix Fq_n = f2polymod_An_list(m, n); + tmatrix Fq_n = f2_polymod_An_list(m, n); int qn = Fq_n.get_num_rows(); for (int i = 0; i < qn; i++) { @@ -170,7 +170,7 @@ int main(int argc, char ** argv) } std::cout << "F = " << F << "\n"; - tmatrix Pn_Fq = f2polymod_Pn_list(m, n); + tmatrix Pn_Fq = f2_polymod_Pn_list(m, n); int oP = Pn_Fq.get_num_rows(); for (int i = 0; i < oP; i++) { diff --git a/pre-cmake/classes/tests/ttmv08.cpp b/pre-cmake/classes/tests/ttmv08.cpp index 2b0ce3c..8c64d8a 100644 --- a/pre-cmake/classes/tests/ttmv08.cpp +++ b/pre-cmake/classes/tests/ttmv08.cpp @@ -40,7 +40,7 @@ tmvpoly get_f( f2_poly_t & F2_m) { tmvpoly F2_f; - if (!tmvpoly_f2polymod_from_string(F2_f, "1.3.0+1.0.3+1.0.0", F2_m)) { + if (!tmvpoly_f2_polymod_from_string(F2_f, "1.3.0+1.0.3+1.0.0", F2_m)) { std::cerr << "b&d!!\n"; exit(1); } @@ -159,7 +159,7 @@ int main(int argc, char ** argv) } std::cout << "f = " << f << "\n"; - tmatrix Fq_n = f2polymod_An_list(Fq_m, n); + tmatrix Fq_n = f2_polymod_An_list(Fq_m, n); int qn = Fq_n.get_num_rows(); for (int i = 0; i < qn; i++) { @@ -177,7 +177,7 @@ int main(int argc, char ** argv) } std::cout << "F = " << F << "\n"; - tmatrix Pn_Fq = f2polymod_Pn_list(Fq_m, n); + tmatrix Pn_Fq = f2_polymod_Pn_list(Fq_m, n); int oP = Pn_Fq.get_num_rows(); for (int i = 0; i < oP; i++) { diff --git a/pre-cmake/classes/tests/ttmv09.cpp b/pre-cmake/classes/tests/ttmv09.cpp index ad2e787..4ae5aa4 100644 --- a/pre-cmake/classes/tests/ttmv09.cpp +++ b/pre-cmake/classes/tests/ttmv09.cpp @@ -61,7 +61,7 @@ int main(int argc, char ** argv) f2_polymod_t F2_one = f2_polymod_t::prime_sfld_elt(1, F2_m); tmvpoly F2_f; - if (!tmvpoly_f2polymod_from_string(F2_f, fstring, F2_m)) { + if (!tmvpoly_f2_polymod_from_string(F2_f, fstring, F2_m)) { std::cerr << "Couldn't scan polynomial.\n"; exit(1); } @@ -94,7 +94,7 @@ int main(int argc, char ** argv) } std::cout << "f = " << f << "\n"; - tmatrix Fq_n = f2polymod_An_list(Fq_m, n); + tmatrix Fq_n = f2_polymod_An_list(Fq_m, n); int qn = Fq_n.get_num_rows(); for (int i = 0; i < qn; i++) { @@ -112,7 +112,7 @@ int main(int argc, char ** argv) } std::cout << "F = " << F << "\n"; - tmatrix Pn_Fq = f2polymod_Pn_list(Fq_m, n); + tmatrix Pn_Fq = f2_polymod_Pn_list(Fq_m, n); int oP = Pn_Fq.get_num_rows(); for (int i = 0; i < oP; i++) { diff --git a/pre-cmake/classes/tests/ttmv10.cpp b/pre-cmake/classes/tests/ttmv10.cpp index 22aee98..884e076 100644 --- a/pre-cmake/classes/tests/ttmv10.cpp +++ b/pre-cmake/classes/tests/ttmv10.cpp @@ -62,7 +62,7 @@ int main(int argc, char ** argv) f2_polymod_t F2_one = f2_polymod_t::prime_sfld_elt(1, F2_m); tmvpoly F2_f; - if (!tmvpoly_f2polymod_from_string(F2_f, fstring, F2_m)) { + if (!tmvpoly_f2_polymod_from_string(F2_f, fstring, F2_m)) { std::cerr << "Couldn't scan polynomial.\n"; exit(1); } @@ -90,7 +90,7 @@ int main(int argc, char ** argv) std::cerr << "Couldn't parse \"" << argi << "\".\n"; exit(1); } - Fq_m = f2poly_find_irr(deg); + Fq_m = f2_poly_find_irreducible(deg); } f2_polymod_t Fq_zero = f2_polymod_t::prime_sfld_elt(0, Fq_m); @@ -117,7 +117,7 @@ int main(int argc, char ** argv) std::cout << "Affine zeroes:\n"; } - tmatrix Fq_n = f2polymod_An_list(Fq_m, n); + tmatrix Fq_n = f2_polymod_An_list(Fq_m, n); int qn = Fq_n.get_num_rows(); for (int i = 0; i < qn; i++) { @@ -134,7 +134,7 @@ int main(int argc, char ** argv) std::cout << "Projective zeroes:\n"; } - tmatrix Pn_Fq = f2polymod_Pn_list(Fq_m, n); + tmatrix Pn_Fq = f2_polymod_Pn_list(Fq_m, n); int oP = Pn_Fq.get_num_rows(); for (int i = 0; i < oP; i++) { diff --git a/pre-cmake/classes/tests/ttmv11.cpp b/pre-cmake/classes/tests/ttmv11.cpp index 02b2b20..c5380e6 100644 --- a/pre-cmake/classes/tests/ttmv11.cpp +++ b/pre-cmake/classes/tests/ttmv11.cpp @@ -55,10 +55,10 @@ int main(int argc, char ** argv) const char * fstring = argv[argb]; argb++; - fp_poly_t Fp_m = fppoly_find_irr(p, 1); + fp_poly_t Fp_m = fp_poly_find_irr(p, 1); tmvpoly Fp_f; - if (!tmvpoly_fppolymod_from_string(Fp_f, fstring, Fp_m)) { + if (!tmvpoly_fp_polymod_from_string(Fp_f, fstring, Fp_m)) { std::cerr << "Couldn't scan polynomial.\n"; exit(1); } @@ -87,7 +87,7 @@ int main(int argc, char ** argv) std::cerr << "Couldn't parse \"" << argi << "\".\n"; exit(1); } - Fq_m = fppoly_find_irr(p, deg); + Fq_m = fp_poly_find_irr(p, deg); } fp_polymod_t Fq_zero = fp_polymod_t::prime_sfld_elt(0, Fq_m); tmvpoly f = Fp_Fq_embed(Fp_f, Fq_m); @@ -110,7 +110,7 @@ int main(int argc, char ** argv) std::cout << "Affine zeroes:\n"; } - tmatrix Fq_n = fppolymod_An_list(Fq_m, n); + tmatrix Fq_n = fp_polymod_An_list(Fq_m, n); int qn = Fq_n.get_num_rows(); for (int i = 0; i < qn; i++) { @@ -127,7 +127,7 @@ int main(int argc, char ** argv) std::cout << "Projective zeroes:\n"; } - tmatrix Pn_Fq = fppolymod_Pn_list(Fq_m, n); + tmatrix Pn_Fq = fp_polymod_Pn_list(Fq_m, n); int oP = Pn_Fq.get_num_rows(); for (int i = 0; i < oP; i++) { diff --git a/pre-cmake/classes/tests/ttmv12.cpp b/pre-cmake/classes/tests/ttmv12.cpp index 81a368e..18700aa 100644 --- a/pre-cmake/classes/tests/ttmv12.cpp +++ b/pre-cmake/classes/tests/ttmv12.cpp @@ -22,7 +22,7 @@ int main(int argc, char ** argv) usage(argv[0]); if (!m.from_string(argv[1])) usage(argv[0]); - if (!tmvpoly_f2polymod_from_string(f, argv[2], m)) + if (!tmvpoly_f2_polymod_from_string(f, argv[2], m)) usage(argv[0]); zero = f2_polymod_t::prime_sfld_elt(0, m); diff --git a/pre-cmake/doc/berlekamp1.tex b/pre-cmake/doc/berlekamp1.tex index 8b2a2d3..e7435c9 100644 --- a/pre-cmake/doc/berlekamp1.tex +++ b/pre-cmake/doc/berlekamp1.tex @@ -206,7 +206,7 @@ \section{Example} These are $h_1 = 11100$ and $h_2 = 1$, respectively. Compute $\gcd(f, h_1) = 111$ and $\gcd(f, h_1+1) = 1011$ to obtain non-trivial factors of $f$. -%static void fppoly_berlekamp( +%static void fp_poly_berlekamp( % fp_poly_t f, % tfacinfo & rfinfo, % int recurse) @@ -271,7 +271,7 @@ \section{Example} % % int got_it = 0; % for (row = 0; row < dimker && !got_it; row++) { -% fp_poly_t h = fppoly_from_vector(nullspace_basis[row], n); +% fp_poly_t h = fp_poly_from_vector(nullspace_basis[row], n); % if (h == 1) % continue; % @@ -315,15 +315,15 @@ \section{Example} % rfinfo.insert_factor(f2); % } % else { -% fppoly_pre_berlekamp(f1, rfinfo, recurse); -% fppoly_pre_berlekamp(f2, rfinfo, recurse); +% fp_poly_pre_berlekamp(f1, rfinfo, recurse); +% fp_poly_pre_berlekamp(f2, rfinfo, recurse); % } %} -%static void f2poly_berlekamp( +%static void f2_poly_berlekamp( % f2_poly_t f, % tfacinfo & rfinfo, % int recurse) @@ -414,7 +414,7 @@ \section{Example} % % for (row = 0; row < dimker; row++) { % f2_poly_t h, hc; -% h = f2poly_from_vector(nullspace_basis[row], n); +% h = f2_poly_from_vector(nullspace_basis[row], n); % hc = h + f2_poly_t(1); % % f2_poly_t check1 = (h * h) % f; @@ -449,8 +449,8 @@ \section{Example} % rfinfo.insert_factor(f2); % } % else { -% f2poly_pre_berlekamp(f1, rfinfo, recurse); -% f2poly_pre_berlekamp(f2, rfinfo, recurse); +% f2_poly_pre_berlekamp(f1, rfinfo, recurse); +% f2_poly_pre_berlekamp(f2, rfinfo, recurse); % } % return; % } diff --git a/pre-cmake/doc/spffl.html b/pre-cmake/doc/spffl.html index 99810c0..9d48089 100644 --- a/pre-cmake/doc/spffl.html +++ b/pre-cmake/doc/spffl.html @@ -128,12 +128,12 @@

         #!/bin/sh
         p=7
-        elements="`spiff fplist -a $p`"
+        elements="`spiff fp_list -a $p`"
         for a in $elements
         do
                 for b in $elements
                 do
-                        c=`spiff fpop $p $a . $b`
+                        c=`spiff fp_op $p $a . $b`
                         echo -n " $c"
                 done
                 echo ""
@@ -361,7 +361,7 @@ 

Residue field - fpnpolyrat_t + fpn_polyrat_t fpnpr Fpn(y) Quotient field @@ -468,12 +468,12 @@

to do: many more
-bash$ f=`spiff f2pop 2 ^ 64 - 2`
+bash$ f=`spiff f2_p_op 2 ^ 64 - 2`
 
-bash$ spiff f2pfactor $f
+bash$ spiff f2_p_factor $f
 2 3 7 b d 43 49 57 5b 61 67 6d 73 75
 
-bash$ spiff f2pmtbl 13 .
+bash$ spiff f2_pm_tbl 13 .
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 1 2 3 4 5 6 7 8 9 a b c d e f
 0 2 4 6 8 a c e 3 1 7 5 b 9 f d
@@ -492,9 +492,9 @@ 

0 f d 2 9 6 4 b 1 e c 3 8 7 5 a m=13 -for r in `spiff f2pmlist -a $m` +for r in `spiff f2_pm_list -a $m` do - spiff f2pmchpol $m $r + spiff f2_pm_ch_pol $m $r done 1:0:0:0:0 @@ -514,7 +514,7 @@

1:1:0:0:1 1:1:1:1:1 -spiff f2pperiod `spiff f2plist 4` +spiff f2_p_period `spiff f2_p_list 4` 10: 0 11: 4 12: 0 @@ -532,7 +532,7 @@

1e: 0 1f: 5 -spiff fpord 35 `spiff fplist -u 35` +spiff fp_ord 35 `spiff fp_list -u 35` 1: 1 2: 12 3: 12 diff --git a/pre-cmake/examples/f2pcrt2.sh b/pre-cmake/examples/f2pcrt2.sh index f466ed0..df14ba7 100755 --- a/pre-cmake/examples/f2pcrt2.sh +++ b/pre-cmake/examples/f2pcrt2.sh @@ -7,9 +7,9 @@ do_once () { a=$3 b=$4 - c=`spiff f2pop $m . { f2pmop $n $b / $m } + $n . { f2pmop $m $a / $n }` - d=`spiff f2pmop $m $c . 1` - e=`spiff f2pmop $n $c . 1` + c=`spiff f2_p_op $m . { f2_pm_op $n $b / $m } + $n . { f2_pm_op $m $a / $n }` + d=`spiff f2_pm_op $m $c . 1` + e=`spiff f2_pm_op $n $c . 1` echo $a $b $c $d $e } @@ -23,9 +23,9 @@ if [ $# -eq 4 ]; then elif [ $# -eq 2 ]; then m=$1 n=$2 - for a in `spiff f2pmlist -a $m` + for a in `spiff f2_pm_list -a $m` do - for b in `spiff f2pmlist -a $n` + for b in `spiff f2_pm_list -a $n` do do_once $m $n $a $b done diff --git a/pre-cmake/examples/fppowers.sh b/pre-cmake/examples/fppowers.sh index 79bdbef..2e17cd4 100755 --- a/pre-cmake/examples/fppowers.sh +++ b/pre-cmake/examples/fppowers.sh @@ -10,7 +10,7 @@ shift for a do - g=`spiff zgcd $p $a` + g=`spiff z_gcd $p $a` if [ $g -ne 1 ]; then echo "$0: $a is not relatively prime to $p." 1>&2 exit 1 @@ -20,7 +20,7 @@ do while [ $ap -ne 1 ] do echo $ap - ap=`spiff fpop $p $ap . $a` + ap=`spiff fp_op $p $ap . $a` done echo $ap diff --git a/pre-cmake/examples/zcrt2.sh b/pre-cmake/examples/zcrt2.sh index 731179c..7457bb5 100755 --- a/pre-cmake/examples/zcrt2.sh +++ b/pre-cmake/examples/zcrt2.sh @@ -7,9 +7,9 @@ do_once () { a=$3 b=$4 - c=`spiff zop $m . { fpop $n $b / $m } + $n . { fpop $m $a / $n }` - d=`spiff fpop $m $c . 1` - e=`spiff fpop $n $c . 1` + c=`spiff z_op $m . { fp_op $n $b / $m } + $n . { fp_op $m $a / $n }` + d=`spiff fp_op $m $c . 1` + e=`spiff fp_op $n $c . 1` echo $a $b $c $d $e } @@ -23,9 +23,9 @@ if [ $# -eq 4 ]; then elif [ $# -eq 2 ]; then m=$1 n=$2 - for a in `spiff fplist -a $m` + for a in `spiff fp_list -a $m` do - for b in `spiff fplist -a $n` + for b in `spiff fp_list -a $n` do do_once $m $n $a $b done diff --git a/pre-cmake/regression/mkinputs.sh b/pre-cmake/regression/mkinputs.sh index b645198..10bb67a 100644 --- a/pre-cmake/regression/mkinputs.sh +++ b/pre-cmake/regression/mkinputs.sh @@ -5,23 +5,23 @@ mkdir -p data/input # ---------------------------------------------------------------- # Matrices -spiff f2matrandom 128 128 > data/input/f2-mat1.txt -spiff f2matrandom 128 128 > data/input/f2-mat2.txt +spiff f2_mat_random 128 128 > data/input/f2-mat1.txt +spiff f2_mat_random 128 128 > data/input/f2-mat2.txt -spiff f2matrandom 126 138 > data/input/f2-mat3.txt -spiff f2matrandom 138 122 > data/input/f2-mat4.txt +spiff f2_mat_random 126 138 > data/input/f2-mat3.txt +spiff f2_mat_random 138 122 > data/input/f2-mat4.txt -spiff f2matrandom 126 108 > data/input/f2-mat5.txt -spiff f2matrandom 108 123 > data/input/f2-mat6.txt +spiff f2_mat_random 126 108 > data/input/f2-mat5.txt +spiff f2_mat_random 108 123 > data/input/f2-mat6.txt -spiff f2pmmatrandom 11b 48 48 > data/input/f2pm-mat1.txt -spiff f2npmmatrandom 43 1:0:0:2 12 12 > data/input/f2npm-mat1.txt -spiff fpmatrandom 17 100 100 > data/input/fp-mat1.txt -spiff fppmmatrandom 11 1,0,9 20 20 > data/input/fppm-mat1.txt +spiff f2_pm_mat_random 11b 48 48 > data/input/f2pm-mat1.txt +spiff f2n_pm_mat_random 43 1:0:0:2 12 12 > data/input/f2npm-mat1.txt +spiff fp_mat_random 17 100 100 > data/input/fp-mat1.txt +spiff fp_pm_mat_random 11 1,0,9 20 20 > data/input/fppm-mat1.txt # ---------------------------------------------------------------- # Polyomials -spiff f2prandom 60 20 > data/input/f2-pols.txt -spiff f2nprandom 13 20 10 > data/input/f2n-pols.txt -spiff fpprandom 19 20 10 > data/input/fp-pols.txt +spiff f2_p_random 60 20 > data/input/f2-pols.txt +spiff f2n_p_random 13 20 10 > data/input/f2n-pols.txt +spiff fp_p_random 19 20 10 > data/input/fp-pols.txt diff --git a/pre-cmake/regression/regress.sh b/pre-cmake/regression/regress.sh index 1393440..bbc792c 100644 --- a/pre-cmake/regression/regress.sh +++ b/pre-cmake/regression/regress.sh @@ -5,139 +5,139 @@ mkdir -p data/outact # ---------------------------------------------------------------- # Integer factorization -spiff ztestprime { zlist 0 100 } > data/outact/ztestprime-0-100.txt -spiff zfactor { zlist 0 100 } > data/outact/zfactor-0-100.txt -spiff zdivisors { zlist 0 100 } > data/outact/zdivisors-0-100.txt +spiff z_test_prime { z_list 0 100 } > data/outact/z_test_prime-0-100.txt +spiff z_factor { z_list 0 100 } > data/outact/z_factor-0-100.txt +spiff z_divisors { z_list 0 100 } > data/outact/z_divisors-0-100.txt -spiff ztestprime { zlist 1000000 100 } > data/outact/ztestprime-1000000-100.txt -spiff zfactor { zlist 1000000 100 } > data/outact/zfactor-1000000-100.txt -spiff zdivisors { zlist 1000000 100 } > data/outact/zdivisors-1000000-100.txt +spiff z_test_prime { z_list 1000000 100 } > data/outact/z_test_prime-1000000-100.txt +spiff z_factor { z_list 1000000 100 } > data/outact/z_factor-1000000-100.txt +spiff z_divisors { z_list 1000000 100 } > data/outact/z_divisors-1000000-100.txt # ---------------------------------------------------------------- # Polynomial classification -spiff f2ptest -ip { f2plist 0-8 } > data/outact/f2ptest-0-8.txt -spiffsf f2nptest 7 { f2nplist 7 0-4 } > data/outact/f2nptest-0-8.txt -spiff fpptest 5 { fpplist 5 0-4 } > data/outact/fpptest-0-8.txt -spiff f2pperiod { f2plist 0-8 } > data/outact/f2pperiod-0-8.txt +spiff f2_p_test -ip { f2_p_list 0-8 } > data/outact/f2_p_test-0-8.txt +spiffsf f2n_p_test 7 { f2n_p_list 7 0-4 } > data/outact/f2n_p_test-0-8.txt +spiff fp_p_test 5 { fp_p_list 5 0-4 } > data/outact/fp_p_test-0-8.txt +spiff f2_p_period { f2_p_list 0-8 } > data/outact/f2_p_period-0-8.txt # ---------------------------------------------------------------- # Finite field tables -spiff f2pmtbl 13 + > data/outact/f2pm-13-add.txt -spiff f2pmtbl 13 - > data/outact/f2pm-13-sub.txt -spiff f2pmtbl 13 . > data/outact/f2pm-13-mul.txt -spiff f2pmtbl 13 / > data/outact/f2pm-13-div.txt +spiff f2_pm_tbl 13 + > data/outact/f2pm-13-add.txt +spiff f2_pm_tbl 13 - > data/outact/f2pm-13-sub.txt +spiff f2_pm_tbl 13 . > data/outact/f2pm-13-mul.txt +spiff f2_pm_tbl 13 / > data/outact/f2pm-13-div.txt -spiffsf f2npmtbl 3 1:0:1:2 + > data/outact/f2npm-3-1012-add.txt -spiffsf f2npmtbl 3 1:0:1:2 - > data/outact/f2npm-3-1012-sub.txt -spiffsf f2npmtbl 3 1:0:1:2 . > data/outact/f2npm-3-1012-mul.txt -spiffsf f2npmtbl 3 1:0:1:2 / > data/outact/f2npm-3-1012-div.txt +spiffsf f2n_pm_tbl 3 1:0:1:2 + > data/outact/f2npm-3-1012-add.txt +spiffsf f2n_pm_tbl 3 1:0:1:2 - > data/outact/f2npm-3-1012-sub.txt +spiffsf f2n_pm_tbl 3 1:0:1:2 . > data/outact/f2npm-3-1012-mul.txt +spiffsf f2n_pm_tbl 3 1:0:1:2 / > data/outact/f2npm-3-1012-div.txt -spiff fppmtbl 2 1011 + > data/outact/fppm-2-1011-add.txt -spiff fppmtbl 2 1011 - > data/outact/fppm-2-1011-sub.txt -spiff fppmtbl 2 1011 . > data/outact/fppm-2-1011-mul.txt -spiff fppmtbl 2 1011 / > data/outact/fppm-2-1011-div.txt +spiff fp_pm_tbl 2 1011 + > data/outact/fppm-2-1011-add.txt +spiff fp_pm_tbl 2 1011 - > data/outact/fppm-2-1011-sub.txt +spiff fp_pm_tbl 2 1011 . > data/outact/fppm-2-1011-mul.txt +spiff fp_pm_tbl 2 1011 / > data/outact/fppm-2-1011-div.txt -spiff fppmtbl 3 1021 + > data/outact/fppm-3-1021-add.txt -spiff fppmtbl 3 1021 - > data/outact/fppm-3-1021-sub.txt -spiff fppmtbl 3 1021 . > data/outact/fppm-3-1021-mul.txt -spiff fppmtbl 3 1021 / > data/outact/fppm-3-1021-div.txt +spiff fp_pm_tbl 3 1021 + > data/outact/fppm-3-1021-add.txt +spiff fp_pm_tbl 3 1021 - > data/outact/fppm-3-1021-sub.txt +spiff fp_pm_tbl 3 1021 . > data/outact/fppm-3-1021-mul.txt +spiff fp_pm_tbl 3 1021 / > data/outact/fppm-3-1021-div.txt # ---------------------------------------------------------------- # Polynomial factorization -spiff f2pfactor { f2plist 0-5 } > data/outact/f2-smpols-factor.txt -spiff f2pdivisors { f2plist 0-5 } > data/outact/f2-smpols-divisors.txt -spiff f2ptest -ip { f2plist 0-5 } > data/outact/f2-smpols-test.txt -spiff f2pgcd a f > data/outact/f2-smpols-gcd.txt -spiff f2plcm a f > data/outact/f2-smpols-lcm.txt +spiff f2_p_factor { f2_p_list 0-5 } > data/outact/f2-smpols-factor.txt +spiff f2_p_divisors { f2_p_list 0-5 } > data/outact/f2-smpols-divisors.txt +spiff f2_p_test -ip { f2_p_list 0-5 } > data/outact/f2-smpols-test.txt +spiff f2_p_gcd a f > data/outact/f2-smpols-gcd.txt +spiff f2_p_lcm a f > data/outact/f2-smpols-lcm.txt -spiffsf f2npfactor b { f2nplist b 0-3 } > data/outact/f2n-smpols-factor.txt -spiffsf f2npdivisors b { f2nplist b 0-3 } > data/outact/f2n-smpols-divisors.txt -spiffsf f2nptest b { f2nplist b 0-3 } > data/outact/f2n-smpols-test.txt -spiffsf f2npgcd b 3:4:a 6:7:9 > data/outact/f2n-smpols-gcd.txt -spiffsf f2nplcm b 3:4:a 6:7:9 > data/outact/f2n-smpols-lcm.txt +spiffsf f2n_p_factor b { f2n_p_list b 0-3 } > data/outact/f2n-smpols-factor.txt +spiffsf f2n_p_divisors b { f2n_p_list b 0-3 } > data/outact/f2n-smpols-divisors.txt +spiffsf f2n_p_test b { f2n_p_list b 0-3 } > data/outact/f2n-smpols-test.txt +spiffsf f2n_p_gcd b 3:4:a 6:7:9 > data/outact/f2n-smpols-gcd.txt +spiffsf f2n_p_lcm b 3:4:a 6:7:9 > data/outact/f2n-smpols-lcm.txt -spiffsf fppfactor 7 { fpplist 7 0-3 } > data/outact/fp-smpols-factor.txt -spiffsf fppdivisors 7 { fpplist 7 0-3 } > data/outact/fp-smpols-divisors.txt -spiffsf fpptest 7 { fpplist 7 0-3 } > data/outact/fp-smpols-test.txt -spiffsf fppgcd 7 1,3,2,6 2,4,5 > data/outact/fp-smpols-gcd.txt -spiffsf fpplcm 7 1,3,2,6 2,4,5 > data/outact/fp-smpols-lcm.txt +spiffsf fp_p_factor 7 { fp_p_list 7 0-3 } > data/outact/fp-smpols-factor.txt +spiffsf fp_p_divisors 7 { fp_p_list 7 0-3 } > data/outact/fp-smpols-divisors.txt +spiffsf fp_p_test 7 { fp_p_list 7 0-3 } > data/outact/fp-smpols-test.txt +spiffsf fp_p_gcd 7 1,3,2,6 2,4,5 > data/outact/fp-smpols-gcd.txt +spiffsf fp_p_lcm 7 1,3,2,6 2,4,5 > data/outact/fp-smpols-lcm.txt -spiff f2pfactor `cat data/input/f2-pols.txt` \ +spiff f2_p_factor `cat data/input/f2-pols.txt` \ > data/outact/f2-pols-factor.txt -spiff f2pdivisors `cat data/input/f2-pols.txt` \ +spiff f2_p_divisors `cat data/input/f2-pols.txt` \ > data/outact/f2-pols-divisors.txt -spiff f2ptest -ip `cat data/input/f2-pols.txt` \ +spiff f2_p_test -ip `cat data/input/f2-pols.txt` \ > data/outact/f2-pols-test.txt -spiff f2pgcd \ +spiff f2_p_gcd \ `sed -n 1p data/input/f2-pols.txt` `sed -n 2p data/input/f2-pols.txt` \ > data/outact/f2-pols-gcd.txt -spiff f2plcm \ +spiff f2_p_lcm \ `sed -n 1p data/input/f2-pols.txt` `sed -n 2p data/input/f2-pols.txt` \ > data/outact/f2-pols-lcm.txt -spiffsf f2npfactor 13 `cat data/input/f2n-pols.txt` \ +spiffsf f2n_p_factor 13 `cat data/input/f2n-pols.txt` \ > data/outact/f2n-pols-factor.txt -spiffsf f2npdivisors 13 `cat data/input/f2n-pols.txt` \ +spiffsf f2n_p_divisors 13 `cat data/input/f2n-pols.txt` \ > data/outact/f2n-pols-divisors.txt -spiffsf f2nptest 13 `cat data/input/f2n-pols.txt` \ +spiffsf f2n_p_test 13 `cat data/input/f2n-pols.txt` \ > data/outact/f2n-pols-test.txt -spiffsf f2npgcd 13 \ +spiffsf f2n_p_gcd 13 \ `sed -n 1p data/input/f2n-pols.txt` `sed -n 2p data/input/f2n-pols.txt` \ > data/outact/f2n-pols-gcd.txt -spiffsf f2nplcm 13 \ +spiffsf f2n_p_lcm 13 \ `sed -n 1p data/input/f2n-pols.txt` `sed -n 2p data/input/f2n-pols.txt` \ > data/outact/f2n-pols-lcm.txt -spiffsf fppfactor 19 `cat data/input/fp-pols.txt` \ +spiffsf fp_p_factor 19 `cat data/input/fp-pols.txt` \ > data/outact/fp-pols-factor.txt -spiffsf fppdivisors 19 `cat data/input/fp-pols.txt` \ +spiffsf fp_p_divisors 19 `cat data/input/fp-pols.txt` \ > data/outact/fp-pols-divisors.txt -spiffsf fpptest 19 `cat data/input/fp-pols.txt` \ +spiffsf fp_p_test 19 `cat data/input/fp-pols.txt` \ > data/outact/fp-pols-test.txt -spiffsf fppgcd 19 \ +spiffsf fp_p_gcd 19 \ `sed -n 1p data/input/fp-pols.txt` `sed -n 2p data/input/fp-pols.txt` \ > data/outact/fp-pols-gcd.txt -spiffsf fpplcm 19 \ +spiffsf fp_p_lcm 19 \ `sed -n 1p data/input/fp-pols.txt` `sed -n 2p data/input/fp-pols.txt` \ > data/outact/fp-pols-lcm.txt # ---------------------------------------------------------------- # Matrix arithmetic -spiff f2matop '[[1 1 0] [0 1 1] [1 1 1]]' . '[[0 1 1] [0 1 0] [1 1 0]]' \ +spiff f2_mat_op '[[1 1 0] [0 1 1] [1 1 1]]' . '[[0 1 1] [0 1 0] [1 1 0]]' \ > data/outact/f2-mat33.txt -spiff f2matop data/input/f2-mat1.txt . data/input/f2-mat2.txt \ +spiff f2_mat_op data/input/f2-mat1.txt . data/input/f2-mat2.txt \ > data/outact/f2-mat-1-1.txt -spiff f2matop data/input/f2-mat3.txt . data/input/f2-mat4.txt \ +spiff f2_mat_op data/input/f2-mat3.txt . data/input/f2-mat4.txt \ > data/outact/f2-mat-3-4.txt -spiff f2matop data/input/f2-mat5.txt . data/input/f2-mat6.txt \ +spiff f2_mat_op data/input/f2-mat5.txt . data/input/f2-mat6.txt \ > data/outact/f2-mat-5-6.txt -spiff f2matop det data/input/f2-mat1.txt > data/outact/f2-mat-det-1.txt +spiff f2_mat_op det data/input/f2-mat1.txt > data/outact/f2-mat-det-1.txt -spiff f2pmmatop 13 '[[6 a 9] [1 3 e] [c 7 0]]' . '[[1 f 1] [e b b] [d d 0]]' \ +spiff f2_pm_mat_op 13 '[[6 a 9] [1 3 e] [c 7 0]]' . '[[1 f 1] [e b b] [d d 0]]' \ > data/outact/f2pm-13-mat33.txt -spiffsf f2pmmatop 11b det data/input/f2pm-mat1.txt \ +spiffsf f2_pm_mat_op 11b det data/input/f2pm-mat1.txt \ > data/outact/f2pm-mat-det-1.txt -spiffsf f2pmmatop 11b inv data/input/f2pm-mat1.txt \ +spiffsf f2_pm_mat_op 11b inv data/input/f2pm-mat1.txt \ > data/outact/f2pm-mat-inv-1.txt -spiffsf f2npmmatop 43 1:0:0:2 det data/input/f2npm-mat1.txt \ +spiffsf f2n_pm_mat_op 43 1:0:0:2 det data/input/f2npm-mat1.txt \ > data/outact/f2npm-mat-det-1.txt -spiffsf f2npmmatop 43 1:0:0:2 inv data/input/f2npm-mat1.txt \ +spiffsf f2n_pm_mat_op 43 1:0:0:2 inv data/input/f2npm-mat1.txt \ > data/outact/f2npm-mat-inv-1.txt -spiff fpmatop 17 det data/input/fp-mat1.txt > data/outact/fp-mat-det-1.txt -spiff fpmatop 17 inv data/input/fp-mat1.txt > data/outact/fp-mat-inv-1.txt +spiff fp_mat_op 17 det data/input/fp-mat1.txt > data/outact/fp-mat-det-1.txt +spiff fp_mat_op 17 inv data/input/fp-mat1.txt > data/outact/fp-mat-inv-1.txt -spiff fppmmatop 11 1,0,9 det data/input/fppm-mat1.txt \ +spiff fp_pm_mat_op 11 1,0,9 det data/input/fppm-mat1.txt \ > data/outact/fppm-mat-det-1.txt -spiff fppmmatop 11 1,0,9 inv data/input/fppm-mat1.txt \ +spiff fp_pm_mat_op 11 1,0,9 inv data/input/fppm-mat1.txt \ > data/outact/fppm-mat-inv-1.txt # ---------------------------------------------------------------- diff --git a/pre-cmake/tools/f2pfactortest.sh b/pre-cmake/tools/f2pfactortest.sh index 59f2121..336a833 100644 --- a/pre-cmake/tools/f2pfactortest.sh +++ b/pre-cmake/tools/f2pfactortest.sh @@ -1,10 +1,10 @@ for n in `jot 1 1000` do - #r=`spiff f2prandom $n` - r=`spiff f2pop 2 ^ $n - 1` - if [ "`spiff ztestprime $n`" = "PRIME" ]; then + #r=`spiff f2_p_random $n` + r=`spiff f2_p_op 2 ^ $n - 1` + if [ "`spiff z_test_prime $n`" = "PRIME" ]; then echo deg=$n $r = - spiff f2pfactor $r + spiff f2_p_factor $r echo "" fi done diff --git a/pre-cmake/tools/f2pmchart.cpp b/pre-cmake/tools/f2pmchart.cpp index f2bd91c..87ef56d 100644 --- a/pre-cmake/tools/f2pmchart.cpp +++ b/pre-cmake/tools/f2pmchart.cpp @@ -198,7 +198,7 @@ static void find_irreds( flo = f2_poly_t::from_base_rep(1 << n); fhi = f2_poly_t::from_base_rep((1 << n+1) - 1); for (f = flo; f <= fhi; f.increment()) { - if (!f2poly_is_irreducible(f)) + if (!f2_poly_is_irreducible(f)) continue; if (count >= num_irreds) { @@ -286,7 +286,7 @@ static void fill_f2pm_chart( int rowi = 0; f2pm_chart_row_t * prow; - if (!f2polymod_find_generator(m, g)) { + if (!f2_polymod_find_generator(m, g)) { std::cerr << "Couldn't find generator for " << m << ".\n"; exit(1); } @@ -319,7 +319,7 @@ static void fill_f2pm_chart( prow->min_poly = f2pm_min_poly(elt); pchart->rows[rowi].num_roots = d; - pchart->rows[rowi].order = f2polymod_order(elt); + pchart->rows[rowi].order = f2_polymod_order(elt); for (j = 0; j < d; j++) { marks[orbit_log] = 1; diff --git a/pre-cmake/tools/f2pmop.cpp b/pre-cmake/tools/f2pmop.cpp index da1e5e7..ebf97e6 100644 --- a/pre-cmake/tools/f2pmop.cpp +++ b/pre-cmake/tools/f2pmop.cpp @@ -13,13 +13,13 @@ typedef void usage_t(char * argv0); typedef int main_t (int argc, char ** argv, usage_t * pusage); -static void f2pmop_usage(char * argv0) +static void f2_pm_op_usage(char * argv0) { std::cerr << "Usage: " << argv0 << " {m} ...\n"; exit(1); } -static int f2pmop_main(int argc, char ** argv, usage_t * pusage) +static int f2_pm_op_main(int argc, char ** argv, usage_t * pusage) { f2_poly_t m; if (argc < 2) @@ -34,5 +34,5 @@ static int f2pmop_main(int argc, char ** argv, usage_t * pusage) int main(int argc, char ** argv) { - return f2pmop_main(argc, argv, f2pmop_usage); + return f2_pm_op_main(argc, argv, f2_pm_op_usage); } diff --git a/pre-cmake/tools/fppmchart.cpp b/pre-cmake/tools/fppmchart.cpp index fb9620b..62057ef 100644 --- a/pre-cmake/tools/fppmchart.cpp +++ b/pre-cmake/tools/fppmchart.cpp @@ -9,7 +9,7 @@ #include #include "fp_polymod_t.h" #include "fp_poly_factor.h" -#include "fppolymod_units.h" +#include "fp_polymod_units.h" #include "min_char_polys.h" #include "moebius.h" #include "log10.h" @@ -213,7 +213,7 @@ static void find_irreds( flo = fp_poly_t::from_base_rep(1 << n); fhi = fp_poly_t::from_base_rep((1 << n+1) - 1); for (f = flo; f <= fhi; f.increment()) { - if (!fppoly_is_irreducible(f)) + if (!fp_poly_is_irreducible(f)) continue; if (count >= num_irreds) { @@ -301,7 +301,7 @@ static void fill_fppm_chart( int rowi = 0; fppm_chart_row_t * prow; - if (!fppolymod_find_generator(m, g)) { + if (!fp_polymod_find_generator(m, g)) { std::cerr << "Couldn't find generator for " << m << ".\n"; exit(1); } @@ -334,7 +334,7 @@ static void fill_fppm_chart( prow->min_poly = fppm_min_poly(elt); pchart->rows[rowi].num_roots = d; - pchart->rows[rowi].order = fppolymod_order(elt); + pchart->rows[rowi].order = fp_polymod_order(elt); for (j = 0; j < d; j++) { marks[orbit_log] = 1; diff --git a/pre-cmake/tools/minpoly.sh b/pre-cmake/tools/minpoly.sh index 766673f..5d17a3d 100644 --- a/pre-cmake/tools/minpoly.sh +++ b/pre-cmake/tools/minpoly.sh @@ -3,15 +3,15 @@ if [ $# -eq 1 ]; then n=$1 fi -spiff f2matrandom $n $n > a -chpol=`spiff f2pmmatchpol 3 a` +spiff f2_mat_random $n $n > a +chpol=`spiff f2_pm_mat_ch_pol 3 a` echo "char poly = $chpol" -echo "det = " `spiff f2npmatop 3 det a` +echo "det = " `spiff f2n_p_mat_op 3 det a` echo "A = " cat a echo "" -for p in `spiff f2npdivisors 3 $chpol` +for p in `spiff f2n_p_divisors 3 $chpol` do single 3 $p a done diff --git a/pre-cmake/tools/minpoly2.sh b/pre-cmake/tools/minpoly2.sh index 1b5147e..47a3dcc 100644 --- a/pre-cmake/tools/minpoly2.sh +++ b/pre-cmake/tools/minpoly2.sh @@ -9,15 +9,15 @@ if [ $# -eq 2 ]; then n=$2 fi -spiff f2pmmatrandom $m $n $n > a -chpol=`spiff f2pmmatchpol $m a` +spiff f2_pm_mat_random $m $n $n > a +chpol=`spiff f2_pm_mat_ch_pol $m a` echo "char poly = $chpol" -echo "det = " `spiff f2npmatop $m det a` +echo "det = " `spiff f2n_p_mat_op $m det a` echo "A = " cat a echo "" -for p in `spiff f2npdivisors $m $chpol` +for p in `spiff f2n_p_divisors $m $chpol` do single $m $p a done diff --git a/pre-cmake/tools/minpoly3.sh b/pre-cmake/tools/minpoly3.sh index b7a1de3..7689453 100644 --- a/pre-cmake/tools/minpoly3.sh +++ b/pre-cmake/tools/minpoly3.sh @@ -3,14 +3,14 @@ if [ $# -eq 1 ]; then m=$1 fi -spiff f2pcompmx $m > a -chpol=`spiff f2pmmatchpol 3 a` +spiff f2_p_comp_mx $m > a +chpol=`spiff f2_pm_mat_ch_pol 3 a` echo "char poly = $chpol" echo "A = " cat a echo "" -for p in `spiff f2npdivisors 3 $chpol` +for p in `spiff f2n_p_divisors 3 $chpol` do single 3 $p a done diff --git a/pre-cmake/tools/prof1.sh b/pre-cmake/tools/prof1.sh index ca0d837..28d3b13 100644 --- a/pre-cmake/tools/prof1.sh +++ b/pre-cmake/tools/prof1.sh @@ -1,2 +1,2 @@ -singlep f2pfactor { f2pop 2 ^ 2048 - 2 } +singlep f2_p_factor { f2_p_op 2 ^ 2048 - 2 } gprof singlep gmon.out > prof1.txt diff --git a/pre-cmake/tools/prof2.sh b/pre-cmake/tools/prof2.sh index b3f41b2..5dc58d3 100644 --- a/pre-cmake/tools/prof2.sh +++ b/pre-cmake/tools/prof2.sh @@ -1,2 +1,2 @@ -singlep fppfactor 2 { fppop 2 10 ^ 256 - 10 } +singlep fp_p_factor 2 { fp_p_op 2 10 ^ 256 - 10 } gprof singlep gmon.out > prof2.txt diff --git a/pre-cmake/tools/reval.cpp b/pre-cmake/tools/reval.cpp index ad72089..30f2cea 100644 --- a/pre-cmake/tools/reval.cpp +++ b/pre-cmake/tools/reval.cpp @@ -20,7 +20,7 @@ int main(int argc, char ** argv) usage(argv[0]); if (!m.from_string(argv[1])) usage(argv[0]); - if (!tmvrat_f2polymod_from_string(r, argv[2], m)) + if (!tmvrat_f2_polymod_from_string(r, argv[2], m)) usage(argv[0]); // if (xxx) r = r.homogenize(); int nvars = r.get_nvars(); diff --git a/pre-cmake/tools/single.cpp b/pre-cmake/tools/single.cpp index 4814281..cae5aaf 100644 --- a/pre-cmake/tools/single.cpp +++ b/pre-cmake/tools/single.cpp @@ -13,7 +13,7 @@ typedef void usage_t(char * argv0); typedef int main_t (int argc, char ** argv, usage_t * pusage); -static void f2pmmatsolve_usage(char * argv0) +static void f2_pm_mat_solve_usage(char * argv0) { std::cerr << "Usage: " << argv0 << " {m} {A} {b}\n"; std::cerr << "Solves A x = b for x, only when a unique solution exists.\n"; @@ -42,7 +42,7 @@ tmatrix f2np_poly_of_matrix( } // ---------------------------------------------------------------- -static int f2pmmatsolve_main(int argc, char ** argv, usage_t * pusage) +static int f2_pm_mat_solve_main(int argc, char ** argv, usage_t * pusage) { f2_poly_t m = 0; f2_polymod_t zero, one; @@ -69,5 +69,5 @@ static int f2pmmatsolve_main(int argc, char ** argv, usage_t * pusage) int main(int argc, char ** argv) { - return f2pmmatsolve_main(argc, argv, f2pmmatsolve_usage); + return f2_pm_mat_solve_main(argc, argv, f2_pm_mat_solve_usage); } diff --git a/pre-cmake/tools/solve_unique.cpp b/pre-cmake/tools/solve_unique.cpp index 14575c2..38b49a8 100644 --- a/pre-cmake/tools/solve_unique.cpp +++ b/pre-cmake/tools/solve_unique.cpp @@ -48,14 +48,14 @@ typedef void usage_t(char * argv0); typedef int main_t (int argc, char ** argv, usage_t * pusage); -static void f2pmmatsolve_usage(char * argv0) +static void f2_pm_mat_solve_usage(char * argv0) { std::cerr << "Usage: " << argv0 << " {m} {A} {b}\n"; std::cerr << "Solves A x = b for x, only when a unique solution exists.\n"; exit(1); } -static int f2pmmatsolve_main(int argc, char ** argv, usage_t * pusage) +static int f2_pm_mat_solve_main(int argc, char ** argv, usage_t * pusage) { f2_poly_t m = 0; f2_polymod_t zero, one; @@ -89,5 +89,5 @@ static int f2pmmatsolve_main(int argc, char ** argv, usage_t * pusage) int main(int argc, char ** argv) { - return f2pmmatsolve_main(argc, argv, f2pmmatsolve_usage); + return f2_pm_mat_solve_main(argc, argv, f2_pm_mat_solve_usage); } diff --git a/pre-cmake/tools/testf2pmmatchpol.sh b/pre-cmake/tools/testf2pmmatchpol.sh index fe44213..25b327b 100644 --- a/pre-cmake/tools/testf2pmmatchpol.sh +++ b/pre-cmake/tools/testf2pmmatchpol.sh @@ -1,11 +1,11 @@ -spiff f2pmmatrandom 13 8 8 > m +spiff f2_pm_mat_random 13 8 8 > m echo "M:" cat m echo "" -f=`spiff f2pmmatchpol 13 m` +f=`spiff f2_pm_mat_ch_pol 13 m` echo "chpol: $f" echo "" echo -n "factors: " -spiff f2npfactor 13 $f +spiff f2n_p_factor 13 $f diff --git a/pre-cmake/tools/testme.sh b/pre-cmake/tools/testme.sh index f09eef7..cf6d192 100644 --- a/pre-cmake/tools/testme.sh +++ b/pre-cmake/tools/testme.sh @@ -3,19 +3,19 @@ if [ $# -eq 1 ]; then n=$1 fi -spiff f2pmmatrandom 11b $n $n > a +spiff f2_pm_mat_random 11b $n $n > a echo "static fast:" -time spiffsf f2pmmatop 11b a ^ -1 > b +time spiffsf f2_pm_mat_op 11b a ^ -1 > b #echo "static prof:" -#time spiffsprof f2pmmatop 11b a ^ -1 > e +#time spiffsprof f2_pm_mat_op 11b a ^ -1 > e echo "static slow:" -time spiffs f2pmmatop 11b a ^ -1 > c +time spiffs f2_pm_mat_op 11b a ^ -1 > c echo "dyn link:" -time spiff f2pmmatop 11b a ^ -1 > d +time spiff f2_pm_mat_op 11b a ^ -1 > d echo "" echo "Checksums:" diff --git a/pre-cmake/tools/testz2npirr.sh b/pre-cmake/tools/testz2npirr.sh index 6e0613c..ae4c70a 100644 --- a/pre-cmake/tools/testz2npirr.sh +++ b/pre-cmake/tools/testz2npirr.sh @@ -13,10 +13,10 @@ fi for i in `jot 1 $n` do - f=`spiff f2nprandom $m $d` + f=`spiff f2n_p_random $m $d` echo -n $f echo -n ": " spiff f2npirr $m $f - spiff f2npfactor $m $f + spiff f2n_p_factor $m $f echo "" done diff --git a/pre-cmake/tools/todo.txt b/pre-cmake/tools/todo.txt index 6a18210..bcebe64 100644 --- a/pre-cmake/tools/todo.txt +++ b/pre-cmake/tools/todo.txt @@ -41,7 +41,7 @@ k points of degree n ... ! memoize lots of functions -- phi? gcd? * fppm log tbl. needs find_gen & what else? -k bit_matrix_t to accelerate f2pfactor +k bit_matrix_t to accelerate f2_p_factor ! other row-red routine for rings (must be EDs). Needs generic "gcd". @@ -124,7 +124,7 @@ fpn - . . . - k special bit matrix * sighdlr in find/rand irrs for status "wiid" * rename *linalg.* to something more appropriate. -* fix tfac binary search on f2pfactor 1e +* fix tfac binary search on f2_p_factor 1e ---------------------------------------------------------------- ! regression tests: @@ -148,7 +148,7 @@ k z*list * ffcomp: alg'ms, pfs out of appces & into own sections. k scalar * vec op*? k vec * matrix op*? -k bitmatrix to speed up f2pfactor +k bitmatrix to speed up f2_p_factor ================================================================ for ffcomp: diff --git a/pre-cmake/tools/zop.cpp b/pre-cmake/tools/zop.cpp index a95425c..dfa6ddc 100644 --- a/pre-cmake/tools/zop.cpp +++ b/pre-cmake/tools/zop.cpp @@ -18,7 +18,7 @@ static void zop_usage(char * argv0) exit(1); } -static int zop_main(int argc, char ** argv, usage_t * pusage) +static int z_op_main(int argc, char ** argv, usage_t * pusage) { cmd_line_parse(argc-1, argv+1, 0, 1); return 0; @@ -27,5 +27,5 @@ static int zop_main(int argc, char ** argv, usage_t * pusage) int main(int argc, char ** argv) { - return zop_main(argc, argv, zop_usage); + return z_op_main(argc, argv, zop_usage); } diff --git a/pre-cmake/utils/tmvpolyscan.cpp b/pre-cmake/utils/tmvpolyscan.cpp index 652ad0a..f8255fa 100644 --- a/pre-cmake/utils/tmvpolyscan.cpp +++ b/pre-cmake/utils/tmvpolyscan.cpp @@ -6,7 +6,7 @@ // // "2.3.1.0+4.0.1.1" -int tmvpoly_f2polymod_from_string( +int tmvpoly_f2_polymod_from_string( tmvpoly & f, const char * string, f2_poly_t m) @@ -28,7 +28,7 @@ int tmvpoly_f2polymod_from_string( } else { if (nvars != nvars0) { - std::cerr << "tmvpoly_f2polymod_from_string: all " + std::cerr << "tmvpoly_f2_polymod_from_string: all " "monomials must have same # variables.\n"; free(cpstring); delete [] monomv; @@ -38,7 +38,7 @@ int tmvpoly_f2polymod_from_string( if (nvars < 1) { std::cerr - << "tmvpoly_f2polymod_from_string: need >= 1 variable in \"" + << "tmvpoly_f2_polymod_from_string: need >= 1 variable in \"" << monomv[i] << "\".\n"; free(cpstring); delete [] monomv; @@ -52,7 +52,7 @@ int tmvpoly_f2polymod_from_string( f2_polymod_t coeff; if (!coeff.from_string(cvarv[0], m)) { std::cerr - << "tmvpoly_f2polymod_from_string: couldn't parse \"" + << "tmvpoly_f2_polymod_from_string: couldn't parse \"" << cvarv[0] << "\" as coefficient.\n"; free(cpstring); @@ -65,7 +65,7 @@ int tmvpoly_f2polymod_from_string( for (int j = 0; j < nvars; j++) { if (sscanf(cvarv[j+1], "%d", &expts[j]) != 1) { std::cerr - << "tmvpoly_f2polymod_from_string: couldn't parse \"" + << "tmvpoly_f2_polymod_from_string: couldn't parse \"" << cvarv[j+1] << "\" as exponent.\n"; free(cpstring); @@ -92,7 +92,7 @@ int tmvpoly_f2polymod_from_string( // // "2.3.1.0+4.0.1.1" -int tmvpoly_fppolymod_from_string( +int tmvpoly_fp_polymod_from_string( tmvpoly & f, const char * string, fp_poly_t m) @@ -114,7 +114,7 @@ int tmvpoly_fppolymod_from_string( } else { if (nvars != nvars0) { - std::cerr << "tmvpoly_fppolymod_from_string: all " + std::cerr << "tmvpoly_fp_polymod_from_string: all " "monomials must have same # variables.\n"; free(cpstring); delete [] monomv; @@ -124,7 +124,7 @@ int tmvpoly_fppolymod_from_string( if (nvars < 1) { std::cerr - << "tmvpoly_fppolymod_from_string: need >= 1 variable in \"" + << "tmvpoly_fp_polymod_from_string: need >= 1 variable in \"" << monomv[i] << "\".\n"; free(cpstring); delete [] monomv; @@ -138,7 +138,7 @@ int tmvpoly_fppolymod_from_string( fp_polymod_t coeff; if (!coeff.from_string(cvarv[0], m)) { std::cerr - << "tmvpoly_fppolymod_from_string: couldn't parse \"" + << "tmvpoly_fp_polymod_from_string: couldn't parse \"" << cvarv[0] << "\" as coefficient.\n"; free(cpstring); @@ -151,7 +151,7 @@ int tmvpoly_fppolymod_from_string( for (int j = 0; j < nvars; j++) { if (sscanf(cvarv[j+1], "%d", &expts[j]) != 1) { std::cerr - << "tmvpoly_fppolymod_from_string: couldn't parse \"" + << "tmvpoly_fp_polymod_from_string: couldn't parse \"" << cvarv[j+1] << "\" as exponent.\n"; free(cpstring); diff --git a/pre-cmake/utils/tmvpolyscan.h b/pre-cmake/utils/tmvpolyscan.h index cc03f55..909b66d 100644 --- a/pre-cmake/utils/tmvpolyscan.h +++ b/pre-cmake/utils/tmvpolyscan.h @@ -8,12 +8,12 @@ #include "fp_polymod_t.h" #include "tmvpoly.h" -int tmvpoly_f2polymod_from_string( +int tmvpoly_f2_polymod_from_string( tmvpoly & f, const char * string, f2_poly_t m); -int tmvpoly_fppolymod_from_string( +int tmvpoly_fp_polymod_from_string( tmvpoly & f, const char * string, fp_poly_t m); diff --git a/pre-cmake/utils/tmvratscan.cpp b/pre-cmake/utils/tmvratscan.cpp index fa1861b..78d917f 100644 --- a/pre-cmake/utils/tmvratscan.cpp +++ b/pre-cmake/utils/tmvratscan.cpp @@ -8,7 +8,7 @@ // // "2.3.1.0+4.0.1.1" -int tmvrat_f2polymod_from_string( +int tmvrat_f2_polymod_from_string( tmvrat & f, char * string, f2_poly_t m) @@ -17,7 +17,7 @@ int tmvrat_f2polymod_from_string( char * pslash = strchr(cpstring, '/'); if (!pslash) { // I don't know how to construct a generic 1. - std::cerr << "tmvrat_f2polymod_from_string: need numerator and denominator.\n"; + std::cerr << "tmvrat_f2_polymod_from_string: need numerator and denominator.\n"; exit(1); } *pslash = 0; @@ -25,11 +25,11 @@ int tmvrat_f2polymod_from_string( char * denom_string = pslash + 1; tmvpoly numer, denom; - if (!tmvpoly_f2polymod_from_string(numer, numer_string, m)) { + if (!tmvpoly_f2_polymod_from_string(numer, numer_string, m)) { free(cpstring); return 0; } - if (!tmvpoly_f2polymod_from_string(denom, denom_string, m)) { + if (!tmvpoly_f2_polymod_from_string(denom, denom_string, m)) { free(cpstring); return 0; } @@ -40,24 +40,24 @@ int tmvrat_f2polymod_from_string( } // ---------------------------------------------------------------- -int tmvrat_f2polymods_from_file( +int tmvrat_f2_polymods_from_file( char * file_name, tvector< tmvrat > & rats, f2_poly_t m) { if ((strcmp(file_name, "-") == 0) || (strcmp(file_name, "@") == 0)) - return tmvrat_f2polymods_from_stream(std::cin, rats, m); + return tmvrat_f2_polymods_from_stream(std::cin, rats, m); std::ifstream ifs; ifs.open(file_name, std::ifstream::in); if (ifs.fail()) { - std::cerr << "tmvrat_f2polymods_from_file: couldn't open \"" + std::cerr << "tmvrat_f2_polymods_from_file: couldn't open \"" << file_name << "\"\n"; return 0; } - if (!tmvrat_f2polymods_from_stream(ifs, rats, m)) { - std::cerr << "tmvrat_f2polymods_from_file: scan failure reading \"" + if (!tmvrat_f2_polymods_from_stream(ifs, rats, m)) { + std::cerr << "tmvrat_f2_polymods_from_file: scan failure reading \"" << file_name << "\"\n"; ifs.close(); return 0; @@ -67,7 +67,7 @@ int tmvrat_f2polymods_from_file( } // ---------------------------------------------------------------- -int tmvrat_f2polymods_from_stream( +int tmvrat_f2_polymods_from_stream( std::istream & is, tvector< tmvrat > & rats, f2_poly_t m) @@ -110,7 +110,7 @@ int tmvrat_f2polymods_from_stream( *phash = 0; // Scan - if (!tmvrat_f2polymod_from_string(prats[num_rats], line, m)) { + if (!tmvrat_f2_polymod_from_string(prats[num_rats], line, m)) { rv = 0; break; } @@ -122,7 +122,7 @@ int tmvrat_f2polymods_from_stream( if (num_rats == 0) { is.setstate(std::ios::badbit); - std::cerr << "tmvrat_f2polymods_from_stream >>: empty file.\n"; + std::cerr << "tmvrat_f2_polymods_from_stream >>: empty file.\n"; } rats = tvector< tmvrat >(num_rats); @@ -138,7 +138,7 @@ int tmvrat_f2polymods_from_stream( // // "2.3.1.0+4.0.1.1" -int tmvrat_fppolymod_from_string( +int tmvrat_fp_polymod_from_string( tmvrat & f, char * string, fp_poly_t m) @@ -147,7 +147,7 @@ int tmvrat_fppolymod_from_string( char * pslash = strchr(cpstring, '/'); if (!pslash) { // I don't know how to construct a generic 1. - std::cerr << "tmvrat_fppolymod_from_string: need numerator and denominator.\n"; + std::cerr << "tmvrat_fp_polymod_from_string: need numerator and denominator.\n"; exit(1); } *pslash = 0; @@ -155,11 +155,11 @@ int tmvrat_fppolymod_from_string( const char * denom_string = pslash + 1; tmvpoly numer, denom; - if (!tmvpoly_fppolymod_from_string(numer, numer_string, m)) { + if (!tmvpoly_fp_polymod_from_string(numer, numer_string, m)) { free(cpstring); return 0; } - if (!tmvpoly_fppolymod_from_string(denom, denom_string, m)) { + if (!tmvpoly_fp_polymod_from_string(denom, denom_string, m)) { free(cpstring); return 0; } diff --git a/pre-cmake/utils/tmvratscan.h b/pre-cmake/utils/tmvratscan.h index f48412b..130aa2a 100644 --- a/pre-cmake/utils/tmvratscan.h +++ b/pre-cmake/utils/tmvratscan.h @@ -8,22 +8,22 @@ #include "fp_polymod_t.h" #include "tmvrat.h" -int tmvrat_f2polymod_from_string( +int tmvrat_f2_polymod_from_string( tmvrat & f, char * string, f2_poly_t m); -int tmvrat_f2polymods_from_file( +int tmvrat_f2_polymods_from_file( char * file_name, tvector< tmvrat > & rats, f2_poly_t m); -int tmvrat_f2polymods_from_stream( +int tmvrat_f2_polymods_from_stream( std::istream & is, tvector< tmvrat > & rats, f2_poly_t m); -int tmvrat_fppolymod_from_string( +int tmvrat_fp_polymod_from_string( tmvrat & f, char * string, fp_poly_t m); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1e616b0..43b5ce9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,7 +8,7 @@ add_subdirectory(bits) add_subdirectory(containers) add_subdirectory(polynomials) add_subdirectory(rationals) -add_subdirectory(qcyclo) +add_subdirectory(q_cyclo) add_subdirectory(random) add_subdirectory(factorization) add_subdirectory(units) diff --git a/src/factorization/f2_poly_factor.cpp b/src/factorization/f2_poly_factor.cpp index 39cd2c3..36b52e7 100644 --- a/src/factorization/f2_poly_factor.cpp +++ b/src/factorization/f2_poly_factor.cpp @@ -21,15 +21,15 @@ namespace spffl::factorization { static void -f2poly_pre_berlekamp(spffl::polynomials::f2_poly_t f, +f2_poly_pre_berlekamp(spffl::polynomials::f2_poly_t f, tfacinfo &rfinfo, int recurse); -static void f2poly_berlekamp(spffl::polynomials::f2_poly_t f, +static void f2_poly_berlekamp(spffl::polynomials::f2_poly_t f, tfacinfo &rfinfo, int recurse); -spffl::polynomials::f2_poly_t f2poly_from_vector( +spffl::polynomials::f2_poly_t f2_poly_from_vector( #ifdef USE_BIT_MATRIX spffl::bits::bit_vector_t &v, #else @@ -45,13 +45,13 @@ f2_poly_factor(spffl::polynomials::f2_poly_t f) { finfo.insert_unit(f); return finfo; } - f2poly_pre_berlekamp(f, finfo, 1); + f2_poly_pre_berlekamp(f, finfo, 1); return finfo; } // ---------------------------------------------------------------- static void -f2poly_pre_berlekamp(spffl::polynomials::f2_poly_t f, +f2_poly_pre_berlekamp(spffl::polynomials::f2_poly_t f, tfacinfo &rfinfo, int recurse) { spffl::polynomials::f2_poly_t d = f.deriv(); @@ -59,7 +59,7 @@ f2poly_pre_berlekamp(spffl::polynomials::f2_poly_t f, #ifdef F2POLY_FACTOR_DEBUG std::cout << "\n"; - std::cout << "f2poly_pre_berlekamp input = " << f << " f' = " << d + std::cout << "f2_poly_pre_berlekamp input = " << f << " f' = " << d << " (f,f') = " << g << "\n"; #endif @@ -76,7 +76,7 @@ f2poly_pre_berlekamp(spffl::polynomials::f2_poly_t f, return; } else if (g == 1) { // Input is squarefree. - f2poly_berlekamp(f, rfinfo, recurse); + f2_poly_berlekamp(f, rfinfo, recurse); } else if (d == 0) { // Input is a perfect square spffl::polynomials::f2_poly_t s; @@ -88,7 +88,7 @@ f2poly_pre_berlekamp(spffl::polynomials::f2_poly_t f, } // Multiplicity is p only if degree is > 0. - f2poly_pre_berlekamp(s, sfinfo, recurse); + f2_poly_pre_berlekamp(s, sfinfo, recurse); if (f.find_degree() > 0) sfinfo.exp_all(2); rfinfo.merge(sfinfo); @@ -97,8 +97,8 @@ f2poly_pre_berlekamp(spffl::polynomials::f2_poly_t f, #endif } else { spffl::polynomials::f2_poly_t q = f / g; - f2poly_pre_berlekamp(g, rfinfo, recurse); - f2poly_pre_berlekamp(q, rfinfo, recurse); + f2_poly_pre_berlekamp(g, rfinfo, recurse); + f2_poly_pre_berlekamp(q, rfinfo, recurse); } } @@ -153,7 +153,7 @@ f2poly_pre_berlekamp(spffl::polynomials::f2_poly_t f, // These are h1 = 1c and h2 = 1, respectively. Compute gcd(f, h1) = 7 and // gcd(f, h1+1) = b to obtain non-trivial factors of f. -static void f2poly_berlekamp(spffl::polynomials::f2_poly_t f, +static void f2_poly_berlekamp(spffl::polynomials::f2_poly_t f, tfacinfo &rfinfo, int recurse) { int n = f.find_degree(); @@ -166,7 +166,7 @@ static void f2poly_berlekamp(spffl::polynomials::f2_poly_t f, #ifdef F2POLY_FACTOR_DEBUG std::cout << "\n"; - std::cout << "f2poly_berlekamp input = " << f << "\n"; + std::cout << "f2_poly_berlekamp input = " << f << "\n"; #endif #ifdef USE_BIT_MATRIX spffl::bits::bit_matrix_t BI(n, n); @@ -286,7 +286,7 @@ static void f2poly_berlekamp(spffl::polynomials::f2_poly_t f, for (row = 0; row < dimker; row++) { spffl::polynomials::f2_poly_t h, hc; - h = f2poly_from_vector(nullspace_basis[row], n); + h = f2_poly_from_vector(nullspace_basis[row], n); hc = h + spffl::polynomials::f2_poly_t(1); spffl::polynomials::f2_poly_t check1 = (h * h) % f; @@ -327,8 +327,8 @@ static void f2poly_berlekamp(spffl::polynomials::f2_poly_t f, rfinfo.insert_factor(f1); rfinfo.insert_factor(f2); } else { - f2poly_pre_berlekamp(f1, rfinfo, recurse); - f2poly_pre_berlekamp(f2, rfinfo, recurse); + f2_poly_pre_berlekamp(f1, rfinfo, recurse); + f2_poly_pre_berlekamp(f2, rfinfo, recurse); } return; } @@ -338,7 +338,7 @@ static void f2poly_berlekamp(spffl::polynomials::f2_poly_t f, } // ---------------------------------------------------------------- -spffl::polynomials::f2_poly_t f2poly_from_vector( +spffl::polynomials::f2_poly_t f2_poly_from_vector( #ifdef USE_BIT_MATRIX spffl::bits::bit_vector_t &v, #else @@ -373,8 +373,8 @@ spffl::polynomials::f2_poly_t f2poly_from_vector( //// 2^3 3^1 24 //// 2^3 3^2 72 // -// unsigned f2poly_num_divisors( -// f2poly_factor_info_t * pfinfo) +// unsigned f2_poly_num_divisors( +// f2_poly_factor_info_t * pfinfo) //{ // unsigned rv; // int i; @@ -382,7 +382,7 @@ spffl::polynomials::f2_poly_t f2poly_from_vector( // if ((pfinfo->num_distinct < 0) // || (pfinfo->num_distinct > F2POLY_MAX_NUM_FACTORS)) // { -// fprintf(stderr, "f2poly_num_divisors: num distinct (%d) " +// fprintf(stderr, "f2_poly_num_divisors: num distinct (%d) " // "out of bounds 0-%d\n", // pfinfo->num_distinct, F2POLY_MAX_NUM_FACTORS); // exit(1); @@ -398,8 +398,8 @@ spffl::polynomials::f2_poly_t f2poly_from_vector( //// See comments to the above. k is treated as a multibase representation //// over the bases mi+1. // -// spffl::polynomials::f2_poly_t f2poly_kth_divisor( -// f2poly_factor_info_t * pfinfo, +// spffl::polynomials::f2_poly_t f2_poly_kth_divisor( +// f2_poly_factor_info_t * pfinfo, // unsigned k) //{ // spffl::polynomials::f2_poly_t rv; @@ -408,14 +408,14 @@ spffl::polynomials::f2_poly_t f2poly_from_vector( // unsigned base; // unsigned power; // -// rv = f2poly_from_base_rep(1); +// rv = f2_poly_from_base_rep(1); // for (i = 0; i < pfinfo->num_distinct; i++) { // base = pfinfo->factor_counts[i].count + 1; // power = k % base; // k = k / base; // -// fp = f2poly_power(&pfinfo->factor_counts[i].f, power); -// rv = f2poly_mul(&rv, &fp); +// fp = f2_poly_power(&pfinfo->factor_counts[i].f, power); +// rv = f2_poly_mul(&rv, &fp); // } // return rv; //} @@ -423,30 +423,30 @@ spffl::polynomials::f2_poly_t f2poly_from_vector( //// ---------------------------------------------------------------- //// The caller must free the return value. // -// spffl::polynomials::f2_poly_t * f2poly_get_all_divisors( +// spffl::polynomials::f2_poly_t * f2_poly_get_all_divisors( // spffl::polynomials::f2_poly_t * pr, // unsigned * pnum_divisors) //{ -// f2poly_factor_info_t finfo; +// f2_poly_factor_info_t finfo; // unsigned nf, k; // spffl::polynomials::f2_poly_t * all_divisors; // // f2_poly_factor(pr, &finfo); -// nf = f2poly_num_divisors(&finfo); +// nf = f2_poly_num_divisors(&finfo); // *pnum_divisors = nf; // // all_divisors = (spffl::polynomials::f2_poly_t *)malloc_check(nf * //sizeof(spffl::polynomials::f2_poly_t)); for (k = 0; k < nf; k++) { -// all_divisors[k] = f2poly_kth_divisor(&finfo, k); +// all_divisors[k] = f2_poly_kth_divisor(&finfo, k); // } // qsort(all_divisors, nf, sizeof(spffl::polynomials::f2_poly_t), -//f2poly_qcmp); +//f2_poly_qcmp); // // return all_divisors; //} // ---------------------------------------------------------------- -int f2poly_is_irreducible(spffl::polynomials::f2_poly_t f) { +int f2_poly_is_irreducible(spffl::polynomials::f2_poly_t f) { tfacinfo finfo; int d = f.find_degree(); @@ -455,7 +455,7 @@ int f2poly_is_irreducible(spffl::polynomials::f2_poly_t f) { if (d == 1) return 1; - f2poly_pre_berlekamp(f, finfo, 0); + f2_poly_pre_berlekamp(f, finfo, 0); #ifdef FPPOLY_FACTOR_DEBUG std::cout << "f2pirr: input = " << f << "\n"; @@ -471,19 +471,19 @@ int f2poly_is_irreducible(spffl::polynomials::f2_poly_t f) { // ---------------------------------------------------------------- // Lexically lowest -spffl::polynomials::f2_poly_t f2poly_find_irr(int degree) { +spffl::polynomials::f2_poly_t f2_poly_find_irreducible(int degree) { spffl::polynomials::f2_poly_t rv(0); rv.set_bit(degree); rv.set_bit(0); if (degree < 1) { - std::cout << "f2poly_find_irr: degree must be positive; got " << degree + std::cout << "f2_poly_find_irreducible: degree must be positive; got " << degree << ".\n"; exit(1); } while (rv.find_degree() == degree) { - if (f2poly_is_irreducible(rv)) + if (f2_poly_is_irreducible(rv)) return rv; rv.increment(); rv.increment(); @@ -491,18 +491,18 @@ spffl::polynomials::f2_poly_t f2poly_find_irr(int degree) { // There are irreducibles of all positive degrees, so it is // an error if we failed to find one. - std::cout << "f2poly_find_irr: coding error.\n"; + std::cout << "f2_poly_find_irreducible: coding error.\n"; exit(1); return rv; } // ---------------------------------------------------------------- -spffl::polynomials::f2_poly_t f2poly_random_irr(int degree) { +spffl::polynomials::f2_poly_t f2_poly_random_irreducible(int degree) { spffl::polynomials::f2_poly_t rv; if (degree < 1) { - std::cout << "f2poly_random_irr: degree must be positive; got " << degree + std::cout << "f2_poly_random_irreducible: degree must be positive; got " << degree << ".\n"; exit(1); } @@ -510,7 +510,7 @@ spffl::polynomials::f2_poly_t f2poly_random_irr(int degree) { for (;;) { rv = spffl::random::f2_poly_random(degree); rv.set_bit(0); - if (f2poly_is_irreducible(rv)) + if (f2_poly_is_irreducible(rv)) return rv; } } diff --git a/src/factorization/f2_poly_factor.h b/src/factorization/f2_poly_factor.h index b54b52d..fa4a3e5 100644 --- a/src/factorization/f2_poly_factor.h +++ b/src/factorization/f2_poly_factor.h @@ -14,12 +14,12 @@ namespace spffl::factorization { tfacinfo f2_poly_factor(spffl::polynomials::f2_poly_t f); -int f2poly_is_irreducible(spffl::polynomials::f2_poly_t f); +int f2_poly_is_irreducible(spffl::polynomials::f2_poly_t f); // Lexically lowest. -spffl::polynomials::f2_poly_t f2poly_find_irr(int degree); +spffl::polynomials::f2_poly_t f2_poly_find_irreducible(int degree); -spffl::polynomials::f2_poly_t f2poly_random_irr(int degree); +spffl::polynomials::f2_poly_t f2_poly_random_irreducible(int degree); } // namespace spffl::factorization diff --git a/src/factorization/f2n_poly_factor.cpp b/src/factorization/f2n_poly_factor.cpp index 3225720..7d9e84d 100644 --- a/src/factorization/f2n_poly_factor.cpp +++ b/src/factorization/f2n_poly_factor.cpp @@ -15,16 +15,16 @@ namespace spffl::factorization { //#define F2NPOLY_FACTOR_DEBUG static void -f2npoly_pre_berlekamp(spffl::polynomials::f2n_poly_t f, +f2n_poly_pre_berlekamp(spffl::polynomials::f2n_poly_t f, tfacinfo &rfinfo, int recurse); -static void f2npoly_berlekamp(spffl::polynomials::f2n_poly_t f, +static void f2n_poly_berlekamp(spffl::polynomials::f2n_poly_t f, tfacinfo &rfinfo, int recurse); spffl::polynomials::f2n_poly_t -f2npoly_from_vector(tvector v, int n); +f2n_poly_from_vector(tvector v, int n); // ---------------------------------------------------------------- tfacinfo @@ -47,13 +47,13 @@ f2n_poly_factor(spffl::polynomials::f2n_poly_t f) { f /= leader; } - f2npoly_pre_berlekamp(f, finfo, 1); + f2n_poly_pre_berlekamp(f, finfo, 1); return finfo; } // ---------------------------------------------------------------- static void -f2npoly_pre_berlekamp(spffl::polynomials::f2n_poly_t f, +f2n_poly_pre_berlekamp(spffl::polynomials::f2n_poly_t f, tfacinfo &rfinfo, int recurse) { spffl::polynomials::f2n_poly_t d = f.deriv(); @@ -61,7 +61,7 @@ f2npoly_pre_berlekamp(spffl::polynomials::f2n_poly_t f, #ifdef F2NPOLY_FACTOR_DEBUG std::cout << "\n"; - std::cout << "f2npoly_pre_berlekamp input = " << f << " f' = " << d + std::cout << "f2n_poly_pre_berlekamp input = " << f << " f' = " << d << " (f,f') = " << g << "\n"; #endif @@ -75,7 +75,7 @@ f2npoly_pre_berlekamp(spffl::polynomials::f2n_poly_t f, return; } else if (g.find_degree() == 0) { // Input is squarefree. - f2npoly_berlekamp(f, rfinfo, recurse); + f2n_poly_berlekamp(f, rfinfo, recurse); } else if (d == 0) { // Input is a perfect square spffl::polynomials::f2n_poly_t s; @@ -91,7 +91,7 @@ f2npoly_pre_berlekamp(spffl::polynomials::f2n_poly_t f, #endif // Multiplicity is p only if degree is > 0. - f2npoly_pre_berlekamp(s, sfinfo, recurse); + f2n_poly_pre_berlekamp(s, sfinfo, recurse); if (f.find_degree() > 0) sfinfo.exp_all(2); rfinfo.merge(sfinfo); @@ -103,8 +103,8 @@ f2npoly_pre_berlekamp(spffl::polynomials::f2n_poly_t f, g /= g.get_coeff(g.find_degree()); q /= q.get_coeff(q.find_degree()); - f2npoly_pre_berlekamp(g, rfinfo, recurse); - f2npoly_pre_berlekamp(q, rfinfo, recurse); + f2n_poly_pre_berlekamp(g, rfinfo, recurse); + f2n_poly_pre_berlekamp(q, rfinfo, recurse); } } @@ -112,7 +112,7 @@ f2npoly_pre_berlekamp(spffl::polynomials::f2n_poly_t f, // See my "Computation in finite fields" (ffcomp.pdf) for a full description // of this algorithm. See f2_poly_factor.cpp for some sample data. -static void f2npoly_berlekamp(spffl::polynomials::f2n_poly_t f, +static void f2n_poly_berlekamp(spffl::polynomials::f2n_poly_t f, tfacinfo &rfinfo, int recurse) { int n = f.find_degree(); @@ -133,7 +133,7 @@ static void f2npoly_berlekamp(spffl::polynomials::f2n_poly_t f, #ifdef F2NPOLY_FACTOR_DEBUG std::cout << "\n"; - std::cout << "f2npoly_berlekamp input = " << f << "\n"; + std::cout << "f2n_poly_berlekamp input = " << f << "\n"; std::cout << "x" << " = " << x << "\n"; #endif @@ -201,7 +201,7 @@ static void f2npoly_berlekamp(spffl::polynomials::f2n_poly_t f, int got_it = 0; for (row = 0; row < dimker && !got_it; row++) { spffl::polynomials::f2n_poly_t h = - f2npoly_from_vector(nullspace_basis[row], n); + f2n_poly_from_vector(nullspace_basis[row], n); #ifdef F2NPOLY_FACTOR_DEBUG std::cout << "h = " << h << "\n"; #endif // F2NPOLY_FACTOR_DEBUG @@ -257,14 +257,14 @@ static void f2npoly_berlekamp(spffl::polynomials::f2n_poly_t f, rfinfo.insert_factor(f1); rfinfo.insert_factor(f2); } else { - f2npoly_pre_berlekamp(f1, rfinfo, recurse); - f2npoly_pre_berlekamp(f2, rfinfo, recurse); + f2n_poly_pre_berlekamp(f1, rfinfo, recurse); + f2n_poly_pre_berlekamp(f2, rfinfo, recurse); } } // ---------------------------------------------------------------- spffl::polynomials::f2n_poly_t -f2npoly_from_vector(tvector v, int n) { +f2n_poly_from_vector(tvector v, int n) { spffl::polynomials::f2n_poly_t f; f.set_coeff(0, v[0] - v[0]); for (int i = 0; i < n; i++) @@ -273,7 +273,7 @@ f2npoly_from_vector(tvector v, int n) { } // ---------------------------------------------------------------- -int f2npoly_roots(spffl::polynomials::f2n_poly_t f, +int f2n_poly_roots(spffl::polynomials::f2n_poly_t f, tvector &rroots) { tfacinfo finfo = f2n_poly_factor(f); int nf = finfo.get_num_distinct(); @@ -311,7 +311,7 @@ int f2npoly_roots(spffl::polynomials::f2n_poly_t f, } // ---------------------------------------------------------------- -int f2npoly_is_irreducible(spffl::polynomials::f2n_poly_t f) { +int f2n_poly_is_irreducible(spffl::polynomials::f2n_poly_t f) { tfacinfo finfo; int d = f.find_degree(); @@ -321,7 +321,7 @@ int f2npoly_is_irreducible(spffl::polynomials::f2n_poly_t f) { return 1; f /= f.get_coeff(d); - f2npoly_pre_berlekamp(f, finfo, 0); + f2n_poly_pre_berlekamp(f, finfo, 0); #ifdef F2NPOLY_FACTOR_DEBUG std::cout << "f2npirr: input = " << f << "\n"; @@ -337,7 +337,7 @@ int f2npoly_is_irreducible(spffl::polynomials::f2n_poly_t f) { // ---------------------------------------------------------------- // Lexically lowest -spffl::polynomials::f2n_poly_t f2npoly_find_irr(spffl::polynomials::f2_poly_t m, +spffl::polynomials::f2n_poly_t f2n_poly_find_irr(spffl::polynomials::f2_poly_t m, int degree) { spffl::polynomials::f2_poly_t c0(0), c1(1); spffl::polynomials::f2_polymod_t zero(c0, m), one(c1, m); @@ -345,14 +345,14 @@ spffl::polynomials::f2n_poly_t f2npoly_find_irr(spffl::polynomials::f2_poly_t m, rv.set_coeff(degree, one); if (degree < 1) { - std::cout << "f2npoly_find_irr: degree must be positive; got " << degree + std::cout << "f2n_poly_find_irr: degree must be positive; got " << degree << ".\n"; exit(1); } while (rv.find_degree() == degree) { if (rv.get_coeff(0) != zero) { - if (f2npoly_is_irreducible(rv)) + if (f2n_poly_is_irreducible(rv)) return rv; } rv.increment(); @@ -360,7 +360,7 @@ spffl::polynomials::f2n_poly_t f2npoly_find_irr(spffl::polynomials::f2_poly_t m, // There are irreducibles of all positive degrees, so it is // an error if we failed to find one. - std::cout << "f2npoly_find_irr: coding error.\n"; + std::cout << "f2n_poly_find_irr: coding error.\n"; exit(1); return rv; @@ -368,13 +368,13 @@ spffl::polynomials::f2n_poly_t f2npoly_find_irr(spffl::polynomials::f2_poly_t m, // ---------------------------------------------------------------- spffl::polynomials::f2n_poly_t -f2npoly_random_irr(spffl::polynomials::f2_poly_t m, int degree) { +f2n_poly_random_irr(spffl::polynomials::f2_poly_t m, int degree) { spffl::polynomials::f2_poly_t c0(0); spffl::polynomials::f2_polymod_t zero(c0, m); spffl::polynomials::f2n_poly_t rv; if (degree < 1) { - std::cout << "f2npoly_random_irr: degree must be positive; got " << degree + std::cout << "f2n_poly_random_irr: degree must be positive; got " << degree << ".\n"; exit(1); } @@ -383,7 +383,7 @@ f2npoly_random_irr(spffl::polynomials::f2_poly_t m, int degree) { rv = spffl::random::f2n_poly_random(m, degree); if (rv.get_coeff(0) == zero) continue; - if (f2npoly_is_irreducible(rv)) { + if (f2n_poly_is_irreducible(rv)) { rv /= rv.get_coeff(degree); // make monic return rv; } diff --git a/src/factorization/f2n_poly_factor.h b/src/factorization/f2n_poly_factor.h index 98fa28d..45c6252 100644 --- a/src/factorization/f2n_poly_factor.h +++ b/src/factorization/f2n_poly_factor.h @@ -16,18 +16,18 @@ tfacinfo f2n_poly_factor(spffl::polynomials::f2n_poly_t f); // Without multiplicity. -int f2npoly_roots(spffl::polynomials::f2n_poly_t f, +int f2n_poly_roots(spffl::polynomials::f2n_poly_t f, tvector &rroots); -int f2npoly_is_irreducible(spffl::polynomials::f2n_poly_t f); +int f2n_poly_is_irreducible(spffl::polynomials::f2n_poly_t f); // Lexically lowest (and therefore monic). -spffl::polynomials::f2n_poly_t f2npoly_find_irr(spffl::polynomials::f2_poly_t m, +spffl::polynomials::f2n_poly_t f2n_poly_find_irr(spffl::polynomials::f2_poly_t m, int degree); // Monic. spffl::polynomials::f2n_poly_t -f2npoly_random_irr(spffl::polynomials::f2_poly_t m, int degree); +f2n_poly_random_irr(spffl::polynomials::f2_poly_t m, int degree); } // namespace spffl::factorization diff --git a/src/factorization/fp_poly_factor.cpp b/src/factorization/fp_poly_factor.cpp index b7c5939..85904d0 100644 --- a/src/factorization/fp_poly_factor.cpp +++ b/src/factorization/fp_poly_factor.cpp @@ -15,16 +15,16 @@ namespace spffl::factorization { //#define FPPOLY_FACTOR_DEBUG static void -fppoly_pre_berlekamp(spffl::polynomials::fp_poly_t f, +fp_poly_pre_berlekamp(spffl::polynomials::fp_poly_t f, tfacinfo &rfinfo, int recurse); -static void fppoly_berlekamp(spffl::polynomials::fp_poly_t f, +static void fp_poly_berlekamp(spffl::polynomials::fp_poly_t f, tfacinfo &rfinfo, int recurse); spffl::polynomials::fp_poly_t -fppoly_from_vector(tvector v, int n); +fp_poly_from_vector(tvector v, int n); // ---------------------------------------------------------------- tfacinfo @@ -46,13 +46,13 @@ fp_poly_factor(spffl::polynomials::fp_poly_t f) { f /= leader; } - fppoly_pre_berlekamp(f, finfo, 1); + fp_poly_pre_berlekamp(f, finfo, 1); return finfo; } // ---------------------------------------------------------------- static void -fppoly_pre_berlekamp(spffl::polynomials::fp_poly_t f, +fp_poly_pre_berlekamp(spffl::polynomials::fp_poly_t f, tfacinfo &rfinfo, int recurse) { spffl::polynomials::fp_poly_t d = f.deriv(); @@ -60,7 +60,7 @@ fppoly_pre_berlekamp(spffl::polynomials::fp_poly_t f, #ifdef FPPOLY_FACTOR_DEBUG std::cout << "\n"; - std::cout << "fppoly_pre_berlekamp input = " << f << " f' = " << d + std::cout << "fp_poly_pre_berlekamp input = " << f << " f' = " << d << " (f,f') = " << g << "\n"; #endif @@ -74,7 +74,7 @@ fppoly_pre_berlekamp(spffl::polynomials::fp_poly_t f, return; } else if (g.find_degree() == 0) { // Input is squarefree. - fppoly_berlekamp(f, rfinfo, recurse); + fp_poly_berlekamp(f, rfinfo, recurse); } else if (d == 0) { // Input is a perfect pth power spffl::polynomials::fp_poly_t s; @@ -87,7 +87,7 @@ fppoly_pre_berlekamp(spffl::polynomials::fp_poly_t f, } // Multiplicity is p only if degree is > 0. - fppoly_pre_berlekamp(s, sfinfo, recurse); + fp_poly_pre_berlekamp(s, sfinfo, recurse); if (f.find_degree() > 0) sfinfo.exp_all(p); rfinfo.merge(sfinfo); @@ -99,8 +99,8 @@ fppoly_pre_berlekamp(spffl::polynomials::fp_poly_t f, g /= g.get_coeff(g.find_degree()); q /= q.get_coeff(q.find_degree()); - fppoly_pre_berlekamp(g, rfinfo, recurse); - fppoly_pre_berlekamp(q, rfinfo, recurse); + fp_poly_pre_berlekamp(g, rfinfo, recurse); + fp_poly_pre_berlekamp(q, rfinfo, recurse); } } @@ -108,7 +108,7 @@ fppoly_pre_berlekamp(spffl::polynomials::fp_poly_t f, // See my "Computation in finite fields" (ffcomp.pdf) for a full description // of this algorithm. See f2_poly_factor.cpp for some sample data. -static void fppoly_berlekamp(spffl::polynomials::fp_poly_t f, +static void fp_poly_berlekamp(spffl::polynomials::fp_poly_t f, tfacinfo &rfinfo, int recurse) { int n = f.find_degree(); @@ -127,7 +127,7 @@ static void fppoly_berlekamp(spffl::polynomials::fp_poly_t f, #ifdef FPPOLY_FACTOR_DEBUG std::cout << "\n"; - std::cout << "fppoly_berlekamp input = " << f << "\n"; + std::cout << "fp_poly_berlekamp input = " << f << "\n"; std::cout << "x" << " = " << x << "\n"; #endif @@ -195,7 +195,7 @@ static void fppoly_berlekamp(spffl::polynomials::fp_poly_t f, int got_it = 0; for (row = 0; row < dimker && !got_it; row++) { spffl::polynomials::fp_poly_t h = - fppoly_from_vector(nullspace_basis[row], n); + fp_poly_from_vector(nullspace_basis[row], n); #ifdef FPPOLY_FACTOR_DEBUG std::cout << "h = " << h << "\n"; #endif // FPPOLY_FACTOR_DEBUG @@ -246,14 +246,14 @@ static void fppoly_berlekamp(spffl::polynomials::fp_poly_t f, rfinfo.insert_factor(f1); rfinfo.insert_factor(f2); } else { - fppoly_pre_berlekamp(f1, rfinfo, recurse); - fppoly_pre_berlekamp(f2, rfinfo, recurse); + fp_poly_pre_berlekamp(f1, rfinfo, recurse); + fp_poly_pre_berlekamp(f2, rfinfo, recurse); } } // ---------------------------------------------------------------- spffl::polynomials::fp_poly_t -fppoly_from_vector(tvector v, int n) { +fp_poly_from_vector(tvector v, int n) { spffl::polynomials::fp_poly_t f; f.set_coeff(0, v[0] - v[0]); for (int i = 0; i < n; i++) @@ -262,7 +262,7 @@ fppoly_from_vector(tvector v, int n) { } // ---------------------------------------------------------------- -int fppoly_is_irreducible(spffl::polynomials::fp_poly_t f) { +int fp_poly_is_irreducible(spffl::polynomials::fp_poly_t f) { tfacinfo finfo; int d = f.find_degree(); @@ -272,7 +272,7 @@ int fppoly_is_irreducible(spffl::polynomials::fp_poly_t f) { return 1; f /= f.get_coeff(d); - fppoly_pre_berlekamp(f, finfo, 0); + fp_poly_pre_berlekamp(f, finfo, 0); #ifdef FPPOLY_FACTOR_DEBUG std::cout << "fppirr: input = " << f << "\n"; @@ -288,20 +288,20 @@ int fppoly_is_irreducible(spffl::polynomials::fp_poly_t f) { // ---------------------------------------------------------------- // Lexically lowest -spffl::polynomials::fp_poly_t fppoly_find_irr(int p, int degree) { +spffl::polynomials::fp_poly_t fp_poly_find_irr(int p, int degree) { spffl::intmath::intmod_t zero(0, p), one(1, p); spffl::polynomials::fp_poly_t rv = zero; rv.set_coeff(degree, one); if (degree < 1) { - std::cout << "fppoly_find_irr: degree must be positive; got " << degree + std::cout << "fp_poly_find_irr: degree must be positive; got " << degree << ".\n"; exit(1); } while (rv.find_degree() == degree) { if (rv.get_coeff(0) != zero) { - if (fppoly_is_irreducible(rv)) + if (fp_poly_is_irreducible(rv)) return rv; } rv.increment(); @@ -310,19 +310,19 @@ spffl::polynomials::fp_poly_t fppoly_find_irr(int p, int degree) { // There are irreducibles of all positive degrees, so it is // an error if we failed to find one. - std::cout << "fppoly_find_irr: coding error.\n"; + std::cout << "fp_poly_find_irr: coding error.\n"; exit(1); return rv; } // ---------------------------------------------------------------- -spffl::polynomials::fp_poly_t fppoly_random_irr(int p, int degree) { +spffl::polynomials::fp_poly_t fp_poly_random_irr(int p, int degree) { spffl::intmath::intmod_t zero(0, p); spffl::polynomials::fp_poly_t rv; if (degree < 1) { - std::cout << "fppoly_random_irr: degree must be positive; got " << degree + std::cout << "fp_poly_random_irr: degree must be positive; got " << degree << ".\n"; exit(1); } @@ -331,7 +331,7 @@ spffl::polynomials::fp_poly_t fppoly_random_irr(int p, int degree) { rv = spffl::random::fp_poly_random(p, degree); if (rv.get_coeff(0) == zero) continue; - if (fppoly_is_irreducible(rv)) { + if (fp_poly_is_irreducible(rv)) { rv /= rv.get_coeff(degree); // make monic return rv; } diff --git a/src/factorization/fp_poly_factor.h b/src/factorization/fp_poly_factor.h index 8b54eef..a4267b2 100644 --- a/src/factorization/fp_poly_factor.h +++ b/src/factorization/fp_poly_factor.h @@ -14,13 +14,13 @@ namespace spffl::factorization { tfacinfo fp_poly_factor(spffl::polynomials::fp_poly_t f); -int fppoly_is_irreducible(spffl::polynomials::fp_poly_t f); +int fp_poly_is_irreducible(spffl::polynomials::fp_poly_t f); // Lexically lowest (and therefore monic). -spffl::polynomials::fp_poly_t fppoly_find_irr(int p, int degree); +spffl::polynomials::fp_poly_t fp_poly_find_irr(int p, int degree); // Monic. -spffl::polynomials::fp_poly_t fppoly_random_irr(int p, int degree); +spffl::polynomials::fp_poly_t fp_poly_random_irr(int p, int degree); } // namespace spffl::factorization diff --git a/src/linalg/f2_linear_algebra.cpp b/src/linalg/f2_linear_algebra.cpp index 46a44ae..cc163e1 100644 --- a/src/linalg/f2_linear_algebra.cpp +++ b/src/linalg/f2_linear_algebra.cpp @@ -83,7 +83,7 @@ f2_companion_matrix(spffl::polynomials::f2_poly_t chpol) { // ---------------------------------------------------------------- static spffl::polynomials::f2n_poly_t -f2polymod_char_or_min_poly(spffl::polynomials::f2_polymod_t a, bool do_min) { +f2_polymod_char_or_min_poly(spffl::polynomials::f2_polymod_t a, bool do_min) { spffl::polynomials::f2_poly_t m = a.get_modulus(); int d = m.find_degree(); spffl::polynomials::f2_poly_t r1(1); @@ -104,14 +104,14 @@ f2polymod_char_or_min_poly(spffl::polynomials::f2_polymod_t a, bool do_min) { // ---------------------------------------------------------------- spffl::polynomials::f2n_poly_t -f2polymod_char_poly(spffl::polynomials::f2_polymod_t a) { - return f2polymod_char_or_min_poly(a, 0); +f2_polymod_char_poly(spffl::polynomials::f2_polymod_t a) { + return f2_polymod_char_or_min_poly(a, 0); } // ---------------------------------------------------------------- spffl::polynomials::f2n_poly_t -f2polymod_min_poly(spffl::polynomials::f2_polymod_t a) { - return f2polymod_char_or_min_poly(a, 1); +f2_polymod_min_poly(spffl::polynomials::f2_polymod_t a) { + return f2_polymod_char_or_min_poly(a, 1); } } // namespace spffl::linalg diff --git a/src/linalg/f2_linear_algebra.h b/src/linalg/f2_linear_algebra.h index f5f0994..380a756 100644 --- a/src/linalg/f2_linear_algebra.h +++ b/src/linalg/f2_linear_algebra.h @@ -25,10 +25,10 @@ tmatrix f2_companion_matrix(spffl::polynomials::f2_poly_t chpol); spffl::polynomials::f2n_poly_t -f2polymod_min_poly(spffl::polynomials::f2_polymod_t a); +f2_polymod_min_poly(spffl::polynomials::f2_polymod_t a); spffl::polynomials::f2n_poly_t -f2polymod_char_poly(spffl::polynomials::f2_polymod_t a); +f2_polymod_char_poly(spffl::polynomials::f2_polymod_t a); } // namespace spffl::linalg diff --git a/src/linalg/f2_polymod_convert.cpp b/src/linalg/f2_polymod_convert.cpp index 5ebf28a..342960b 100644 --- a/src/linalg/f2_polymod_convert.cpp +++ b/src/linalg/f2_polymod_convert.cpp @@ -12,14 +12,14 @@ namespace spffl::linalg { // ---------------------------------------------------------------- -int f2polymod_convert_prep(spffl::polynomials::f2_polymod_t g1, +int f2_polymod_convert_prep(spffl::polynomials::f2_polymod_t g1, spffl::polynomials::f2_poly_t m2, spffl::polynomials::f2_polymod_t &rg2) { - spffl::polynomials::f2n_poly_t g1_min_poly = f2polymod_min_poly(g1); + spffl::polynomials::f2n_poly_t g1_min_poly = f2_polymod_min_poly(g1); spffl::polynomials::f2n_poly_t g2_min_poly = g1_min_poly; g2_min_poly.change_modulus(m2); tvector roots; - if (!spffl::factorization::f2npoly_roots(g2_min_poly, roots)) + if (!spffl::factorization::f2n_poly_roots(g2_min_poly, roots)) return 0; if (roots.get_num_elements() != g2_min_poly.find_degree()) return 0; @@ -30,7 +30,7 @@ int f2polymod_convert_prep(spffl::polynomials::f2_polymod_t g1, // ---------------------------------------------------------------- spffl::polynomials::f2_polymod_t -f2polymod_convert_scalar(spffl::polynomials::f2_polymod_t g1, +f2_polymod_convert_scalar(spffl::polynomials::f2_polymod_t g1, spffl::polynomials::f2_polymod_t g2, spffl::polynomials::f2_polymod_t a1) { spffl::polynomials::f2_polymod_t zero1 = g1 - g1; @@ -38,24 +38,24 @@ f2polymod_convert_scalar(spffl::polynomials::f2_polymod_t g1, if (a1 == zero1) return zero2; else - return g2.exp(spffl::units::f2polymod_log(g1, a1)); + return g2.exp(spffl::units::f2_polymod_log(g1, a1)); } // ---------------------------------------------------------------- spffl::polynomials::f2n_poly_t -f2polymod_convert_poly(spffl::polynomials::f2_polymod_t g1, +f2_polymod_convert_poly(spffl::polynomials::f2_polymod_t g1, spffl::polynomials::f2_polymod_t g2, spffl::polynomials::f2n_poly_t f1) { int deg = f1.find_degree(); spffl::polynomials::f2n_poly_t f2(f1); for (int i = 0; i <= deg; i++) - f2.set_coeff(i, f2polymod_convert_scalar(g1, g2, f1.get_coeff(i))); + f2.set_coeff(i, f2_polymod_convert_scalar(g1, g2, f1.get_coeff(i))); return f2; } // ---------------------------------------------------------------- tmatrix -f2polymod_convert_matrix(spffl::polynomials::f2_polymod_t g1, +f2_polymod_convert_matrix(spffl::polynomials::f2_polymod_t g1, spffl::polynomials::f2_polymod_t g2, tmatrix A1) { int nr = A1.get_num_rows(); @@ -63,7 +63,7 @@ f2polymod_convert_matrix(spffl::polynomials::f2_polymod_t g1, tmatrix A2(nr, nc); for (int i = 0; i < nr; i++) for (int j = 0; j < nc; j++) - A2[i][j] = f2polymod_convert_scalar(g1, g2, A1[i][j]); + A2[i][j] = f2_polymod_convert_scalar(g1, g2, A1[i][j]); return A2; } diff --git a/src/linalg/f2_polymod_convert.h b/src/linalg/f2_polymod_convert.h index f3cd10a..4302cdc 100644 --- a/src/linalg/f2_polymod_convert.h +++ b/src/linalg/f2_polymod_convert.h @@ -12,22 +12,22 @@ namespace spffl::linalg { -int f2polymod_convert_prep(spffl::polynomials::f2_polymod_t g1, +int f2_polymod_convert_prep(spffl::polynomials::f2_polymod_t g1, spffl::polynomials::f2_poly_t m2, spffl::polynomials::f2_polymod_t &rg2); spffl::polynomials::f2_polymod_t -f2polymod_convert_scalar(spffl::polynomials::f2_polymod_t g1, +f2_polymod_convert_scalar(spffl::polynomials::f2_polymod_t g1, spffl::polynomials::f2_polymod_t g2, spffl::polynomials::f2_polymod_t a1); spffl::polynomials::f2n_poly_t -f2polymod_convert_poly(spffl::polynomials::f2_polymod_t g1, +f2_polymod_convert_poly(spffl::polynomials::f2_polymod_t g1, spffl::polynomials::f2_polymod_t g2, spffl::polynomials::f2n_poly_t f1); tmatrix -f2polymod_convert_matrix(spffl::polynomials::f2_polymod_t g1, +f2_polymod_convert_matrix(spffl::polynomials::f2_polymod_t g1, spffl::polynomials::f2_polymod_t g2, tmatrix A1); diff --git a/src/linalg/f2_polymod_linear_algebra.cpp b/src/linalg/f2_polymod_linear_algebra.cpp index 68f2d16..53632d2 100644 --- a/src/linalg/f2_polymod_linear_algebra.cpp +++ b/src/linalg/f2_polymod_linear_algebra.cpp @@ -135,7 +135,7 @@ int f2pm_matrix_is_dable( // Use specified modulus if degrees are equal. rext_modulus = base_modulus; } else { - rext_modulus = spffl::factorization::f2poly_find_irr(absolute_ext_degree); + rext_modulus = spffl::factorization::f2_poly_find_irreducible(absolute_ext_degree); } if (verbose) { @@ -153,17 +153,17 @@ int f2pm_matrix_is_dable( } else { spffl::polynomials::f2_polymod_t base_g, ext_g; - if (!spffl::units::f2polymod_find_generator(base_modulus, base_g)) { + if (!spffl::units::f2_polymod_find_generator(base_modulus, base_g)) { std::cerr << "Can't find generator mod " << base_modulus << ".\n"; exit(1); } - if (!f2polymod_convert_prep(base_g, rext_modulus, ext_g)) { + if (!f2_polymod_convert_prep(base_g, rext_modulus, ext_g)) { std::cerr << "Can't find generator mod " << rext_modulus << ".\n"; exit(1); } - ext_chpol = f2polymod_convert_poly(base_g, ext_g, chpol); - ext_A = f2polymod_convert_matrix(base_g, ext_g, A); + ext_chpol = f2_polymod_convert_poly(base_g, ext_g, chpol); + ext_A = f2_polymod_convert_matrix(base_g, ext_g, A); } tfacinfo ext_finfo = diff --git a/src/linalg/fp_linear_algebra.cpp b/src/linalg/fp_linear_algebra.cpp index 345893b..1192ecf 100644 --- a/src/linalg/fp_linear_algebra.cpp +++ b/src/linalg/fp_linear_algebra.cpp @@ -76,7 +76,7 @@ fp_companion_matrix(spffl::polynomials::fp_poly_t chpol) { #if 0 // ---------------------------------------------------------------- -static spffl::polynomials::fpn_poly_t fppolymod_char_or_min_poly( +static spffl::polynomials::fpn_poly_t fp_polymod_char_or_min_poly( spffl::polynomials::fp_polymod_t a, bool do_min) { @@ -100,17 +100,17 @@ static spffl::polynomials::fpn_poly_t fppolymod_char_or_min_poly( } // ---------------------------------------------------------------- -spffl::polynomials::fpn_poly_t fppolymod_char_poly( +spffl::polynomials::fpn_poly_t fp_polymod_char_poly( spffl::polynomials::fp_polymod_t a) { - return fppolymod_char_or_min_poly(a, 0); + return fp_polymod_char_or_min_poly(a, 0); } // ---------------------------------------------------------------- -spffl::polynomials::fpn_poly_t fppolymod_min_poly( +spffl::polynomials::fpn_poly_t fp_polymod_min_poly( spffl::polynomials::fp_polymod_t a) { - return fppolymod_char_or_min_poly(a, 1); + return fp_polymod_char_or_min_poly(a, 1); } #endif diff --git a/src/linalg/fp_linear_algebra.h b/src/linalg/fp_linear_algebra.h index 210c10d..9db7e00 100644 --- a/src/linalg/fp_linear_algebra.h +++ b/src/linalg/fp_linear_algebra.h @@ -25,10 +25,10 @@ tmatrix fp_companion_matrix(spffl::polynomials::fp_poly_t chpol); #if 0 -spffl::polynomials::fpn_poly_t fppolymod_min_poly( +spffl::polynomials::fpn_poly_t fp_polymod_min_poly( spffl::polynomials::fp_polymod_t a); -spffl::polynomials::fpn_poly_t fppolymod_char_poly( +spffl::polynomials::fpn_poly_t fp_polymod_char_poly( spffl::polynomials::fp_polymod_t a); #endif diff --git a/src/list/list_elements.cpp b/src/list/list_elements.cpp index e80cc79..9592803 100644 --- a/src/list/list_elements.cpp +++ b/src/list/list_elements.cpp @@ -15,7 +15,7 @@ namespace spffl::list { // ---------------------------------------------------------------- -tvector f2poly_list(int deg) { +tvector f2_poly_list(int deg) { int nel = 1 << deg; tvector rv(nel); @@ -34,7 +34,7 @@ tvector f2poly_list(int deg) { // ---------------------------------------------------------------- tvector -f2npoly_list(spffl::polynomials::f2_poly_t im, int outerdeg) { +f2n_poly_list(spffl::polynomials::f2_poly_t im, int outerdeg) { int innerdeg = im.find_degree(); int q = 1 << innerdeg; int nel = (q - 1) * spffl::intmath::int_power(q, outerdeg); @@ -56,7 +56,7 @@ f2npoly_list(spffl::polynomials::f2_poly_t im, int outerdeg) { } // ---------------------------------------------------------------- -tvector fppoly_list(int p, int deg) { +tvector fp_poly_list(int p, int deg) { int nel = (p - 1) * spffl::intmath::int_power(p, deg); tvector rv(nel); @@ -110,7 +110,7 @@ tvector intmod_list(int p, sp_list_type_t type) { // ---------------------------------------------------------------- tvector -f2polymod_list(spffl::polynomials::f2_poly_t m, sp_list_type_t type) { +f2_polymod_list(spffl::polynomials::f2_poly_t m, sp_list_type_t type) { int deg = m.find_degree(); int nel; if (type == SP_LIST_ALL) @@ -120,7 +120,7 @@ f2polymod_list(spffl::polynomials::f2_poly_t m, sp_list_type_t type) { else if (type == SP_LIST_NON_UNITS) nel = (1 << deg) - spffl::factorization::f2_poly_totient(m); else { - std::cerr << "f2polymod_list: unhandled code option.\n"; + std::cerr << "f2_polymod_list: unhandled code option.\n"; exit(1); } tvector rv(nel); @@ -156,7 +156,7 @@ f2polymod_list(spffl::polynomials::f2_poly_t m, sp_list_type_t type) { // ---------------------------------------------------------------- tvector -f2npolymod_list(spffl::polynomials::f2n_poly_t om, sp_list_type_t type) { +f2n_polymod_list(spffl::polynomials::f2n_poly_t om, sp_list_type_t type) { spffl::polynomials::f2_polymod_t c0 = om.get_coeff(0); spffl::polynomials::f2_poly_t im = c0.get_modulus(); int outerdeg = om.find_degree(); @@ -170,7 +170,7 @@ f2npolymod_list(spffl::polynomials::f2n_poly_t om, sp_list_type_t type) { nel = (1 << (outerdeg * innerdeg)) - spffl::factorization::f2n_poly_totient(om); else { - std::cerr << "f2npolymod_list: unhandled code option.\n"; + std::cerr << "f2n_polymod_list: unhandled code option.\n"; exit(1); } tvector rv(nel); @@ -207,7 +207,7 @@ f2npolymod_list(spffl::polynomials::f2n_poly_t om, sp_list_type_t type) { // ---------------------------------------------------------------- tvector -fppolymod_list(spffl::polynomials::fp_poly_t m, sp_list_type_t type) { +fp_polymod_list(spffl::polynomials::fp_poly_t m, sp_list_type_t type) { int p = m.get_char(); int n = m.find_degree(); int nel; @@ -219,7 +219,7 @@ fppolymod_list(spffl::polynomials::fp_poly_t m, sp_list_type_t type) { nel = spffl::intmath::int_power(p, n) - spffl::factorization::fp_poly_totient(m); else { - std::cerr << "fppolymod_list: unhandled code option.\n"; + std::cerr << "fp_polymod_list: unhandled code option.\n"; exit(1); } tvector rv(nel); @@ -255,7 +255,7 @@ fppolymod_list(spffl::polynomials::fp_poly_t m, sp_list_type_t type) { // ---------------------------------------------------------------- tvector -f2polymod_glist(spffl::polynomials::f2_polymod_t g, sp_list_type_t type) { +f2_polymod_glist(spffl::polynomials::f2_polymod_t g, sp_list_type_t type) { spffl::polynomials::f2_poly_t m = g.get_modulus(); spffl::polynomials::f2_poly_t gres = g.get_residue(); spffl::polynomials::f2_poly_t gr = m.gcd(gres); @@ -314,14 +314,14 @@ tvector intmod_glist(spffl::intmath::intmod_t g, // ---------------------------------------------------------------- tmatrix -f2polymod_An_list(spffl::polynomials::f2_poly_t m, int n) { +f2_polymod_An_list(spffl::polynomials::f2_poly_t m, int n) { int d = m.find_degree(); int q = 1 << d; int qn = spffl::intmath::int_power(q, n); tmatrix rv(qn, n); int i, j; - tvector Fq = f2polymod_list(m, SP_LIST_ALL); + tvector Fq = f2_polymod_list(m, SP_LIST_ALL); for (i = 0; i < qn; i++) { int baserep = i; @@ -342,11 +342,11 @@ f2polymod_An_list(spffl::polynomials::f2_poly_t m, int n) { // # = q^0 + q^2 tmatrix -f2polymod_Pn_list(spffl::polynomials::f2_poly_t m, int n) { +f2_polymod_Pn_list(spffl::polynomials::f2_poly_t m, int n) { int i, j, k; int d = m.find_degree(); int q = 1 << d; - tvector Fq = f2polymod_list(m, SP_LIST_ALL); + tvector Fq = f2_polymod_list(m, SP_LIST_ALL); spffl::polynomials::f2_polymod_t zero = spffl::polynomials::f2_polymod_t::prime_sfld_elt(0, m); spffl::polynomials::f2_polymod_t one = @@ -383,7 +383,7 @@ f2polymod_Pn_list(spffl::polynomials::f2_poly_t m, int n) { // ---------------------------------------------------------------- tmatrix -fppolymod_An_list(spffl::polynomials::fp_poly_t m, int n) { +fp_polymod_An_list(spffl::polynomials::fp_poly_t m, int n) { int d = m.find_degree(); int p = m.get_char(); int q = spffl::intmath::int_power(p, d); @@ -391,7 +391,7 @@ fppolymod_An_list(spffl::polynomials::fp_poly_t m, int n) { tmatrix rv(qn, n); int i, j; - tvector Fq = fppolymod_list(m, SP_LIST_ALL); + tvector Fq = fp_polymod_list(m, SP_LIST_ALL); for (i = 0; i < qn; i++) { int baserep = i; @@ -412,12 +412,12 @@ fppolymod_An_list(spffl::polynomials::fp_poly_t m, int n) { // # = q^0 + q^2 tmatrix -fppolymod_Pn_list(spffl::polynomials::fp_poly_t m, int n) { +fp_polymod_Pn_list(spffl::polynomials::fp_poly_t m, int n) { int i, j, k; int d = m.find_degree(); int p = m.get_char(); int q = spffl::intmath::int_power(p, d); - tvector Fq = fppolymod_list(m, SP_LIST_ALL); + tvector Fq = fp_polymod_list(m, SP_LIST_ALL); spffl::polynomials::fp_polymod_t zero = spffl::polynomials::fp_polymod_t::prime_sfld_elt(0, m); spffl::polynomials::fp_polymod_t one = diff --git a/src/list/list_elements.h b/src/list/list_elements.h index 4ed5940..30e66c5 100644 --- a/src/list/list_elements.h +++ b/src/list/list_elements.h @@ -24,42 +24,42 @@ enum sp_list_type_t { }; // Monics only -tvector f2poly_list(int deg); +tvector f2_poly_list(int deg); tvector -f2npoly_list(spffl::polynomials::f2_poly_t m, int deg); -tvector fppoly_list(int p, int deg); +f2n_poly_list(spffl::polynomials::f2_poly_t m, int deg); +tvector fp_poly_list(int p, int deg); tvector intmod_list(int p, sp_list_type_t type); tvector -f2polymod_list(spffl::polynomials::f2_poly_t m, sp_list_type_t); +f2_polymod_list(spffl::polynomials::f2_poly_t m, sp_list_type_t); tvector -f2npolymod_list(spffl::polynomials::f2n_poly_t m, sp_list_type_t); +f2n_polymod_list(spffl::polynomials::f2n_poly_t m, sp_list_type_t); tvector -fppolymod_list(spffl::polynomials::fp_poly_t m, sp_list_type_t); +fp_polymod_list(spffl::polynomials::fp_poly_t m, sp_list_type_t); tvector intmod_glist(spffl::intmath::intmod_t g, sp_list_type_t type); tvector -f2polymod_glist(spffl::polynomials::f2_polymod_t g, sp_list_type_t); +f2_polymod_glist(spffl::polynomials::f2_polymod_t g, sp_list_type_t); tvector -f2npolymod_glist(spffl::polynomials::f2n_polymod_t g, sp_list_type_t); +f2n_polymod_glist(spffl::polynomials::f2n_polymod_t g, sp_list_type_t); tvector -fppolymod_glist(spffl::polynomials::fp_polymod_t g, sp_list_type_t); +fp_polymod_glist(spffl::polynomials::fp_polymod_t g, sp_list_type_t); // Lists all n-tuples over Fq. tmatrix -f2polymod_An_list(spffl::polynomials::f2_poly_t m, int n); +f2_polymod_An_list(spffl::polynomials::f2_poly_t m, int n); tmatrix -fppolymod_An_list(spffl::polynomials::fp_poly_t m, int n); +fp_polymod_An_list(spffl::polynomials::fp_poly_t m, int n); // xxx do it for for other types too // Lists a representative for each equivalence class in projective n-space // over Fq. tmatrix -f2polymod_Pn_list(spffl::polynomials::f2_poly_t m, int n); +f2_polymod_Pn_list(spffl::polynomials::f2_poly_t m, int n); tmatrix -fppolymod_Pn_list(spffl::polynomials::fp_poly_t m, int n); +fp_polymod_Pn_list(spffl::polynomials::fp_poly_t m, int n); // xxx do it for for other types too diff --git a/src/polynomials/f2_poly_t.cpp b/src/polynomials/f2_poly_t.cpp index a1f0d2c..ea1f218 100644 --- a/src/polynomials/f2_poly_t.cpp +++ b/src/polynomials/f2_poly_t.cpp @@ -317,7 +317,7 @@ void f2_poly_t::quot_and_rem(f2_poly_t &that, f2_poly_t &rquot, divisor_l1_pos = that.find_degree(); if ((divisor_l1_pos == 0) && (that.parts[0] == 0)) { // Divisor is zero. - std::cerr << "f2poly_quot_and_rem: Divide by zero.\n"; + std::cerr << "f2_poly_quot_and_rem: Divide by zero.\n"; exit(1); } @@ -1162,7 +1162,7 @@ void f2_poly_t::trim_parts(void) { void f2_poly_t::check_neg_pos(int pos) const { if (pos < 0) { - std::cerr << "f2poly: negative bit position " << pos << " disallowed.\n"; + std::cerr << "f2_poly: negative bit position " << pos << " disallowed.\n"; exit(1); } } diff --git a/src/polynomials/f2_polymod_t.cpp b/src/polynomials/f2_polymod_t.cpp index fda2d54..4e5eb2e 100644 --- a/src/polynomials/f2_polymod_t.cpp +++ b/src/polynomials/f2_polymod_t.cpp @@ -120,7 +120,7 @@ int f2_polymod_t::recip(f2_polymod_t &rinv) { // Error check: if (g.find_degree() != 0) { - // std::cerr << "f2polymod recip: zero or zero divisor.\n"; + // std::cerr << "f2_polymod recip: zero or zero divisor.\n"; return 0; } else { rinv = f2_polymod_t(a, this->modulus); diff --git a/src/polynomials/f2n_polymod_t.cpp b/src/polynomials/f2n_polymod_t.cpp index 132df86..452920a 100644 --- a/src/polynomials/f2n_polymod_t.cpp +++ b/src/polynomials/f2n_polymod_t.cpp @@ -134,7 +134,7 @@ int f2n_polymod_t::recip(f2n_polymod_t &rinv) { // Error check: if (g.find_degree() != 0) { - // std::cerr << "f2npolymod recip: zero or zero divisor.\n"; + // std::cerr << "f2n_polymod recip: zero or zero divisor.\n"; return 0; } diff --git a/src/polynomials/fp_polymod_t.cpp b/src/polynomials/fp_polymod_t.cpp index 5e433be..6c649b4 100644 --- a/src/polynomials/fp_polymod_t.cpp +++ b/src/polynomials/fp_polymod_t.cpp @@ -143,7 +143,7 @@ int fp_polymod_t::recip(fp_polymod_t &rinv) { // Error check: if (g.find_degree() != 0) { - // std::cerr << "fppolymod recip: zero or zero divisor.\n"; + // std::cerr << "fp_polymod recip: zero or zero divisor.\n"; return 0; } diff --git a/src/polynomials/fpn_polymod_t.cpp b/src/polynomials/fpn_polymod_t.cpp index 1ae4473..3581776 100644 --- a/src/polynomials/fpn_polymod_t.cpp +++ b/src/polynomials/fpn_polymod_t.cpp @@ -132,7 +132,7 @@ int fpn_polymod_t::recip(fpn_polymod_t &rinv) { // Error check: if (g.find_degree() != 0) { - // std::cerr << "fpnpolymod recip: zero or zero divisor.\n"; + // std::cerr << "fpn_polymod recip: zero or zero divisor.\n"; return 0; } diff --git a/src/qcyclo/CMakeLists.txt b/src/q_cyclo/CMakeLists.txt similarity index 96% rename from src/qcyclo/CMakeLists.txt rename to src/q_cyclo/CMakeLists.txt index d68d480..343d990 100644 --- a/src/qcyclo/CMakeLists.txt +++ b/src/q_cyclo/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.24) -project(qcyclo) +project(q_cyclo) add_library(${PROJECT_NAME} qff.cpp diff --git a/src/qcyclo/cyclo_poly.cpp b/src/q_cyclo/cyclo_poly.cpp similarity index 79% rename from src/qcyclo/cyclo_poly.cpp rename to src/q_cyclo/cyclo_poly.cpp index 6194505..c095bf1 100644 --- a/src/qcyclo/cyclo_poly.cpp +++ b/src/q_cyclo/cyclo_poly.cpp @@ -11,7 +11,7 @@ #include "cyclo_poly.h" #include "qff.h" -namespace spffl::qcyclo { +namespace spffl::q_cyclo { #define CYCLO_MEMO_MAX 16 static int memo_flags[CYCLO_MEMO_MAX + 1] = {0}; @@ -72,32 +72,32 @@ spffl::rationals::qpoly_t get_cyclo_qpoly(int n) { } // ---------------------------------------------------------------- -spffl::polynomials::f2_poly_t get_cyclo_f2poly(int n) { +spffl::polynomials::f2_poly_t get_cyclo_f2_poly(int n) { spffl::rationals::qpoly_t q = get_cyclo_qpoly(n); - spffl::polynomials::f2_poly_t rv = f2poly_from_qpoly(q); + spffl::polynomials::f2_poly_t rv = f2_poly_from_q_poly(q); return rv; } // ---------------------------------------------------------------- -spffl::polynomials::fp_poly_t get_cyclo_fppoly(int n, int p) { +spffl::polynomials::fp_poly_t get_cyclo_fp_poly(int n, int p) { spffl::rationals::qpoly_t q = get_cyclo_qpoly(n); - spffl::polynomials::fp_poly_t rv = fppoly_from_qpoly(q, p); + spffl::polynomials::fp_poly_t rv = fp_poly_from_qpoly(q, p); return rv; } // ---------------------------------------------------------------- spffl::polynomials::f2n_poly_t -get_cyclo_f2npoly(int n, spffl::polynomials::f2_poly_t im) { +get_cyclo_f2n_poly(int n, spffl::polynomials::f2_poly_t im) { spffl::rationals::qpoly_t q = get_cyclo_qpoly(n); - spffl::polynomials::f2n_poly_t rv = f2npoly_from_qpoly(q, im); + spffl::polynomials::f2n_poly_t rv = f2n_poly_from_qpoly(q, im); return rv; } // ---------------------------------------------------------------- spffl::polynomials::fpn_poly_t -get_cyclo_fpnpoly(int n, spffl::polynomials::fp_poly_t im) { +get_cyclo_fpn_poly(int n, spffl::polynomials::fp_poly_t im) { spffl::rationals::qpoly_t q = get_cyclo_qpoly(n); - spffl::polynomials::fpn_poly_t rv = fpnpoly_from_qpoly(q, im); + spffl::polynomials::fpn_poly_t rv = fpn_poly_from_qpoly(q, im); return rv; } @@ -117,23 +117,23 @@ int main(void) { std::cout << "\n"; for (int n = 1; n < nmax; n++) - std::cout << n << ": " << get_cyclo_f2poly(n) << "\n"; + std::cout << n << ": " << get_cyclo_f2_poly(n) << "\n"; std::cout << "\n"; for (int n = 1; n < nmax; n++) - std::cout << n << ": " << get_cyclo_fppoly(n, p) << "\n"; + std::cout << n << ": " << get_cyclo_fp_poly(n, p) << "\n"; std::cout << "\n"; for (int n = 1; n < nmax; n++) - std::cout << n << ": " << get_cyclo_f2npoly(n, m2) << "\n"; + std::cout << n << ": " << get_cyclo_f2n_poly(n, m2) << "\n"; std::cout << "\n"; for (int n = 1; n < nmax; n++) - std::cout << n << ": " << get_cyclo_fpnpoly(n, mp) << "\n"; + std::cout << n << ": " << get_cyclo_fpn_poly(n, mp) << "\n"; std::cout << "\n"; return 0; } #endif -} // namespace spffl::qcyclo +} // namespace spffl::q_cyclo diff --git a/src/q_cyclo/cyclo_poly.h b/src/q_cyclo/cyclo_poly.h new file mode 100644 index 0000000..5676949 --- /dev/null +++ b/src/q_cyclo/cyclo_poly.h @@ -0,0 +1,22 @@ +#ifndef CYCLOPOLY_H +#define CYCLOPOLY_H + +#include "f2_poly_t.h" +#include "f2n_poly_t.h" +#include "fp_poly_t.h" +#include "fpn_poly_t.h" +#include "qpoly_t.h" + +namespace spffl::q_cyclo { + +spffl::rationals::qpoly_t get_cyclo_qpoly(int n); +spffl::polynomials::f2_poly_t get_cyclo_f2_poly(int n); +spffl::polynomials::fp_poly_t get_cyclo_fp_poly(int n, int p); +spffl::polynomials::f2n_poly_t +get_cyclo_f2n_poly(int n, spffl::polynomials::f2_poly_t im); +spffl::polynomials::fpn_poly_t +get_cyclo_fpn_poly(int n, spffl::polynomials::fp_poly_t im); + +} // namespace spffl::q_cyclo + +#endif // CYCLOPOLY_H diff --git a/src/qcyclo/qff.cpp b/src/q_cyclo/qff.cpp similarity index 87% rename from src/qcyclo/qff.cpp rename to src/q_cyclo/qff.cpp index df694f9..53d3f3d 100644 --- a/src/qcyclo/qff.cpp +++ b/src/q_cyclo/qff.cpp @@ -1,6 +1,6 @@ #include "qff.h" -namespace spffl::qcyclo { +namespace spffl::q_cyclo { // ---------------------------------------------------------------- spffl::bits::bit_t bit_from_rat(spffl::rationals::intrat_t r) { @@ -18,7 +18,7 @@ spffl::intmath::intmod_t intmod_from_rat(spffl::rationals::intrat_t r, int p) { } // ---------------------------------------------------------------- -spffl::polynomials::f2_poly_t f2poly_from_qpoly(spffl::rationals::qpoly_t q) { +spffl::polynomials::f2_poly_t f2_poly_from_q_poly(spffl::rationals::qpoly_t q) { spffl::polynomials::f2_poly_t rv; int d = q.find_degree(); for (int i = d; i >= 0; i--) @@ -27,7 +27,7 @@ spffl::polynomials::f2_poly_t f2poly_from_qpoly(spffl::rationals::qpoly_t q) { } // ---------------------------------------------------------------- -spffl::polynomials::fp_poly_t fppoly_from_qpoly(spffl::rationals::qpoly_t q, +spffl::polynomials::fp_poly_t fp_poly_from_qpoly(spffl::rationals::qpoly_t q, int p) { spffl::polynomials::fp_poly_t rv; int d = q.find_degree(); @@ -38,7 +38,7 @@ spffl::polynomials::fp_poly_t fppoly_from_qpoly(spffl::rationals::qpoly_t q, // ---------------------------------------------------------------- spffl::polynomials::f2n_poly_t -f2npoly_from_qpoly(spffl::rationals::qpoly_t q, +f2n_poly_from_qpoly(spffl::rationals::qpoly_t q, spffl::polynomials::f2_poly_t im) { spffl::polynomials::f2n_poly_t rv; int d = q.find_degree(); @@ -54,7 +54,7 @@ f2npoly_from_qpoly(spffl::rationals::qpoly_t q, // ---------------------------------------------------------------- spffl::polynomials::fpn_poly_t -fpnpoly_from_qpoly(spffl::rationals::qpoly_t q, +fpn_poly_from_qpoly(spffl::rationals::qpoly_t q, spffl::polynomials::fp_poly_t im) { int d = q.find_degree(); int p = im.get_char(); @@ -71,4 +71,4 @@ fpnpoly_from_qpoly(spffl::rationals::qpoly_t q, return rv; } -} // namespace spffl::qcyclo +} // namespace spffl::q_cyclo diff --git a/src/qcyclo/qff.h b/src/q_cyclo/qff.h similarity index 64% rename from src/qcyclo/qff.h rename to src/q_cyclo/qff.h index 0a9fde6..4ef214c 100644 --- a/src/qcyclo/qff.h +++ b/src/q_cyclo/qff.h @@ -8,21 +8,21 @@ #include "intrat_t.h" #include "qpoly_t.h" -namespace spffl::qcyclo { +namespace spffl::q_cyclo { spffl::bits::bit_t bit_from_rat(spffl::rationals::intrat_t r); spffl::intmath::intmod_t intmod_from_rat(spffl::rationals::intrat_t r, int p); -spffl::polynomials::f2_poly_t f2poly_from_qpoly(spffl::rationals::qpoly_t q); -spffl::polynomials::fp_poly_t fppoly_from_qpoly(spffl::rationals::qpoly_t q, +spffl::polynomials::f2_poly_t f2_poly_from_q_poly(spffl::rationals::qpoly_t q); +spffl::polynomials::fp_poly_t fp_poly_from_qpoly(spffl::rationals::qpoly_t q, int p); spffl::polynomials::f2n_poly_t -f2npoly_from_qpoly(spffl::rationals::qpoly_t q, +f2n_poly_from_qpoly(spffl::rationals::qpoly_t q, spffl::polynomials::f2_poly_t im); spffl::polynomials::fpn_poly_t -fpnpoly_from_qpoly(spffl::rationals::qpoly_t q, +fpn_poly_from_qpoly(spffl::rationals::qpoly_t q, spffl::polynomials::fp_poly_t im); -} // namespace spffl::qcyclo +} // namespace spffl::q_cyclo #endif // QFF_H diff --git a/src/qcyclo/cyclo_poly.h b/src/qcyclo/cyclo_poly.h deleted file mode 100644 index 75feb02..0000000 --- a/src/qcyclo/cyclo_poly.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef CYCLOPOLY_H -#define CYCLOPOLY_H - -#include "f2_poly_t.h" -#include "f2n_poly_t.h" -#include "fp_poly_t.h" -#include "fpn_poly_t.h" -#include "qpoly_t.h" - -namespace spffl::qcyclo { - -spffl::rationals::qpoly_t get_cyclo_qpoly(int n); -spffl::polynomials::f2_poly_t get_cyclo_f2poly(int n); -spffl::polynomials::fp_poly_t get_cyclo_fppoly(int n, int p); -spffl::polynomials::f2n_poly_t -get_cyclo_f2npoly(int n, spffl::polynomials::f2_poly_t im); -spffl::polynomials::fpn_poly_t -get_cyclo_fpnpoly(int n, spffl::polynomials::fp_poly_t im); - -} // namespace spffl::qcyclo - -#endif // CYCLOPOLY_H diff --git a/src/units/f2_polymod_units.cpp b/src/units/f2_polymod_units.cpp index 6d9180c..6a43bfb 100644 --- a/src/units/f2_polymod_units.cpp +++ b/src/units/f2_polymod_units.cpp @@ -20,14 +20,14 @@ namespace spffl::units { // to the order of the unit group. Instead, we use Lagrange's theorem, // testing only divisors of the order of the unit group. -int f2polymod_order(spffl::polynomials::f2_polymod_t a) { +int f2_polymod_order(spffl::polynomials::f2_polymod_t a) { spffl::polynomials::f2_poly_t pol1(1); spffl::polynomials::f2_poly_t r = a.get_residue(); spffl::polynomials::f2_poly_t m = a.get_modulus(); spffl::polynomials::f2_poly_t g = r.gcd(m); if (g != pol1) { - std::cerr << "f2polymod_order: zero or zero divisor " << r << " mod " << m + std::cerr << "f2_polymod_order: zero or zero divisor " << r << " mod " << m << ".\n"; exit(1); } @@ -49,18 +49,18 @@ int f2polymod_order(spffl::polynomials::f2_polymod_t a) { // By Lagrange's theorem, g^m = 1 for all units g, with m the order // of the unit group. If we've not found the order of a unit, // something is wrong. - std::cout << "f2polymod_order: Coding error.\n"; + std::cout << "f2_polymod_order: Coding error.\n"; exit(1); } // ---------------------------------------------------------------- -int f2polymod_find_generator(spffl::polynomials::f2_poly_t m, +int f2_polymod_find_generator(spffl::polynomials::f2_poly_t m, spffl::polynomials::f2_polymod_t &rg) { int mdeg = m.find_degree(); spffl::polynomials::f2_poly_t gres(1); if (mdeg < 1) { - std::cout << "f2polymod_find_generator: modulus degree " + std::cout << "f2_polymod_find_generator: modulus degree " << "must be positive; got " << mdeg << ".\n"; exit(1); } @@ -68,7 +68,7 @@ int f2polymod_find_generator(spffl::polynomials::f2_poly_t m, while (gres.find_degree() < mdeg) { spffl::polynomials::f2_polymod_t g(gres, m); - if (f2polymod_order(g) == phi) { + if (f2_polymod_order(g) == phi) { rg = g; return 1; } @@ -85,12 +85,12 @@ int f2polymod_find_generator(spffl::polynomials::f2_poly_t m, // ---------------------------------------------------------------- // The naive test is a one-liner: -// return (spffl::factorization::f2_poly_totient(m) == f2poly_period(m)); -// This appears simple, but f2poly_period() will test x^d for all proper +// return (spffl::factorization::f2_poly_totient(m) == f2_poly_period(m)); +// This appears simple, but f2_poly_period() will test x^d for all proper // divisors of phi(m). For primitivity, it suffices to check only the // *maximal* proper divisors of phi(m). -int f2poly_is_primitive(spffl::polynomials::f2_poly_t m) { +int f2_poly_is_primitive(spffl::polynomials::f2_poly_t m) { spffl::polynomials::f2_poly_t pol1(1); // 1 as a polynomial. spffl::polynomials::f2_poly_t polx(1, 0); if (polx.gcd(m) != pol1) @@ -124,30 +124,30 @@ int f2poly_is_primitive(spffl::polynomials::f2_poly_t m) { } // ---------------------------------------------------------------- -int f2poly_period(spffl::polynomials::f2_poly_t m) { +int f2_poly_period(spffl::polynomials::f2_poly_t m) { spffl::polynomials::f2_poly_t x(1, 0); spffl::polynomials::f2_poly_t one(1); if (x.gcd(m) != one) return 0; - return f2polymod_order(spffl::polynomials::f2_polymod_t(x, m)); + return f2_polymod_order(spffl::polynomials::f2_polymod_t(x, m)); } // ---------------------------------------------------------------- // Lexically lowest -spffl::polynomials::f2_poly_t f2poly_find_prim(int degree, int need_irr) { +spffl::polynomials::f2_poly_t f2_poly_find_prim(int degree, int need_irr) { spffl::polynomials::f2_poly_t rv(0); rv.set_bit(degree); rv.set_bit(0); if (degree < 1) { - std::cout << "f2poly_find_prim: degree must be positive; got " << degree + std::cout << "f2_poly_find_prim: degree must be positive; got " << degree << ".\n"; exit(1); } while (rv.find_degree() == degree) { - if (f2poly_is_primitive(rv)) { - if (!need_irr || spffl::factorization::f2poly_is_irreducible(rv)) + if (f2_poly_is_primitive(rv)) { + if (!need_irr || spffl::factorization::f2_poly_is_irreducible(rv)) return rv; } rv.increment(); @@ -155,26 +155,26 @@ spffl::polynomials::f2_poly_t f2poly_find_prim(int degree, int need_irr) { // There are irreducibles, and primitive irreducibles, of all positive // degrees. It is an error if we failed to find one. - std::cout << "f2poly_find_prim: coding error.\n"; + std::cout << "f2_poly_find_prim: coding error.\n"; exit(1); return rv; } // ---------------------------------------------------------------- -spffl::polynomials::f2_poly_t f2poly_random_prim(int degree, int need_irr) { +spffl::polynomials::f2_poly_t f2_poly_random_prim(int degree, int need_irr) { spffl::polynomials::f2_poly_t rv; if (degree < 1) { - std::cout << "f2poly_random_prim: degree must be positive; " + std::cout << "f2_poly_random_prim: degree must be positive; " << "got " << degree << ".\n"; exit(1); } for (;;) { rv = spffl::random::f2_poly_random(degree); - if (f2poly_is_primitive(rv)) { - if (!need_irr || spffl::factorization::f2poly_is_irreducible(rv)) + if (f2_poly_is_primitive(rv)) { + if (!need_irr || spffl::factorization::f2_poly_is_irreducible(rv)) return rv; } } @@ -204,7 +204,7 @@ static int poly_and_index_qcmp(const void *pv1, const void *pv2) { return 0; } -int f2polymod_log( // Log base g of a. +int f2_polymod_log( // Log base g of a. spffl::polynomials::f2_polymod_t g, spffl::polynomials::f2_polymod_t a) { int rv = -1; spffl::polynomials::f2_poly_t m = g.get_modulus(); @@ -219,7 +219,7 @@ int f2polymod_log( // Log base g of a. spffl::polynomials::f2_polymod_t ginv; if (!g.recip(ginv)) { - std::cerr << "f2polymod_log: g=" + std::cerr << "f2_polymod_log: g=" << " is a zero divisor.\n"; exit(1); } @@ -257,7 +257,7 @@ int f2polymod_log( // Log base g of a. if (rv == -1) { // xxx - std::cerr << "f2polymod_log: error message goes here.\n"; + std::cerr << "f2_polymod_log: error message goes here.\n"; exit(1); } diff --git a/src/units/f2_polymod_units.h b/src/units/f2_polymod_units.h index 691d3ae..34e7365 100644 --- a/src/units/f2_polymod_units.h +++ b/src/units/f2_polymod_units.h @@ -10,29 +10,29 @@ namespace spffl::units { -int f2polymod_order(spffl::polynomials::f2_polymod_t a); +int f2_polymod_order(spffl::polynomials::f2_polymod_t a); // The function return value is 1 if a generator was found, 0 otherwise. // In the former case, rg holds the found generator. -int f2polymod_find_generator(spffl::polynomials::f2_poly_t m, +int f2_polymod_find_generator(spffl::polynomials::f2_poly_t m, spffl::polynomials::f2_polymod_t &rg); // Returns 1 if x generates the multiplicative group. An irreducibility // test is not done. -int f2poly_is_primitive(spffl::polynomials::f2_poly_t m); +int f2_poly_is_primitive(spffl::polynomials::f2_poly_t m); -int f2poly_period(spffl::polynomials::f2_poly_t m); +int f2_poly_period(spffl::polynomials::f2_poly_t m); // Lexically lowest. -spffl::polynomials::f2_poly_t f2poly_find_prim(int degree, int need_irr); +spffl::polynomials::f2_poly_t f2_poly_find_prim(int degree, int need_irr); -spffl::polynomials::f2_poly_t f2poly_random_prim(int degree, int need_irr); +spffl::polynomials::f2_poly_t f2_poly_random_prim(int degree, int need_irr); // Log base g of a, using Shanks' algorithm. // // Warning: We assume that g is a generator. We do not test this, not // only for efficiency, but in case the caller is working within a subfield. -int f2polymod_log(spffl::polynomials::f2_polymod_t g, +int f2_polymod_log(spffl::polynomials::f2_polymod_t g, spffl::polynomials::f2_polymod_t a); } // namespace spffl::units diff --git a/src/units/f2n_polymod_units.cpp b/src/units/f2n_polymod_units.cpp index 5710d37..c5ef347 100644 --- a/src/units/f2n_polymod_units.cpp +++ b/src/units/f2n_polymod_units.cpp @@ -18,7 +18,7 @@ namespace spffl::units { // to the order of the unit group. Instead, we use Lagrange's theorem, // testing only divisors of the order of the unit group. -int f2npolymod_order(spffl::polynomials::f2n_polymod_t a) { +int f2n_polymod_order(spffl::polynomials::f2n_polymod_t a) { spffl::polynomials::f2n_poly_t r = a.get_residue(); spffl::polynomials::f2n_poly_t m = a.get_modulus(); spffl::polynomials::f2n_poly_t g = r.gcd(m); @@ -27,7 +27,7 @@ int f2npolymod_order(spffl::polynomials::f2n_polymod_t a) { spffl::polynomials::f2n_poly_t pol1 = m.prime_sfld_elt(1); if (g != pol1) { - std::cerr << "f2npolymod_order: zero or zero divisor " << r << " mod " << m + std::cerr << "f2n_polymod_order: zero or zero divisor " << r << " mod " << m << ".\n"; std::cerr << "gcd(" << r << ", " << m << ") = " << g << "\n"; exit(1); @@ -50,18 +50,18 @@ int f2npolymod_order(spffl::polynomials::f2n_polymod_t a) { // By Lagrange's theorem, g^m = 1 for all units g, with m the order // of the unit group. If we've not found the order of a unit, // something is wrong. - std::cout << "f2npolymod_order: Coding error.\n"; + std::cout << "f2n_polymod_order: Coding error.\n"; exit(1); } // ---------------------------------------------------------------- -int f2npolymod_find_generator(spffl::polynomials::f2n_poly_t m, +int f2n_polymod_find_generator(spffl::polynomials::f2n_poly_t m, spffl::polynomials::f2n_polymod_t &rg) { int mdeg = m.find_degree(); spffl::polynomials::f2n_poly_t gres = m.prime_sfld_elt(1); if (mdeg < 1) { - std::cout << "f2npolymod_find_generator: modulus degree " + std::cout << "f2n_polymod_find_generator: modulus degree " << "must be positive; got " << mdeg << ".\n"; exit(1); } @@ -69,7 +69,7 @@ int f2npolymod_find_generator(spffl::polynomials::f2n_poly_t m, while (gres.find_degree() < mdeg) { spffl::polynomials::f2n_polymod_t g(gres, m); - if (f2npolymod_order(g) == phi) { + if (f2n_polymod_order(g) == phi) { rg = g; return 1; } @@ -108,7 +108,7 @@ static int poly_and_index_qcmp(const void *pv1, const void *pv2) { return 0; } -int f2npolymod_log( // Log base g of a. +int f2n_polymod_log( // Log base g of a. spffl::polynomials::f2n_polymod_t g, spffl::polynomials::f2n_polymod_t a) { std::cout << "\n"; std::cout << "g = " << g << "\n"; @@ -129,7 +129,7 @@ int f2npolymod_log( // Log base g of a. spffl::polynomials::f2n_polymod_t ginv; if (!g.recip(ginv)) { - std::cerr << "f2npolymod_log: g=" + std::cerr << "f2n_polymod_log: g=" << " is a zero divisor.\n"; exit(1); } @@ -179,7 +179,7 @@ int f2npolymod_log( // Log base g of a. } if (rv == -1) { - std::cerr << "f2npolymod_log: couldn't find log base " << g << " of " << a + std::cerr << "f2n_polymod_log: couldn't find log base " << g << " of " << a << " mod " << m << ".\n"; exit(1); } diff --git a/src/units/f2n_polymod_units.h b/src/units/f2n_polymod_units.h index 0ba7a3a..f6db298 100644 --- a/src/units/f2n_polymod_units.h +++ b/src/units/f2n_polymod_units.h @@ -10,18 +10,18 @@ namespace spffl::units { -int f2npolymod_order(spffl::polynomials::f2n_polymod_t a); +int f2n_polymod_order(spffl::polynomials::f2n_polymod_t a); // The function return value is 1 if a generator was found, 0 otherwise. // In the former case, rg holds the found generator. -int f2npolymod_find_generator(spffl::polynomials::f2n_poly_t m, +int f2n_polymod_find_generator(spffl::polynomials::f2n_poly_t m, spffl::polynomials::f2n_polymod_t &rg); // Log base g of a, using Shanks' algorithm. // // Warning: We assume that g is a generator. We do not test this, not // only for efficiency, but in case the caller is working within a subfield. -int f2npolymod_log(spffl::polynomials::f2n_polymod_t g, +int f2n_polymod_log(spffl::polynomials::f2n_polymod_t g, spffl::polynomials::f2n_polymod_t a); } // namespace spffl::units