template <> int hkz(Options &o, ZZ_mat<mpz_t> &b) { const char *format = o.output_format ? o.output_format : "b"; int flags = 0; if (o.verbose) flags |= HKZ_VERBOSE; string dump_gso_filename; if (o.bkz_flags & BKZ_DUMP_GSO) { dump_gso_filename = o.bkz_dump_gso_filename; flags |= BKZ_DUMP_GSO; } //int status = hkz_reduction(b, flags, o.float_type, o.precision, dump_gso_filename); int status = hkz_reduction(b, flags, o.float_type, o.precision); for (int i = 0; format[i]; i++) { if (format[i] == 'b') { if (format[i + 1] == 'k') { b.print_comma(cout); i++; } else cout << b << endl; } } if (status != RED_SUCCESS) { cerr << "Failure: " << get_red_status_str(status) << endl; } return status; }
template <class ZT> int lll(Options &o, ZZ_mat<ZT> &b) { // Stupid initialization of u and u_inv to be not empty. ZZ_mat<ZT> u(1, 1), u_inv(1, 1); const char *format = o.output_format ? o.output_format : "b"; int status, flags = 0; if (o.verbose) flags |= LLL_VERBOSE; if (o.early_red) flags |= LLL_EARLY_RED; if (o.siegel) flags |= LLL_SIEGEL; if (strchr(format, 'v') != NULL) { // LLL-reduction with transform and inverse transform status = lll_reduction(b, u, u_inv, o.delta, o.eta, o.method, o.float_type, o.precision, flags); } else if (strchr(format, 'u') != NULL) { // LLL-reduction with transform status = lll_reduction(b, u, o.delta, o.eta, o.method, o.float_type, o.precision, flags); } else { status = lll_reduction(b, o.delta, o.eta, o.method, o.float_type, o.precision, flags); } for (int i = 0; format[i]; i++) { switch (format[i]) { case 'b': if (format[i + 1] == 'k') { b.print_comma(cout); i++; } else cout << b << endl; break; case 'u': if (format[i + 1] == 'k') { u.print_comma(cout); i++; } else cout << u << endl; break; case 'v': if (format[i + 1] == 'k') { u_inv.print_comma(cout); i++; } else cout << u_inv << endl; break; case 't': cout << status << endl; break; case ' ': cout << endl; break; } } if (status != RED_SUCCESS) { cerr << "Failure: " << get_red_status_str(status) << endl; } return status; }
template <> int bkz(Options &o, ZZ_mat<mpz_t> &b) { CHECK(o.block_size > 0, "Option -b is missing"); vector<Strategy> strategies; if (!o.bkz_strategy_file.empty()) { strategies = load_strategies_json(strategy_full_path(o.bkz_strategy_file)); } BKZParam param(o.block_size, strategies); // Stupid initialization of u to be not empty. ZZ_mat<mpz_t> u(1, 1); const char *format = o.output_format ? o.output_format : "b"; int status; param.delta = o.delta; param.flags = o.bkz_flags; if (o.bkz_flags & BKZ_DUMP_GSO) param.dump_gso_filename = o.bkz_dump_gso_filename; if (o.bkz_flags & BKZ_GH_BND) param.gh_factor = o.bkz_gh_factor; if (o.bkz_flags & BKZ_MAX_LOOPS) param.max_loops = o.bkz_max_loops; if (o.verbose) param.flags |= BKZ_VERBOSE; if (o.no_lll) param.flags |= BKZ_NO_LLL; status = bkz_reduction(&b, strchr(format, 'u') ? &u : NULL, param, o.float_type, o.precision); for (int i = 0; format[i]; i++) { switch (format[i]) { case 'b': if (format[i + 1] == 'k') { b.print_comma(cout); i++; } else cout << b << endl; break; case 'u': if (format[i + 1] == 'k') { u.print_comma(cout); i++; } else cout << u << endl; break; case 't': cout << status << endl; break; case ' ': cout << endl; break; } } if (status != RED_SUCCESS) { cerr << "Failure: " << get_red_status_str(status) << endl; } return status; }