本文整理汇总了C++中vec_zz_pE类的典型用法代码示例。如果您正苦于以下问题:C++ vec_zz_pE类的具体用法?C++ vec_zz_pE怎么用?C++ vec_zz_pE使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vec_zz_pE类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: mul
void mul(vec_zz_pE& x, const vec_zz_pE& a, const zz_pE& b_in)
{
zz_pE 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:shayne-fletcher,项目名称:cppf,代码行数:9,代码来源:vec_lzz_pE.cpp
示例2: negate
void negate(vec_zz_pE& x, const vec_zz_pE& a)
{
long n = a.length();
x.SetLength(n);
long i;
for (i = 0; i < n; i++)
negate(x[i], a[i]);
}
开发者ID:shayne-fletcher,项目名称:cppf,代码行数:9,代码来源:vec_lzz_pE.cpp
示例3: sub
void sub(vec_zz_pE& x, const vec_zz_pE& a, const vec_zz_pE& b)
{
long n = a.length();
if (b.length() != n) Error("vector sub: dimension mismatch");
x.SetLength(n);
long i;
for (i = 0; i < n; i++)
sub(x[i], a[i], b[i]);
}
开发者ID:shayne-fletcher,项目名称:cppf,代码行数:10,代码来源:vec_lzz_pE.cpp
示例4: add
void add(vec_zz_pE& x, const vec_zz_pE& a, const vec_zz_pE& b)
{
long n = a.length();
if (b.length() != n) LogicError("vector add: dimension mismatch");
x.SetLength(n);
long i;
for (i = 0; i < n; i++)
add(x[i], a[i], b[i]);
}
开发者ID:axelexic,项目名称:NTL,代码行数:10,代码来源:vec_lzz_pE.c
示例5: InnerProduct
void InnerProduct(zz_pE& x, const vec_zz_pE& a, const vec_zz_pE& b)
{
long n = min(a.length(), b.length());
long i;
zz_pX accum, 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:shayne-fletcher,项目名称:cppf,代码行数:14,代码来源:vec_lzz_pE.cpp
示例6: convert
void convert(vector<ZZX>& X, const vec_zz_pE& A)
{
long n = A.length();
X.resize(n);
for (long i = 0; i < n; i++)
conv(X[i], rep(A[i]));
}
开发者ID:deepinit-arek,项目名称:HElib,代码行数:7,代码来源:NumbTh.cpp
示例7: clear
void clear(vec_zz_pE& x)
{
long n = x.length();
long i;
for (i = 0; i < n; i++)
clear(x[i]);
}
开发者ID:shayne-fletcher,项目名称:cppf,代码行数:7,代码来源:vec_lzz_pE.cpp
示例8: VectorCopy
void VectorCopy(vec_zz_pE& x, const vec_zz_pE& a, long n)
{
if (n < 0) Error("VectorCopy: negative length");
if (NTL_OVERFLOW(n, 1, 0)) Error("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:shayne-fletcher,项目名称:cppf,代码行数:17,代码来源:vec_lzz_pE.cpp
示例9: IsZero
long IsZero(const vec_zz_pE& a)
{
long n = a.length();
long i;
for (i = 0; i < n; i++)
if (!IsZero(a[i]))
return 0;
return 1;
}
开发者ID:shayne-fletcher,项目名称:cppf,代码行数:11,代码来源:vec_lzz_pE.cpp
示例10: mul_aux
namespaceanon
void mul_aux(vec_zz_pE& x, const vec_zz_pE& a, const mat_zz_pE& B)
{
long n = B.NumRows();
long l = B.NumCols();
if (n != a.length())
Error("matrix mul: dimension mismatch");
x.SetLength(l);
long i, k;
zz_pX acc, tmp;
for (i = 1; i <= l; i++) {
clear(acc);
for (k = 1; k <= n; k++) {
mul(tmp, rep(a(k)), rep(B(k,i)));
add(acc, acc, tmp);
}
conv(x(i), acc);
}
}
开发者ID:FredericJacobs,项目名称:newNTL,代码行数:23,代码来源:mat_lzz_pE.c
示例11: applyLinPoly
void applyLinPoly(zz_pE& beta, const vec_zz_pE& C, const zz_pE& alpha, long p)
{
long d = zz_pE::degree();
assert(d == C.length());
zz_pE gamma, res;
gamma = to_zz_pE(zz_pX(1, 1));
res = C[0]*alpha;
for (long i = 1; i < d; i++) {
gamma = power(gamma, p);
res += C[i]*to_zz_pE(CompMod(rep(alpha), rep(gamma), zz_pE::modulus()));
}
beta = res;
}
开发者ID:deepinit-arek,项目名称:HElib,代码行数:16,代码来源:NumbTh.cpp
示例12: solve
void solve(zz_pE& d, vec_zz_pE& X,
const mat_zz_pE& A, const vec_zz_pE& b)
{
long n = A.NumRows();
if (A.NumCols() != n)
Error("solve: nonsquare matrix");
if (b.length() != n)
Error("solve: dimension mismatch");
if (n == 0) {
set(d);
X.SetLength(0);
return;
}
long i, j, k, pos;
zz_pX t1, t2;
zz_pX *x, *y;
const zz_pXModulus& p = zz_pE::modulus();
vec_zz_pX *M = newNTL_NEW_OP vec_zz_pX[n];
for (i = 0; i < n; i++) {
M[i].SetLength(n+1);
for (j = 0; j < n; j++) {
M[i][j].rep.SetMaxLength(2*deg(p)-1);
M[i][j] = rep(A[j][i]);
}
M[i][n].rep.SetMaxLength(2*deg(p)-1);
M[i][n] = rep(b[i]);
}
zz_pX det;
set(det);
for (k = 0; k < n; k++) {
pos = -1;
for (i = k; i < n; i++) {
rem(t1, M[i][k], p);
M[i][k] = t1;
if (pos == -1 && !IsZero(t1)) {
pos = i;
}
}
if (pos != -1) {
if (k != pos) {
swap(M[pos], M[k]);
negate(det, det);
}
MulMod(det, det, M[k][k], p);
// make M[k, k] == -1 mod p, and make row k reduced
InvMod(t1, M[k][k], p);
negate(t1, t1);
for (j = k+1; j <= n; j++) {
rem(t2, M[k][j], p);
MulMod(M[k][j], t2, t1, p);
}
for (i = k+1; i < n; i++) {
// M[i] = M[i] + M[k]*M[i,k]
t1 = M[i][k]; // this is already reduced
x = M[i].elts() + (k+1);
y = M[k].elts() + (k+1);
for (j = k+1; j <= n; j++, x++, y++) {
// *x = *x + (*y)*t1
mul(t2, *y, t1);
add(*x, *x, t2);
}
}
}
else {
clear(d);
goto done;
}
}
X.SetLength(n);
for (i = n-1; i >= 0; i--) {
clear(t1);
for (j = i+1; j < n; j++) {
mul(t2, rep(X[j]), M[i][j]);
add(t1, t1, t2);
}
sub(t1, t1, M[i][n]);
conv(X[i], t1);
}
conv(d, det);
//.........这里部分代码省略.........
开发者ID:FredericJacobs,项目名称:newNTL,代码行数:101,代码来源:mat_lzz_pE.c
注:本文中的vec_zz_pE类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论