亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? zz_pex.cpp

?? 一個比較通用的大數運算庫
?? CPP
?? 第 1 頁 / 共 5 頁
字號:



#include <NTL/ZZ_pEX.h>
#include <NTL/vec_vec_ZZ_p.h>

#include <NTL/new.h>

NTL_START_IMPL


const ZZ_pEX& ZZ_pEX::zero()
{
   static ZZ_pEX z;
   return z;
}


istream& operator>>(istream& s, ZZ_pEX& x)
{
   s >> x.rep;
   x.normalize();
   return s;
}

ostream& operator<<(ostream& s, const ZZ_pEX& a)
{
   return s << a.rep;
}


void ZZ_pEX::normalize()
{
   long n;
   const ZZ_pE* p;

   n = rep.length();
   if (n == 0) return;
   p = rep.elts() + n;
   while (n > 0 && IsZero(*--p)) {
      n--;
   }
   rep.SetLength(n);
}


long IsZero(const ZZ_pEX& a)
{
   return a.rep.length() == 0;
}


long IsOne(const ZZ_pEX& a)
{
    return a.rep.length() == 1 && IsOne(a.rep[0]);
}

long operator==(const ZZ_pEX& a, long b)
{
   if (b == 0)
      return IsZero(a);

   if (b == 1)
      return IsOne(a);

   long da = deg(a);

   if (da > 0) return 0;

   NTL_ZZ_pRegister(bb);
   bb = b;

   if (da < 0)
      return IsZero(bb);

   return a.rep[0] == bb;
}

long operator==(const ZZ_pEX& a, const ZZ_p& b)
{
   if (IsZero(b))
      return IsZero(a);

   long da = deg(a);

   if (da != 0)
      return 0;

   return a.rep[0] == b;
}

long operator==(const ZZ_pEX& a, const ZZ_pE& b)
{
   if (IsZero(b))
      return IsZero(a);

   long da = deg(a);

   if (da != 0)
      return 0;

   return a.rep[0] == b;
}




void SetCoeff(ZZ_pEX& x, long i, const ZZ_pE& a)
{
   long j, m;

   if (i < 0) 
      Error("SetCoeff: negative index");

   if (NTL_OVERFLOW(i, 1, 0))
      Error("overflow in SetCoeff");

   m = deg(x);

   if (i > m) {
      /* careful: a may alias a coefficient of x */

      long alloc = x.rep.allocated();

      if (alloc > 0 && i >= alloc) {
         ZZ_pE aa = a;
         x.rep.SetLength(i+1);
         x.rep[i] = aa;
      }
      else {
         x.rep.SetLength(i+1);
         x.rep[i] = a;
      }

      for (j = m+1; j < i; j++)
         clear(x.rep[j]);
   }
   else
      x.rep[i] = a;

   x.normalize();
}

void SetCoeff(ZZ_pEX& x, long i, const ZZ_p& aa)
{
   long j, m;

   if (i < 0)
      Error("SetCoeff: negative index");

   if (NTL_OVERFLOW(i, 1, 0))
      Error("overflow in SetCoeff");

   NTL_ZZ_pRegister(a);  // watch out for aliases!
   a = aa;

   m = deg(x);

   if (i > m) {
      x.rep.SetLength(i+1);
      for (j = m+1; j < i; j++)
         clear(x.rep[j]);
   }
   x.rep[i] = a;
   x.normalize();
}

void SetCoeff(ZZ_pEX& x, long i, long a)
{
   if (a == 1)
      SetCoeff(x, i);
   else {
      NTL_ZZ_pRegister(T);
      T = a;
      SetCoeff(x, i, T);
   }
}



void SetCoeff(ZZ_pEX& x, long i)
{
   long j, m;

   if (i < 0) 
      Error("coefficient index out of range");

   if (NTL_OVERFLOW(i, 1, 0))
      Error("overflow in SetCoeff");

   m = deg(x);

   if (i > m) {
      x.rep.SetLength(i+1);
      for (j = m+1; j < i; j++)
         clear(x.rep[j]);
   }
   set(x.rep[i]);
   x.normalize();
}


void SetX(ZZ_pEX& x)
{
   clear(x);
   SetCoeff(x, 1);
}


long IsX(const ZZ_pEX& a)
{
   return deg(a) == 1 && IsOne(LeadCoeff(a)) && IsZero(ConstTerm(a));
}
      
      

const ZZ_pE& coeff(const ZZ_pEX& a, long i)
{
   if (i < 0 || i > deg(a))
      return ZZ_pE::zero();
   else
      return a.rep[i];
}


