本文整理汇总了C++中vec_zz_p::elts方法的典型用法代码示例。如果您正苦于以下问题:C++ vec_zz_p::elts方法的具体用法?C++ vec_zz_p::elts怎么用?C++ vec_zz_p::elts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vec_zz_p
的用法示例。
在下文中一共展示了vec_zz_p::elts方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InnerProduct
void InnerProduct(zz_p& x, const vec_zz_p& a, const vec_zz_p& b,
long offset)
{
if (offset < 0) LogicError("InnerProduct: negative offset");
if (NTL_OVERFLOW(offset, 1, 0)) ResourceError("InnerProduct: offset too big");
long n = min(a.length(), b.length()+offset);
long i;
long accum, t;
long p = zz_p::modulus();
mulmod_t pinv = zz_p::ModulusInverse();
const zz_p *ap = a.elts();
const zz_p *bp = b.elts();
accum = 0;
for (i = offset; i < n; i++) {
t = MulMod(rep(ap[i]), rep(bp[i-offset]), p, pinv);
accum = AddMod(accum, t, p);
}
x.LoopHole() = accum;
}
示例2: mul
void mul(vec_zz_p& x, const vec_zz_p& a, zz_p b)
{
long n = a.length();
x.SetLength(n);
long i;
if (n <= 1) {
for (i = 0; i < n; i++)
mul(x[i], a[i], b);
}
else {
long p = zz_p::modulus();
double pinv = zz_p::ModulusInverse();
long bb = rep(b);
mulmod_precon_t bpinv = PrepMulModPrecon(bb, p, pinv);
const zz_p *ap = a.elts();
zz_p *xp = x.elts();
for (i = 0; i < n; i++)
xp[i].LoopHole() = MulModPrecon(rep(ap[i]), bb, p, bpinv);
}
}
示例3: mul_aux
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())
LogicError("matrix mul: dimension mismatch");
x.SetLength(n);
zz_p* xp = x.elts();
long p = zz_p::modulus();
mulmod_t pinv = zz_p::ModulusInverse();
long i, k;
long acc, tmp;
const zz_p* bp = b.elts();
if (n <= 1) {
for (i = 0; i < n; i++) {
acc = 0;
const zz_p* ap = A[i].elts();
for (k = 0; k < l; k++) {
tmp = MulMod(rep(ap[k]), rep(bp[k]), p, pinv);
acc = AddMod(acc, tmp, p);
}
xp[i].LoopHole() = acc;
}
}
else {
Vec<mulmod_precon_t>::Watcher watch_precon_vec(precon_vec);
precon_vec.SetLength(l);
mulmod_precon_t *bpinv = precon_vec.elts();
for (k = 0; k < l; k++)
bpinv[k] = PrepMulModPrecon(rep(bp[k]), p, pinv);
for (i = 0; i < n; i++) {
acc = 0;
const zz_p* ap = A[i].elts();
for (k = 0; k < l; k++) {
tmp = MulModPrecon(rep(ap[k]), rep(bp[k]), p, bpinv[k]);
acc = AddMod(acc, tmp, p);
}
xp[i].LoopHole() = acc;
}
}
}
示例4: InnerProduct
void InnerProduct(zz_pX& x, const vec_zz_p& v, long low, long high,
const vec_zz_pX& H, long n, vec_zz_p& t)
{
zz_p s;
long i, j;
zz_p *tp = t.elts();
for (j = 0; j < n; j++)
clear(tp[j]);
long p = zz_p::modulus();
double pinv = zz_p::ModulusInverse();
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();
zz_p w = (v[i]);
long W = rep(w);
mulmod_precon_t Wpinv = PrepMulModPrecon(W, p, pinv); // ((double) W)*pinv;
const zz_p *hp = h.elts();
for (j = 0; j < m; j++) {
long S = MulModPrecon(rep(hp[j]), W, p, Wpinv);
S = AddMod(S, rep(tp[j]), p);
tp[j].LoopHole() = S;
}
}
x.rep = t;
x.normalize();
}
示例5: negate
void negate(vec_zz_p& x, const vec_zz_p& a)
{
long n = a.length();
long p = zz_p::modulus();
x.SetLength(n);
const zz_p *ap = a.elts();
zz_p *xp = x.elts();
long i;
for (i = 0; i < n; i++)
xp[i].LoopHole() = NegateMod(rep(ap[i]), p);
}
示例6: add
void add(vec_zz_p& x, const vec_zz_p& a, const vec_zz_p& b)
{
long n = a.length();
if (b.length() != n) LogicError("vector add: dimension mismatch");
long p = zz_p::modulus();
x.SetLength(n);
const zz_p *ap = a.elts();
const zz_p *bp = b.elts();
zz_p *xp = x.elts();
long i;
for (i = 0; i < n; i++)
xp[i].LoopHole() = AddMod(rep(ap[i]), rep(bp[i]), p);
}
示例7: conv
// NOTE: the signature for this is in lzz_p.h
void conv(vec_zz_p& x, const Vec<long>& a)
{
long i, n;
n = a.length();
x.SetLength(n);
VectorConv(n, x.elts(), a.elts());
}
示例8: clear
void clear(vec_zz_p& x)
{
long n = x.length();
zz_p *xp = x.elts();
long i;
for (i = 0; i < n; i++)
clear(xp[i]);
}
示例9: 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]);
}
示例10: 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);
const zz_p *ap = a.elts();
zz_p *xp = x.elts();
long i;
for (i = 0; i < m; i++)
xp[i] = ap[i];
for (i = m; i < n; i++)
clear(xp[i]);
}
示例11: IsZero
long IsZero(const vec_zz_p& a)
{
long n = a.length();
const zz_p *ap = a.elts();
long i;
for (i = 0; i < n; i++)
if (!IsZero(ap[i]))
return 0;
return 1;
}
示例12: PlainTraceVec
void PlainTraceVec(vec_zz_p& S, const zz_pX& ff)
{
if (deg(ff) <= 0)
Error("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_p acc, t;
const zz_p *fp = f.rep.elts();;
zz_p *sp = S.elts();
sp[0] = n;
for (k = 1; k < n; k++) {
mul(acc, fp[n-k], k);
for (i = 1; i < k; i++) {
mul(t, fp[n-i], rep(sp[k-i]));
add(acc, acc, t);
}
negate(sp[k], acc);
}
}
示例13: mul
void mul(vec_zz_p& x, const vec_zz_p& a, const mat_zz_p& B)
{
long l = a.length();
long m = B.NumCols();
if (l != B.NumRows())
LogicError("matrix mul: dimension mismatch");
if (m == 0) {
x.SetLength(0);
}
else if (m == 1) {
long p = zz_p::modulus();
mulmod_t pinv = zz_p::ModulusInverse();
long acc, tmp;
long k;
acc = 0;
for(k = 1; k <= l; k++) {
tmp = MulMod(rep(a(k)), rep(B(k,1)), p, pinv);
acc = AddMod(acc, tmp, p);
}
x.SetLength(1);
x(1).LoopHole() = acc;
}
else { // m > 1. precondition
long p = zz_p::modulus();
mulmod_t pinv = zz_p::ModulusInverse();
vec_long::Watcher watch_mul_aux_vec(mul_aux_vec);
mul_aux_vec.SetLength(m);
long *acc = mul_aux_vec.elts();
long j, k;
const zz_p* ap = a.elts();
for (j = 0; j < m; j++) acc[j] = 0;
for (k = 0; k < l; k++) {
long aa = rep(ap[k]);
if (aa != 0) {
const zz_p* bp = B[k].elts();
long T1;
mulmod_precon_t aapinv = PrepMulModPrecon(aa, p, pinv);
for (j = 0; j < m; j++) {
T1 = MulModPrecon(rep(bp[j]), aa, p, aapinv);
acc[j] = AddMod(acc[j], T1, p);
}
}
}
x.SetLength(m);
zz_p *xp = x.elts();
for (j = 0; j < m; j++)
xp[j].LoopHole() = acc[j];
}
}