示例#1
0
NTL_START_IMPL

void ZZVec::SetSize(long n, long d)
{
   if (n < 0 || d <= 0) Error("bad args to ZZVec::SetSize()");

   if (v)
      Error("illegal ZZVec initialization");

   len = n;
   bsize = d;

   if (n == 0) return;

   v = (ZZ*) NTL_MALLOC(n, sizeof(ZZ), 0);
   if (!v) Error("out of memory in ZZVec::SetSize()");

   long i = 0;
   long m;
   long j;

   while (i < n) {
      m = ZZ_BlockConstructAlloc(v[i], d, n-i);
      for (j = 1; j < m; j++)
         ZZ_BlockConstructSet(v[i], v[i+j], j);
      i += m;
   }
}
NTL_START_IMPL

static 
void BasicBlockConstruct(ZZ_p* x, long n, long d)
{
   long m, j;

   long i = 0;

   NTL_SCOPE(guard) { BlockDestroy(x, i); };

   while (i < n) {
      m = ZZ_BlockConstructAlloc(x[i]._ZZ_p__rep, d, n-i);
      for (j = 1; j < m; j++)
         ZZ_BlockConstructSet(x[i]._ZZ_p__rep, x[i+j]._ZZ_p__rep, j);
      i += m;
   }

   guard.relax();
}