const ZZ_pE& LeadCoeff(const ZZ_pEX& a)
{
   if (IsZero(a))
      return ZZ_pE::zero();
   else
      return a.rep[deg(a)];
}

const ZZ_pE& ConstTerm(const ZZ_pEX& a)
{
   if (IsZero(a))
      return ZZ_pE::zero();
   else
      return a.rep[0];
}



void conv(ZZ_pEX& x, const ZZ_pE& a)
{
   if (IsZero(a))
      x.rep.SetLength(0);
   else {
      x.rep.SetLength(1);
      x.rep[0] = a;
   }
}

void conv(ZZ_pEX& x, long a)
{
   if (a == 0) 
      clear(x);
   else if (a == 1)
      set(x);
   else {
      NTL_ZZ_pRegister(T);
      T = a;
      conv(x, T);
   }
}

void conv(ZZ_pEX& x, const ZZ& a)
{
   NTL_ZZ_pRegister(T);
   conv(T, a);
   conv(x, T);
}

void conv(ZZ_pEX& x, const ZZ_p& a)
{
   if (IsZero(a)) 
      clear(x);
   else if (IsOne(a))
      set(x);
   else {
      x.rep.SetLength(1);
      conv(x.rep[0], a);
      x.normalize();
   }
}

void conv(ZZ_pEX& x, const ZZ_pX& aa)
{
   ZZ_pX a = aa; // in case a aliases the rep of a coefficient of x

   long n = deg(a)+1;
   long i;

   x.rep.SetLength(n);
   for (i = 0; i < n; i++)
      conv(x.rep[i], coeff(a, i));
}


void conv(ZZ_pEX& x, const vec_ZZ_pE& a)
{
   x.rep = a;
   x.normalize();
}


void add(ZZ_pEX& x, const ZZ_pEX& a, const ZZ_pEX& b)
{
   long da = deg(a);
   long db = deg(b);
   long minab = min(da, db);
   long maxab = max(da, db);
   x.rep.SetLength(maxab+1);

   long i;
   const ZZ_pE *ap, *bp; 
   ZZ_pE* xp;

   for (i = minab+1, ap = a.rep.elts(), bp = b.rep.elts(), xp = x.rep.elts();
        i; i--, ap++, bp++, xp++)
      add(*xp, (*ap), (*bp));

   if (da > minab && &x != &a)
      for (i = da-minab; i; i--, xp++, ap++)
         *xp = *ap;
   else if (db > minab && &x != &b)
      for (i = db-minab; i; i--, xp++, bp++)
         *xp = *bp;
   else
      x.normalize();
}


void add(ZZ_pEX& x, const ZZ_pEX& a, const ZZ_pE& b)
{
   long n = a.rep.length();
   if (n == 0) {
      conv(x, b);
   }
   else if (&x == &a) {
      add(x.rep[0], a.rep[0], b);
      x.normalize();
   }
   else if (x.rep.MaxLength() == 0) {
      x = a;
      add(x.rep[0], a.rep[0], b);
      x.normalize();
   }
   else {
      // ugly...b could alias a coeff of x

      ZZ_pE *xp = x.rep.elts();
      add(xp[0], a.rep[0], b);
      x.rep.SetLength(n);
      xp = x.rep.elts();
      const ZZ_pE *ap = a.rep.elts();
      long i;
      for (i = 1; i < n; i++)
         xp[i] = ap[i];
      x.normalize();
   }
}

void add(ZZ_pEX& x, const ZZ_pEX& a, const ZZ_p& b)
{
   long n = a.rep.length();
   if (n == 0) {
      conv(x, b);
   }
   else if (&x == &a) {
      add(x.rep[0], a.rep[0], b);
      x.normalize();
   }
   else if (x.rep.MaxLength() == 0) {
      x = a;
      add(x.rep[0], a.rep[0], b);
      x.normalize();
   }
   else {
      // ugly...b could alias a coeff of x

      ZZ_pE *xp = x.rep.elts();
      add(xp[0], a.rep[0], b);
      x.rep.SetLength(n);
      xp = x.rep.elts();
      const ZZ_pE *ap = a.rep.elts();
      long i;
      for (i = 1; i < n; i++)
         xp[i] = ap[i];
      x.normalize();
   }
}


void add(ZZ_pEX& x, const ZZ_pEX& a, long b)
{
   if (a.rep.length() == 0) {
      conv(x, b);
   }
   else {
      if (&x != &a) x = a;
      add(x.rep[0], x.rep[0], b);
      x.normalize();
   }
}


