当前位置: 首页>>代码示例>>C++>>正文


C++ Float::mul_2si方法代码示例

本文整理汇总了C++中Float::mul_2si方法的典型用法代码示例。如果您正苦于以下问题:C++ Float::mul_2si方法的具体用法?C++ Float::mul_2si怎么用?C++ Float::mul_2si使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Float的用法示例。


在下文中一共展示了Float::mul_2si方法的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;
}
开发者ID:damons,项目名称:fplll,代码行数:65,代码来源:test_svp.cpp

示例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;
}
开发者ID:damons,项目名称:fplll,代码行数:46,代码来源:test_svp.cpp


注:本文中的Float::mul_2si方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。