本文整理汇总了C++中vec_ZZ_p类的典型用法代码示例。如果您正苦于以下问题:C++ vec_ZZ_p类的具体用法?C++ vec_ZZ_p怎么用?C++ vec_ZZ_p使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vec_ZZ_p类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: 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
示例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: 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
示例4: 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
示例5: 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
示例6: 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
示例7: 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
示例8: InnerProduct
void InnerProduct(ZZ_p& x, const vec_ZZ_p& a, const vec_ZZ_p& b)
{
long n = min(a.length(), b.length());
long i;
NTL_ZZRegister(accum);
NTL_ZZRegister(t);
clear(accum);
for (i = 0; i < n; i++) {
mul(t, rep(a[i]), rep(b[i]));
add(accum, accum, t);
}
conv(x, accum);
}
开发者ID:strizhov,项目名称:MKSim,代码行数:15,代码来源:vec_ZZ_p.c
示例9: 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
示例10: clear
void clear(vec_ZZ_p& x)
{
long n = x.length();
long i;
for (i = 0; i < n; i++)
clear(x[i]);
}
开发者ID:strizhov,项目名称:MKSim,代码行数:7,代码来源:vec_ZZ_p.c
示例11: InnerProduct
void InnerProduct(ZZ_pX& x, const vec_ZZ_p& v, long low, long high,
const vec_ZZ_pX& H, long n, ZZVec& t)
{
NTL_ZZRegister(s);
long i, j;
for (j = 0; j < n; j++)
clear(t[j]);
high = min(high, v.length()-1);
for (i = low; i <= high; i++) {
const vec_ZZ_p& h = H[i-low].rep;
long m = h.length();
const ZZ& w = rep(v[i]);
for (j = 0; j < m; j++) {
mul(s, w, rep(h[j]));
add(t[j], t[j], s);
}
}
x.rep.SetLength(n);
for (j = 0; j < n; j++)
conv(x.rep[j], t[j]);
x.normalize();
}
开发者ID:Brainloop-Security,项目名称:secret-sharing,代码行数:26,代码来源:ZZ_pX1.cpp
示例12: 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
示例13: 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
示例14: 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
示例15: 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
示例16: 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
示例17: IsZero
long IsZero(const vec_ZZ_p& a)
{
long n = a.length();
long i;
for (i = 0; i < n; i++)
if (!IsZero(a[i]))
return 0;
return 1;
}
开发者ID:strizhov,项目名称:MKSim,代码行数:11,代码来源:vec_ZZ_p.c
示例18: MinPolySeq
void MinPolySeq(ZZ_pX& h, const vec_ZZ_p& a, long m)
{
if (m < 0) LogicError("MinPoly: bad args");
if (NTL_OVERFLOW(m, 1, 0)) LogicError("MinPoly: bad args");
if (a.length() < 2*m) LogicError("MinPoly: sequence too short");
if (m > NTL_ZZ_pX_BERMASS_CROSSOVER)
GCDMinPolySeq(h, a, m);
else
BerlekampMassey(h, a, m);
}
开发者ID:Brainloop-Security,项目名称:secret-sharing,代码行数:11,代码来源:ZZ_pX1.cpp
示例19: FindFactors
static
void FindFactors(vec_ZZ_pX& factors, const ZZ_pX& f, const ZZ_pX& g,
const vec_ZZ_p& roots)
{
long r = roots.length();
factors.SetMaxLength(r);
factors.SetLength(0);
RecFindFactors(factors, f, g, roots, 0, r-1);
}
开发者ID:JamesHirschorn,项目名称:QFCL,代码行数:11,代码来源:ZZ_pXFactoring.cpp
示例20: InnerProduct
// inner product (svec_ZZ and svec_ZZ_p)
inline void InnerProduct(ZZ_p& result, const svec_ZZ& a, const vec_ZZ_p& b) {
if (a.length()!=b.length()) {
cerr<<"InnerProduct() length mismatch\n";
exit(1);
}
clear(result);
long an = a.nvalues();
const svec_ZZ::index_t* ai = a.indices();
const svec_ZZ::value_t* av = a.values();
for (long i=0; i<an; ++i)
result += to_ZZ_p(av[i])*b[ai[i]];
}
开发者ID:daniellerch,项目名称:factorlab,代码行数:13,代码来源:smatrix.cpp
注:本文中的vec_ZZ_p类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论