void sub(ZZ_pEX& x, const ZZ_pEX& a, const ZZ_pEX& b)
{
   long da = deg(a);
   long db = deg(b);
   long minab = min(da, db);
   long maxab = max(da, db);
   x.rep.SetLength(maxab+1);

   long i;
   const ZZ_pE *ap, *bp; 
   ZZ_pE* xp;

   for (i = minab+1, ap = a.rep.elts(), bp = b.rep.elts(), xp = x.rep.elts();
        i; i--, ap++, bp++, xp++)
      sub(*xp, (*ap), (*bp));

   if (da > minab && &x != &a)
      for (i = da-minab; i; i--, xp++, ap++)
         *xp = *ap;
   else if (db > minab)
      for (i = db-minab; i; i--, xp++, bp++)
         negate(*xp, *bp);
   else
      x.normalize();
}


void sub(ZZ_pEX& x, const ZZ_pEX& a, const ZZ_pE& b)
{
   long n = a.rep.length();
   if (n == 0) {
      conv(x, b);
      negate(x, x);
   }
   else if (&x == &a) {
      sub(x.rep[0], a.rep[0], b);
      x.normalize();
   }
   else if (x.rep.MaxLength() == 0) {
      x = a;
      sub(x.rep[0], a.rep[0], b);
      x.normalize();
   }
   else {
      // ugly...b could alias a coeff of x

      ZZ_pE *xp = x.rep.elts();
      sub(xp[0], a.rep[0], b);
      x.rep.SetLength(n);
      xp = x.rep.elts();
      const ZZ_pE *ap = a.rep.elts();
      long i;
      for (i = 1; i < n; i++)
         xp[i] = ap[i];
      x.normalize();
   }
}

void sub(ZZ_pEX& x, const ZZ_pEX& a, const ZZ_p& b)
{
   long n = a.rep.length();
   if (n == 0) {
      conv(x, b);
      negate(x, x);
   }
   else if (&x == &a) {
      sub(x.rep[0], a.rep[0], b);
      x.normalize();
   }
   else if (x.rep.MaxLength() == 0) {
      x = a;
      sub(x.rep[0], a.rep[0], b);
      x.normalize();
   }
   else {
      // ugly...b could alias a coeff of x

      ZZ_pE *xp = x.rep.elts();
      sub(xp[0], a.rep[0], b);
      x.rep.SetLength(n);
      xp = x.rep.elts();
      const ZZ_pE *ap = a.rep.elts();
      long i;
      for (i = 1; i < n; i++)
         xp[i] = ap[i];
      x.normalize();
   }
}


void sub(ZZ_pEX& x, const ZZ_pEX& a, long b)
{
   if (a.rep.length() == 0) {
      conv(x, b);
      negate(x, x);
   }
   else {
      if (&x != &a) x = a;
      sub(x.rep[0], x.rep[0], b);
      x.normalize();
   }
}

void sub(ZZ_pEX& x, const ZZ_pE& b, const ZZ_pEX& a)
{
   long n = a.rep.length();
   if (n == 0) {
      conv(x, b);
   }
   else if (x.rep.MaxLength() == 0) {
      negate(x, a);
      add(x.rep[0], x.rep[0], b);
      x.normalize();
   }
   else {
      // ugly...b could alias a coeff of x

      ZZ_pE *xp = x.rep.elts();
      sub(xp[0], b, a.rep[0]);
      x.rep.SetLength(n);
      xp = x.rep.elts();
      const ZZ_pE *ap = a.rep.elts();
      long i;
      for (i = 1; i < n; i++)
         negate(xp[i], ap[i]);
      x.normalize();
   }
}


void sub(ZZ_pEX& x, const ZZ_p& a, const ZZ_pEX& b)
{
   NTL_ZZ_pRegister(T);   // avoids aliasing problems
   T = a;
   negate(x, b);
   add(x, x, T);
}

void sub(ZZ_pEX& x, long a, const ZZ_pEX& b)
{
   NTL_ZZ_pRegister(T); 
   T = a;
   negate(x, b);
   add(x, x, T);
}

