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


C++ vec_ZZ_p::SetLength方法代码示例

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


在下文中一共展示了vec_ZZ_p::SetLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PlainTraceVec

void PlainTraceVec(vec_ZZ_p& S, const ZZ_pX& ff)
{
   if (deg(ff) <= 0)
      LogicError("TraceVec: bad args");

   ZZ_pX f;
   f = ff;

   MakeMonic(f);

   long n = deg(f);

   S.SetLength(n);

   if (n == 0)
      return;

   long k, i;
   ZZ acc, t;
   ZZ_p t1;

   S[0] = n;

   for (k = 1; k < n; k++) {
      mul(acc, rep(f.rep[n-k]), k);

      for (i = 1; i < k; i++) {
         mul(t, rep(f.rep[n-i]), rep(S[k-i]));
         add(acc, acc, t);
      }

      conv(t1, acc);
      negate(S[k], t1);
   }
}
开发者ID:Brainloop-Security,项目名称:secret-sharing,代码行数:35,代码来源:ZZ_pX1.cpp

示例2: StripZeroes

static void StripZeroes(vec_ZZ_p& x)
{
   long n = x.length();
   while (n > 0 && IsZero(x[n-1]))
      n--;
   x.SetLength(n);
}
开发者ID:Brainloop-Security,项目名称:secret-sharing,代码行数:7,代码来源:ZZ_pX1.cpp

示例3: ComputeTraceVec

static
void ComputeTraceVec(vec_ZZ_p& S, const ZZ_pXModulus& F)
{
   if (!F.UseFFT) {
      PlainTraceVec(S, F.f);
      return;
   }

   long i;
   long n = F.n;

   FFTRep R;
   ZZ_pX P, g;

   g.rep.SetLength(n-1);
   for (i = 1; i < n; i++)
      mul(g.rep[n-i-1], F.f.rep[n-i], i); 
   g.normalize();

   ToFFTRep(R, g, F.l);
   mul(R, R, F.HRep);
   FromFFTRep(P, R, n-2, 2*n-4);

   S.SetLength(n);

   S[0] = n;
   for (i = 1; i < n; i++)
      negate(S[i], coeff(P, n-1-i));
}
开发者ID:Brainloop-Security,项目名称:secret-sharing,代码行数:29,代码来源:ZZ_pX1.cpp

示例4: ProjectPowers

void ProjectPowers(vec_ZZ_p& x, const vec_ZZ_p& a, long k,
                   const ZZ_pXArgument& H, const ZZ_pXModulus& F)

{
   long n = F.n;

   if (a.length() > n || k < 0) 
      LogicError("ProjectPowers: bad args");
   if (NTL_OVERFLOW(k, 1, 0)) 
      ResourceError("ProjectPowers: excessive args");


   long m = H.H.length()-1;
   long l = (k+m-1)/m - 1;

   ZZ_pXMultiplier M;
   build(M, H.H[m], F);

   vec_ZZ_p s(INIT_SIZE, n);
   s = a;
   StripZeroes(s);

   x.SetLength(k);

   for (long i = 0; i <= l; i++) {
      long m1 = min(m, k-i*m);
      ZZ_p* w = &x[i*m];
      for (long j = 0; j < m1; j++)
         InnerProduct(w[j], H.H[j].rep, s);
      if (i < l)
         UpdateMap(s, s, M, F);
   }
}
开发者ID:Brainloop-Security,项目名称:secret-sharing,代码行数:33,代码来源:ZZ_pX1.cpp

示例5: PlainUpdateMap

void PlainUpdateMap(vec_ZZ_p& xx, const vec_ZZ_p& a, 
                    const ZZ_pX& b, const ZZ_pX& f)
{
   long n = deg(f);
   long i, m;

   if (IsZero(b)) {
      xx.SetLength(0);
      return;
   }

   m = n-1 - deg(b);

   vec_ZZ_p x(INIT_SIZE, n);

   for (i = 0; i <= m; i++)
      InnerProduct(x[i], a, b.rep, i);

   if (deg(b) != 0) {
      ZZ_pX c(INIT_SIZE, n);
      LeftShift(c, b, m);

      for (i = m+1; i < n; i++) {
         MulByXMod(c, c, f);
         InnerProduct(x[i], a, c.rep);
      }
   }

   xx = x;
}
开发者ID:Brainloop-Security,项目名称:secret-sharing,代码行数:30,代码来源:ZZ_pX1.cpp

示例6: negate

void negate(vec_ZZ_p& x, const vec_ZZ_p& a)
{
    long n = a.length();
    x.SetLength(n);
    long i;
    for (i = 0; i < n; i++)
        negate(x[i], a[i]);
}
开发者ID:strizhov,项目名称:MKSim,代码行数:8,代码来源:vec_ZZ_p.c

示例7: sub

void sub(vec_ZZ_p& x, const vec_ZZ_p& a, const vec_ZZ_p& b)
{
    long n = a.length();
    if (b.length() != n) LogicError("vector sub: dimension mismatch");
    x.SetLength(n);
    long i;
    for (i = 0; i < n; i++)
        sub(x[i], a[i], b[i]);
}
开发者ID:strizhov,项目名称:MKSim,代码行数:9,代码来源:vec_ZZ_p.c

示例8: mul

