void BlockConstructFromVec(GF2E* x, long n, const GF2E* y)
{
   if (n <= 0) return;

   long d = y->_GF2E__rep.xrep.MaxLength();
   BasicBlockConstruct(x, n, d);

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

   long i;
   for (i = 0; i < n; i++) x[i] = y[i];

   guard.relax();
}
void BlockConstructFromVec(ZZ_p* x, long n, const ZZ_p* y)
{
   if (n <= 0) return;

   long d = y->_ZZ_p__rep.MaxAlloc() - 1;
   BasicBlockConstruct(x, n, d);

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

   long i;
   for (i = 0; i < n; i++) x[i] = y[i];

   guard.relax();
}
void BlockConstructFromObj(GF2E* x, long n, const GF2E& y)
{
   if (n <= 0) return;

   if (!GF2EInfo)
      LogicError("GF2E constructor called while modulus undefined");

   long d = GF2E::WordLength();

   BasicBlockConstruct(x, n, d);

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

   long i;
   for (i = 0; i < n; i++) x[i] = y;

   guard.relax();
}
void BlockConstructFromObj(ZZ_p* x, long n, const ZZ_p& y)
{
   if (n <= 0) return;


   if (!ZZ_pInfo)
      LogicError("ZZ_p constructor called while modulus undefined");

   long d = ZZ_p::ModulusSize();

   BasicBlockConstruct(x, n, d);

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

   long i;
   for (i = 0; i < n; i++) x[i] = y;

   guard.relax();
}
NTL_START_IMPL

static
void BasicBlockConstruct(GF2E* x, long n, long d)
{
   long m, j;
 
   long i = 0;

   NTL_SCOPE(guard) { BlockDestroy(x, i); };
 
   while (i < n) {
      m = WV_BlockConstructAlloc(x[i]._GF2E__rep.xrep, d, n-i);
      for (j = 1; j < m; j++)
         WV_BlockConstructSet(x[i]._GF2E__rep.xrep, x[i+j]._GF2E__rep.xrep, j);
      i += m;
   }

   guard.relax();
}