void mul(ZZ_pEX& c, const ZZ_pEX& a, const ZZ_pEX& b)
{
   if (&a == &b) {
      sqr(c, a);
      return;
   }

   if (IsZero(a) || IsZero(b)) {
      clear(c);
      return;
   }

   if (deg(a) == 0) {
      mul(c, b, ConstTerm(a));
      return;
   } 

   if (deg(b) == 0) {
      mul(c, a, ConstTerm(b));
      return;
   }

   // general case...Kronecker subst

   ZZ_pX A, B, C;

   long da = deg(a);
   long db = deg(b);

   long n = ZZ_pE::degree();
   long n2 = 2*n-1;

   if (NTL_OVERFLOW(da+db+1, n2, 0))
      Error("overflow in ZZ_pEX mul");

   long i, j;

   A.rep.SetLength((da+1)*n2);

   for (i = 0; i <= da; i++) {
      const ZZ_pX& coeff = rep(a.rep[i]);
      long dcoeff = deg(coeff);
      for (j = 0; j <= dcoeff; j++)
         A.rep[n2*i + j] = coeff.rep[j]; 
   }

   A.normalize();

   B.rep.SetLength((db+1)*n2);

   for (i = 0; i <= db; i++) {
      const ZZ_pX& coeff = rep(b.rep[i]);
      long dcoeff = deg(coeff);
      for (j = 0; j <= dcoeff; j++)
         B.rep[n2*i + j] = coeff.rep[j]; 
   }

   B.normalize();

   mul(C, A, B);

   long Clen = C.rep.length();
   long lc = (Clen + n2 - 1)/n2;
   long dc = lc - 1;

   c.rep.SetLength(dc+1);

   ZZ_pX tmp;
   
   for (i = 0; i <= dc; i++) {
      tmp.rep.SetLength(n2);
      for (j = 0; j < n2 && n2*i + j < Clen; j++)
         tmp.rep[j] = C.rep[n2*i + j];
      for (; j < n2; j++)
         clear(tmp.rep[j]);
      tmp.normalize();
      conv(c.rep[i], tmp);
   }
  
   c.normalize();
}


void mul(ZZ_pEX& x, const ZZ_pEX& a, const ZZ_pE& b)
{
   if (IsZero(b)) {
      clear(x);
      return;
   }

   ZZ_pE t;
   t = b;

   long i, da;

   const ZZ_pE *ap;
   ZZ_pE* xp;

   da = deg(a);
   x.rep.SetLength(da+1);
   ap = a.rep.elts();
   xp = x.rep.elts();

   for (i = 0; i <= da; i++)
      mul(xp[i], ap[i], t);

   x.normalize();
}



