本文整理汇总了C++中vec_zz_p::length方法的典型用法代码示例。如果您正苦于以下问题:C++ vec_zz_p::length方法的具体用法?C++ vec_zz_p::length怎么用?C++ vec_zz_p::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vec_zz_p
的用法示例。
在下文中一共展示了vec_zz_p::length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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) Error("vector sub: dimension mismatch");
x.SetLength(n);
long i;
for (i = 0; i < n; i++)
sub(x[i], a[i], b[i]);
}
示例3: 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;
zz_p accum, t;
clear(accum);
for (i = 0; i < n; i++) {
mul(t, a[i], b[i]);
add(accum, accum, t);
}
x = accum;
}
示例4: clear
void clear(vec_zz_p& x)
{
long n = x.length();
long i;
for (i = 0; i < n; i++)
clear(x[i]);
}
示例5: 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();
}
示例6: 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 || NTL_OVERFLOW(k, 1, 0))
Error("ProjectPowers: bad 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);
}
}
示例7: 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);
}
}
示例8: StripZeroes
static void StripZeroes(vec_zz_p& x)
{
long n = x.length();
while (n > 0 && IsZero(x[n-1]))
n--;
x.SetLength(n);
}
示例9: CRT
long CRT(vec_ZZ& gg, ZZ& a, const vec_zz_p& G)
{
long n = gg.length();
if (G.length() != n) Error("CRT: vector length mismatch");
long p = zz_p::modulus();
ZZ new_a;
mul(new_a, a, p);
long a_inv;
a_inv = rem(a, p);
a_inv = InvMod(a_inv, p);
long p1;
p1 = p >> 1;
ZZ a1;
RightShift(a1, a, 1);
long p_odd = (p & 1);
long modified = 0;
long h;
ZZ g;
long i;
for (i = 0; i < n; i++) {
if (!CRTInRange(gg[i], a)) {
modified = 1;
rem(g, gg[i], a);
if (g > a1) sub(g, g, a);
}
else
g = gg[i];
h = rem(g, p);
h = SubMod(rep(G[i]), h, p);
h = MulMod(h, a_inv, p);
if (h > p1)
h = h - p;
if (h != 0) {
modified = 1;
if (!p_odd && g > 0 && (h == p1))
MulSubFrom(g, a, h);
else
MulAddTo(g, a, h);
}
gg[i] = g;
}
a = new_a;
return modified;
}
示例10: conv
void conv(vec_ZZ& x, const vec_zz_p& a)
{
long n = a.length();
x.SetLength(n);
long i;
for (i = 0; i < n; i++)
x[i] = rep(a[i]);
}
示例11: 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]);
}
示例12: 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);
}
示例13: 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;
}
}
}
示例14: MinPolySeq
void MinPolySeq(zz_pX& h, const vec_zz_p& a, long m)
{
if (m < 0 || NTL_OVERFLOW(m, 1, 0)) Error("MinPoly: bad args");
if (a.length() < 2*m) Error("MinPoly: sequence too short");
if (m > NTL_zz_pX_BERMASS_CROSSOVER)
GCDMinPolySeq(h, a, m);
else
BerlekampMassey(h, a, m);
}
示例15: 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]);
}