void mul(vec_ZZ_p& x, const vec_ZZ_p& a, long b_in)
{
    NTL_ZZ_pRegister(b);
    b = b_in;
    long n = a.length();
    x.SetLength(n);
    long i;
    for (i = 0; i < n; i++)
        mul(x[i], a[i], b);
}
开发者ID:strizhov,项目名称:MKSim,代码行数:10,代码来源:vec_ZZ_p.c

示例9: FastTraceVec

void FastTraceVec(vec_ZZ_p& S, const ZZ_pX& f)
{
   long n = deg(f);

   if (n <= 0) 
      LogicError("FastTraceVec: bad args");

   if (n == 0) {
      S.SetLength(0);
      return;
   }

   if (n == 1) {
      S.SetLength(1);
      set(S[0]);
      return;
   }
   
   long i;
   ZZ_pX f1;

   f1.rep.SetLength(n-1);
   for (i = 0; i <= n-2; i++)
      f1.rep[i] = f.rep[n-i];
   f1.normalize();

   ZZ_pX f2;
   f2.rep.SetLength(n-1);
   for (i = 0; i <= n-2; i++)
      mul(f2.rep[i], f.rep[n-1-i], i+1);
   f2.normalize();

   ZZ_pX f3;
   InvTrunc(f3, f1, n-1);
   MulTrunc(f3, f3, f2, n-1);

   S.SetLength(n);

   S[0] = n;
   for (i = 1; i < n; i++)
      negate(S[i], coeff(f3, i-1));
}
开发者ID:Brainloop-Security,项目名称:secret-sharing,代码行数:42,代码来源:ZZ_pX1.cpp

示例10: FindRoots

void FindRoots(vec_ZZ_p& x, const ZZ_pX& ff)
{
   ZZ_pX f = ff;

   if (!IsOne(LeadCoeff(f)))
      Error("FindRoots: bad args");

   x.SetMaxLength(deg(f));
   x.SetLength(0);
   RecFindRoots(x, f);
}
开发者ID:JamesHirschorn,项目名称:QFCL,代码行数:11,代码来源:ZZ_pXFactoring.cpp

示例11: conv

void conv(vec_ZZ_p& x, const vec_ZZ& a)
{
   long i, n;

   n = a.length();
   x.SetLength(n);

   ZZ_p* xp = x.elts();
   const ZZ* ap = a.elts();

   for (i = 0; i < n; i++)
      conv(xp[i], ap[i]);
}
开发者ID:Brainloop-Security,项目名称:secret-sharing,代码行数:13,代码来源:vec_ZZ_p.cpp

示例12: eval

void eval(vec_ZZ_p& b, const ZZ_pX& f, const vec_ZZ_p& a)
// naive algorithm:  repeats Horner
{
   if (&b == &f.rep) {
      vec_ZZ_p bb;
      eval(bb, f, a);
      b = bb;
      return;
   }

   long m = a.length();
   b.SetLength(m);
   long i;
   for (i = 0; i < m; i++) 
      eval(b[i], f, a[i]);
}
开发者ID:Brainloop-Security,项目名称:secret-sharing,代码行数:16,代码来源:ZZ_pX1.cpp

示例13: VectorCopy

void VectorCopy(vec_ZZ_p& x, const vec_ZZ_p& a, long n)
{
    if (n < 0) LogicError("VectorCopy: negative length");
    if (NTL_OVERFLOW(n, 1, 0)) ResourceError("overflow in VectorCopy");

    long m = min(n, a.length());

    x.SetLength(n);

    long i;

    for (i = 0; i < m; i++)
        x[i] = a[i];

    for (i = m; i < n; i++)
        clear(x[i]);
}
开发者ID:strizhov,项目名称:MKSim,代码行数:17,代码来源:vec_ZZ_p.c

示例14: mul_aux

static
void mul_aux(vec_ZZ_p& x, const mat_ZZ_p& A, const vec_ZZ_p& b)  
{  
   long n = A.NumRows();  
   long l = A.NumCols();  
  
   if (l != b.length())  
      Error("matrix mul: dimension mismatch");  
  
   x.SetLength(n);  
  
   long i, k;  
   ZZ acc, tmp;  
  
   for (i = 1; i <= n; i++) {  
      clear(acc);  
      for (k = 1; k <= l; k++) {  
         mul(tmp, rep(A(i,k)), rep(b(k)));  
         add(acc, acc, tmp);  
      }  
      conv(x(i), acc);  
   }  
}  
开发者ID:av-elier,项目名称:fast-exponentiation-algs,代码行数:23,代码来源:mat_ZZ_p.c

示例15: RecFindRoots

static
void RecFindRoots(vec_ZZ_p& x, const ZZ_pX& f)
{
   if (deg(f) == 0) return;

   if (deg(f) == 1) {
      long k = x.length();
      x.SetLength(k+1);
      negate(x[k], ConstTerm(f));
      return;
   }
      
   ZZ_pX h;

   ZZ_p r;
   ZZ p1;


   RightShift(p1, ZZ_p::modulus(), 1);
   
   {
      ZZ_pXModulus F;
      build(F, f);

      do {
         random(r);
         PowerXPlusAMod(h, r, p1, F);
         add(h, h, -1);
         GCD(h, h, f);
      } while (deg(h) <= 0 || deg(h) == deg(f));
   }

   RecFindRoots(x, h);
   div(h, f, h); 
   RecFindRoots(x, h);
}
开发者ID:JamesHirschorn,项目名称:QFCL,代码行数:36,代码来源:ZZ_pXFactoring.cpp


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