void mul(ZZ_pEX& x, const ZZ_pEX& a, const ZZ_p& b)
{
   if (IsZero(b)) {
      clear(x);
      return;
   }

   NTL_ZZ_pRegister(t);
   t = b;

   long i, da;

   const ZZ_pE *ap;
   ZZ_pE* xp;

   da = deg(a);
   x.rep.SetLength(da+1);
   ap = a.rep.elts();
   xp = x.rep.elts();

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美性色aⅴ视频一区日韩精品| 国产精品少妇自拍| 最新成人av在线| 国产麻豆91精品| 2020国产精品| 国产成人综合自拍| 国产日韩三级在线| 99久久免费精品| 悠悠色在线精品| 欧洲精品一区二区| 三级在线观看一区二区| 欧美v日韩v国产v| 国产精品小仙女| 依依成人精品视频| 777色狠狠一区二区三区| 久久综合综合久久综合| 国产亚洲欧美色| 欧美三级日本三级少妇99| 亚洲国产美女搞黄色| 日韩精品一区二区三区视频在线观看| 精品制服美女丁香| 亚洲男人的天堂在线aⅴ视频| 欧美日韩免费不卡视频一区二区三区| 天天av天天翘天天综合网| 精品国产乱码久久久久久夜甘婷婷| 精品亚洲国内自在自线福利| 国产精品丝袜91| 亚洲精品日韩一| 久久久久久一二三区| 欧美日韩在线亚洲一区蜜芽| 国产91精品一区二区麻豆网站 | 日本一区二区高清| 欧美日韩精品欧美日韩精品一综合| 国产老妇另类xxxxx| 夜夜嗨av一区二区三区网页 | 久久精品国产色蜜蜜麻豆| 伊人婷婷欧美激情| 亚洲色图欧美在线| 国产欧美日本一区视频| 日韩午夜三级在线| 欧美久久久久久蜜桃| 色综合久久99| 色综合天天综合网天天看片| 成人禁用看黄a在线| 国产精品一二一区| 国内精品久久久久影院一蜜桃| 日韩精品福利网| 午夜精品爽啪视频| 亚洲一区二区三区中文字幕在线 | 欧美精品日韩精品| 欧美婷婷六月丁香综合色| 一本一道波多野结衣一区二区| 成人午夜免费电影| 大美女一区二区三区| 国产乱码精品一区二区三| 激情另类小说区图片区视频区| 秋霞午夜鲁丝一区二区老狼| 男人的j进女人的j一区| 久久99久国产精品黄毛片色诱| 国产一区二区在线观看免费| 国产在线麻豆精品观看| 成人免费av网站| 欧美日韩精品一二三区| 精品国产sm最大网站| 亚洲欧洲日本在线| 首页国产欧美日韩丝袜| 国产成人精品一区二| 欧美午夜宅男影院| 日韩欧美一二区| 久久精品国产秦先生| 91在线精品一区二区| 日韩一级大片在线观看| 欧美国产在线观看| 亚洲午夜精品一区二区三区他趣| 美国av一区二区| 色国产综合视频| 久久精品视频一区二区三区| 亚洲午夜久久久久中文字幕久| 国产精品资源网站| 欧美日本国产一区| 国产精品白丝在线| 国产福利精品一区| 欧美mv日韩mv| 亚洲国产日韩在线一区模特| 岛国一区二区三区| 久久精品人人做人人爽97| 奇米综合一区二区三区精品视频| 色综合久久中文综合久久97| 久久一夜天堂av一区二区三区| 日韩影视精彩在线| 欧美一区午夜视频在线观看| 亚洲午夜激情av| 欧美日韩精品福利| 亚洲va欧美va天堂v国产综合| 91丝袜美女网| 综合久久久久久| 不卡的看片网站| 亚洲视频在线一区观看| 99视频在线观看一区三区| 国产精品网站一区| 99久久伊人网影院| 亚洲乱码一区二区三区在线观看| 91小视频在线| 亚洲国产另类精品专区| 日韩三级免费观看| 国产精品一区免费在线观看| 久久精品在线观看| 99re热这里只有精品免费视频| 国产精品久久久久久久浪潮网站| 处破女av一区二区| 亚洲图片欧美综合| 精品美女一区二区| jvid福利写真一区二区三区| 亚洲免费视频成人| 精品国产免费视频| 日本精品一区二区三区四区的功能| 亚洲午夜私人影院| 久久色.com| 欧美性猛交xxxx乱大交退制版| 国内精品免费在线观看| 一区二区三区日本| 欧美变态凌虐bdsm| 在线亚洲+欧美+日本专区| 精品亚洲porn| 偷拍日韩校园综合在线| 中文字幕一区二区三区在线观看| 欧美精品一二三四| 91国内精品野花午夜精品| 国产在线不卡一区| 午夜电影网亚洲视频| 中文字幕一区二区三区av| 久久蜜桃av一区精品变态类天堂| 在线观看欧美日本| 成人午夜av电影| 欧美午夜精品免费| 色综合色综合色综合| www.色精品| 成人爽a毛片一区二区免费| 久久 天天综合| 日韩在线卡一卡二| 男男成人高潮片免费网站| 亚洲成人动漫精品| 午夜精品久久久久久| 午夜精品久久久久久久久久| 一区二区三区成人| 亚洲综合免费观看高清在线观看| 亚洲精品国产第一综合99久久| 国产精品丝袜91| 亚洲欧美怡红院| 亚洲精品欧美综合四区| 一区二区成人在线视频| 一区二区三区四区不卡在线 | 欧美一区二区三区播放老司机| 欧美理论在线播放| 精品黑人一区二区三区久久| 欧美刺激午夜性久久久久久久| 日韩一区二区在线观看视频| 欧美mv日韩mv国产网站app| 日韩欧美国产一区在线观看| 久久久高清一区二区三区| 中文字幕av一区 二区| 亚洲一线二线三线视频| 图片区小说区区亚洲影院| 久久精品国产一区二区三| 99久久免费国产| 在线观看视频一区二区| 亚洲欧美国产77777| 日韩电影在线免费看| 国产乱人伦偷精品视频免下载| 91麻豆精品在线观看| 欧美一区中文字幕| 中文字幕一区二区不卡| 蜜臀av一区二区| 日本乱码高清不卡字幕| 精品免费99久久| 午夜精品一区二区三区免费视频| 国产高清精品在线| 在线播放视频一区| 亚洲欧美成aⅴ人在线观看| 激情偷乱视频一区二区三区| 欧美少妇一区二区| 中文字幕不卡在线| 国产精品亚洲成人| 精品三级在线看| 日本网站在线观看一区二区三区 | 高清在线不卡av| 日韩一区二区精品在线观看| 亚洲永久精品大片| 91碰在线视频| 一区二区三区欧美日| 91美女视频网站| 成人免费在线播放视频| av欧美精品.com| 日韩毛片精品高清免费| 91视频在线看| 亚洲成a人片综合在线| 欧美少妇一区二区| 日韩精彩视频在线观看| 欧美一区二区日韩| 精品一区二区三区的国产在线播放|