本文整理汇总了C++中Float::get_prec方法的典型用法代码示例。如果您正苦于以下问题:C++ Float::get_prec方法的具体用法?C++ Float::get_prec怎么用?C++ Float::get_prec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Float
的用法示例。
在下文中一共展示了Float::get_prec方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dummy
/**
@brief Test if dual SVP reduction returns reduced basis.
@param A input lattice
@param b shortest dual vector
@return
*/
template <class ZT> int test_dsvp_reduce(ZZ_mat<ZT> &A, IntVect &b)
{
IntMatrix u;
int d = A.get_rows();
Float normb;
if (dual_length(normb, A, b))
{
return 1;
}
int status =
lll_reduction(A, u, LLL_DEF_DELTA, LLL_DEF_ETA, LM_WRAPPER, FT_DEFAULT, 0, LLL_DEFAULT);
if (status != RED_SUCCESS)
{
cerr << "LLL reduction failed: " << get_red_status_str(status) << endl;
return status;
}
IntMatrix empty_mat;
MatGSO<Integer, Float> gso(A, empty_mat, empty_mat, GSO_INT_GRAM);
LLLReduction<Integer, Float> lll_obj(gso, LLL_DEF_DELTA, LLL_DEF_ETA, LLL_DEFAULT);
vector<Strategy> strategies;
BKZParam dummy(d, strategies);
BKZReduction<Float> bkz_obj(gso, lll_obj, dummy);
bool clean = true;
bkz_obj.svp_reduction_ex(0, d, dummy, clean, true);
status = bkz_obj.status;
if (status != RED_SUCCESS)
{
cerr << "Failure: " << get_red_status_str(status) << endl;
return status;
}
Float norm_sol;
Integer zero;
zero = 0;
IntVect e_n(d, zero);
e_n[d - 1] = 1;
if (dual_length(norm_sol, A, e_n))
{
return 1;
}
Float error;
error = 1;
error.mul_2si(error, -(int)error.get_prec());
normb += error;
if (norm_sol > normb)
{
cerr << "Last dual vector too long by more than " << error << endl;
return 1;
}
return 0;
}
示例2:
template <class ZT> int test_dual_svp(ZZ_mat<ZT> &A, IntVect &b)
{
IntVect sol_coord; // In the LLL-reduced basis
IntVect solution;
IntMatrix u;
Float normb;
if (dual_length(normb, A, b))
{
return 1;
}
int status =
lll_reduction(A, u, LLL_DEF_DELTA, LLL_DEF_ETA, LM_WRAPPER, FT_DEFAULT, 0, LLL_DEFAULT);
if (status != RED_SUCCESS)
{
cerr << "LLL reduction failed: " << get_red_status_str(status) << endl;
return status;
}
status = shortest_vector(A, sol_coord, SVPM_FAST, SVP_DUAL);
if (status != RED_SUCCESS)
{
cerr << "Failure: " << get_red_status_str(status) << endl;
return status;
}
Float norm_sol;
if (dual_length(norm_sol, A, sol_coord))
{
return 1;
}
Float error;
error = 1;
error.mul_2si(error, -(int)error.get_prec());
normb += error;
if (norm_sol > normb)
{
cerr << "Returned dual vector too long by more than " << error << endl;
return 1;
}
return 0;
}