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

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

?? xdouble.c

?? 密碼大家Shoup寫的數論算法c語言實現
?? C
字號:
#include <NTL/xdouble.h>#include <NTL/RR.h>#include <NTL/new.h>NTL_START_IMPLlong xdouble::oprec = 10;void xdouble::SetOutputPrecision(long p){   if (p < 1) p = 1;   if (p >= (1L << (NTL_BITS_PER_LONG-4)))       Error("xdouble: output precision too big");   oprec = p;}void xdouble::normalize() {   if (x == 0)       e = 0;   else if (x > 0) {      while (x < NTL_XD_HBOUND_INV) { x *= NTL_XD_BOUND; e--; }      while (x > NTL_XD_HBOUND) { x *= NTL_XD_BOUND_INV; e++; }   }   else {      while (x > -NTL_XD_HBOUND_INV) { x *= NTL_XD_BOUND; e--; }      while (x < -NTL_XD_HBOUND) { x *= NTL_XD_BOUND_INV; e++; }   }   if (e >= (1L << (NTL_BITS_PER_LONG-4)))      Error("xdouble: overflow");   if (e <= -(1L << (NTL_BITS_PER_LONG-4)))      Error("xdouble: underflow");}   xdouble to_xdouble(double a){   if (a == 0 || a == 1 || (a > 0 && a >= NTL_XD_HBOUND_INV && a <= NTL_XD_HBOUND)       || (a < 0 && a <= -NTL_XD_HBOUND_INV && a >= -NTL_XD_HBOUND)) {            return xdouble(a, 0);    }   if (!IsFinite(&a))      Error("double to xdouble conversion: non finite value");   xdouble z = xdouble(a, 0);   z.normalize();   return z;}void conv(double& xx, const xdouble& a){   double x;   long e;   x = a.x;   e = a.e;   while (e > 0) { x *= NTL_XD_BOUND; e--; }   while (e < 0) { x *= NTL_XD_BOUND_INV; e++; }   xx = x;}xdouble operator+(const xdouble& a, const xdouble& b){   xdouble z;   if (a.x == 0)       return b;   if (b.x == 0)     return a;         if (a.e == b.e) {      z.x = a.x + b.x;      z.e = a.e;      z.normalize();      return z;   }   else if (a.e > b.e) {      if (a.e > b.e+1)         return a;      z.x = a.x + b.x*NTL_XD_BOUND_INV;      z.e = a.e;      z.normalize();      return z;   }   else {      if (b.e > a.e+1)         return b;      z.x = a.x*NTL_XD_BOUND_INV + b.x;      z.e = b.e;      z.normalize();      return z;   }}xdouble operator-(const xdouble& a, const xdouble& b){   xdouble z;   if (a.x == 0)      return -b;   if (b.x == 0)      return a;   if (a.e == b.e) {      z.x = a.x - b.x;      z.e = a.e;      z.normalize();      return z;   }   else if (a.e > b.e) {      if (a.e > b.e+1)         return a;      z.x = a.x - b.x*NTL_XD_BOUND_INV;      z.e = a.e;      z.normalize();      return z;   }   else {      if (b.e > a.e+1)         return -b;      z.x = a.x*NTL_XD_BOUND_INV - b.x;      z.e = b.e;      z.normalize();      return z;   }}xdouble operator-(const xdouble& a){   xdouble z;   z.x = -a.x;   z.e = a.e;   return z;}xdouble operator*(const xdouble& a, const xdouble& b){   xdouble z;   z.e = a.e + b.e;   z.x = a.x * b.x;   z.normalize();   return z;}xdouble operator/(const xdouble& a, const xdouble& b){   xdouble z;   if (b.x == 0) Error("xdouble division by 0");   z.e = a.e - b.e;   z.x = a.x / b.x;   z.normalize();   return z;}long compare(const xdouble& a, const xdouble& b){   xdouble z = a - b;   if (z.x < 0)      return -1;   else if (z.x == 0)      return 0;   else      return 1;}long sign(const xdouble& z){   if (z.x < 0)      return -1;   else if (z.x == 0)      return 0;   else      return 1;}   xdouble trunc(const xdouble& a){   if (a.x >= 0)      return floor(a);   else      return ceil(a);}xdouble floor(const xdouble& aa){   xdouble z;   xdouble a = aa;   ForceToMem(&a.x);   if (a.e == 0) {      z.x = floor(a.x);      z.e = 0;      z.normalize();      return z;   }   else if (a.e > 0) {      return a;   }   else {      if (a.x < 0)         return to_xdouble(-1);      else         return to_xdouble(0);   }}xdouble ceil(const xdouble& aa){   xdouble z;   xdouble a = aa;   ForceToMem(&a.x);   if (a.e == 0) {      z.x = ceil(a.x);      z.e = 0;      z.normalize();      return z;   }   else if (a.e > 0) {      return a;   }   else {      if (a.x < 0)         return to_xdouble(0);      else         return to_xdouble(1);   }}xdouble to_xdouble(const ZZ& a){   long old_p = RR::precision();   RR::SetPrecision(NTL_DOUBLE_PRECISION);      static RR t;   conv(t, a);   double x;   conv(x, t.mantissa());   xdouble y, z, res;   conv(y, x);   power2(z, t.exponent());   res = y*z;   RR::SetPrecision(old_p);   return res;}void conv(ZZ& x, const xdouble& a){   xdouble b = floor(a);   long old_p = RR::precision();   RR::SetPrecision(NTL_DOUBLE_PRECISION);   static RR t;   conv(t, b);   conv(x, t);   RR::SetPrecision(old_p);}xdouble fabs(const xdouble& a){   xdouble z;   z.e = a.e;   z.x = fabs(a.x);   return z;}xdouble sqrt(const xdouble& a){   if (a == 0)      return to_xdouble(0);   if (a < 0)      Error("xdouble: sqrt of negative number");   xdouble t;   if (a.e & 1) {      t.e = (a.e - 1)/2;      t.x = sqrt(a.x * NTL_XD_BOUND);   }   else {      t.e = a.e/2;      t.x = sqrt(a.x);   }   t.normalize();   return t;}      void power(xdouble& z, const xdouble& a, const ZZ& e){   xdouble b, res;   b = a;   res = 1;   long n = NumBits(e);   long i;   for (i = n-1; i >= 0; i--) {      res = res * res;      if (bit(e, i))         res = res * b;   }   if (sign(e) < 0)       z = 1/res;   else      z = res;}void power(xdouble& z, const xdouble& a, long e){   static ZZ E;   E = e;   power(z, a, E);}      void power2(xdouble& z, long e){   long hb = NTL_XD_HBOUND_LOG;   long b = 2*hb;   long q, r;   q = e/b;   r = e%b;   while (r >= hb) {      r -= b;      q++;   }   while (r < -hb) {      r += b;      q--;   }   if (q >= (1L << (NTL_BITS_PER_LONG-4)))      Error("xdouble: overflow");   if (q <= -(1L << (NTL_BITS_PER_LONG-4)))      Error("xdouble: underflow");   int rr = r;   double x = ldexp(1.0, rr);   z.x = x;   z.e = q;}void MulAdd(xdouble& z, const xdouble& a, const xdouble& b, const xdouble& c)// z = a + b*c{   double x;   long e;   e = b.e + c.e;   x = b.x * c.x;   if (x == 0) {       z = a;      return;   }   if (a.x == 0) {      z.e = e;      z.x = x;      z.normalize();      return;   }         if (a.e == e) {      z.x = a.x + x;      z.e = e;      z.normalize();      return;   }   else if (a.e > e) {      if (a.e > e+1) {         z = a;         return;      }      z.x = a.x + x*NTL_XD_BOUND_INV;      z.e = a.e;      z.normalize();      return;   }   else {      if (e > a.e+1) {         z.x = x;         z.e = e;         z.normalize();         return;      }      z.x = a.x*NTL_XD_BOUND_INV + x;      z.e = e;      z.normalize();      return;   }}void MulSub(xdouble& z, const xdouble& a, const xdouble& b, const xdouble& c)// z = a - b*c{   double x;   long e;   e = b.e + c.e;   x = b.x * c.x;   if (x == 0) {       z = a;      return;   }   if (a.x == 0) {      z.e = e;      z.x = -x;      z.normalize();      return;   }         if (a.e == e) {      z.x = a.x - x;      z.e = e;      z.normalize();      return;   }   else if (a.e > e) {      if (a.e > e+1) {         z = a;         return;      }      z.x = a.x - x*NTL_XD_BOUND_INV;      z.e = a.e;      z.normalize();      return;   }   else {      if (e > a.e+1) {         z.x = -x;         z.e = e;         z.normalize();         return;      }      z.x = a.x*NTL_XD_BOUND_INV - x;      z.e = e;      z.normalize();      return;   }}double log(const xdouble& a){   static double LogBound = log(NTL_XD_BOUND);   if (a.x <= 0) {      Error("log(xdouble): argument must be positive");   }   return log(a.x) + a.e*LogBound;}xdouble xexp(double x){   const double LogBound = log(NTL_XD_BOUND);   double y = x/LogBound;   double iy = floor(y+0.5);   if (iy >= (1L << (NTL_BITS_PER_LONG-4)))      Error("xdouble: overflow");   if (iy <= -(1L << (NTL_BITS_PER_LONG-4)))      Error("xdouble: underflow");   double fy = y - iy;   xdouble res;   res.e = long(iy);   res.x = exp(fy*LogBound);   res.normalize();   return res;}/**************  input / output routines **************/void ComputeLn2(RR&);void ComputeLn10(RR&);long ComputeMax10Power(){   long old_p = RR::precision();   RR::SetPrecision(NTL_BITS_PER_LONG);   RR ln2, ln10;   ComputeLn2(ln2);   ComputeLn10(ln10);   long k = to_long( to_RR(1L << (NTL_BITS_PER_LONG-5)) * ln2 / ln10 );   RR::SetPrecision(old_p);   return k;}xdouble PowerOf10(const ZZ& e){   static long init = 0;   static xdouble v10k;   static long k;   if (!init) {      long old_p = RR::precision();      k = ComputeMax10Power();      RR::SetPrecision(NTL_DOUBLE_PRECISION);      v10k = to_xdouble(power(to_RR(10), k));       RR::SetPrecision(old_p);      init = 1;   }   ZZ e1;   long neg;   if (e < 0) {      e1 = -e;      neg = 1;   }   else {      e1 = e;      neg = 0;   }   long r;   ZZ q;   r = DivRem(q, e1, k);   long old_p = RR::precision();   RR::SetPrecision(NTL_DOUBLE_PRECISION);   xdouble x1 = to_xdouble(power(to_RR(10), r));   RR::SetPrecision(old_p);   xdouble x2 = power(v10k, q);   xdouble x3 = x1*x2;   if (neg) x3 = 1/x3;   return x3;}ostream& operator<<(ostream& s, const xdouble& a){   if (a == 0) {      s << "0";      return s;   }   long old_p = RR::precision();   long temp_p = long(log(fabs(log(fabs(a))) + 1.0)/log(2.0)) + 10;    RR::SetPrecision(temp_p);   RR ln2, ln10, log_2_10;   ComputeLn2(ln2);   ComputeLn10(ln10);   log_2_10 = ln10/ln2;   ZZ log_10_a = to_ZZ(  (to_RR(a.e)*to_RR(2*NTL_XD_HBOUND_LOG) + log(fabs(a.x))/log(2.0))/log_2_10);   RR::SetPrecision(old_p);   xdouble b;   long neg;   if (a < 0) {      b = -a;      neg = 1;   }   else {      b = a;      neg = 0;   }   ZZ k = xdouble::OutputPrecision() - log_10_a;   xdouble c, d;   c = PowerOf10(to_ZZ(xdouble::OutputPrecision()));   d = PowerOf10(log_10_a);   b = b / d;   b = b * c;   while (b < c) {      b = b * 10.0;      k++;   }   while (b >= c) {      b = b / 10.0;      k--;   }   b = b + 0.5;   k = -k;   ZZ B;   conv(B, b);   long bp_len = xdouble::OutputPrecision()+10;   char *bp = NTL_NEW_OP char[bp_len];   if (!bp) Error("xdouble output: out of memory");   long len, i;   len = 0;   do {      if (len >= bp_len) Error("xdouble output: buffer overflow");      bp[len] = DivRem(B, B, 10) + '0';      len++;   } while (B > 0);   for (i = 0; i < len/2; i++) {      char tmp;      tmp = bp[i];      bp[i] = bp[len-1-i];      bp[len-1-i] = tmp;   }   i = len-1;   while (bp[i] == '0') i--;   k += (len-1-i);   len = i+1;   bp[len] = '\0';   if (k > 3 || k < -len - 3) {      // use scientific notation      if (neg) s << "-";      s << "0." << bp << "e" << (k + len);   }   else {      long kk = to_long(k);      if (kk >= 0) {         if (neg) s << "-";         s << bp;         for (i = 0; i < kk; i++)             s << "0";      }      else if (kk <= -len) {         if (neg) s << "-";         s << "0.";         for (i = 0; i < -len-kk; i++)            s << "0";         s << bp;      }      else {         if (neg) s << "-";         for (i = 0; i < len+kk; i++)            s << bp[i];            s << ".";            for (i = len+kk; i < len; i++)            s << bp[i];      }   }   delete [] bp;   return s;}istream& operator>>(istream& s, xdouble& x){   long c;   long sign;   ZZ a, b;   if (!s) Error("bad xdouble input");   c = s.peek();   while (c == ' ' || c == '\n' || c == '\t') {      s.get();      c = s.peek();   }   if (c == '-') {      sign = -1;      s.get();      c = s.peek();   }   else      sign = 1;   long got1 = 0;   long got_dot = 0;   long got2 = 0;   a = 0;   b = 1;   if (c >= '0' && c <= '9') {      got1 = 1;      while (c >= '0' && c <= '9') {         mul(a, a, 10);         add(a, a, c-'0');         s.get();         c = s.peek();      }   }   if (c == '.') {      got_dot = 1;      s.get();      c = s.peek();      if (c >= '0' && c <= '9') {         got2 = 1;            while (c >= '0' && c <= '9') {            mul(a, a, 10);            add(a, a, c-'0');            mul(b, b, 10);            s.get();            c = s.peek();         }      }   }   if (got_dot && !got1 && !got2)  Error("bad xdouble input");   ZZ e;   long got_e = 0;   long e_sign;   if (c == 'e' || c == 'E') {      got_e = 1;      s.get();      c = s.peek();      if (c == '-') {         e_sign = -1;         s.get();         c = s.peek();      }      else if (c == '+') {         e_sign = 1;         s.get();         c = s.peek();      }      else         e_sign = 1;      if (c < '0' || c > '9') Error("bad xdouble input");      e = 0;      while (c >= '0' && c <= '9') {         mul(e, e, 10);         add(e, e, c-'0');         s.get();         c = s.peek();      }   }   if (!got1 && !got2 && !got_e) Error("bad xdouble input");   xdouble t1, t2, v;   if (got1 || got2) {      conv(t1, a);      conv(t2, b);      v = t1/t2;   }   else      v = 1;   if (sign < 0)      v = -v;   if (got_e) {      if (e_sign < 0) negate(e, e);      t1 = PowerOf10(e);      v = v * t1;   }   x = v;   return s;}xdouble to_xdouble(const char *s){   long c;   long sign;   ZZ a, b;   long i=0;   if (!s) Error("bad xdouble input");   c = s[i];   while (c == ' ' || c == '\n' || c == '\t') {      i++;      c = s[i];   }   if (c == '-') {      sign = -1;      i++;      c = s[i];   }   else      sign = 1;   long got1 = 0;   long got_dot = 0;   long got2 = 0;   a = 0;   b = 1;   if (c >= '0' && c <= '9') {      got1 = 1;      while (c >= '0' && c <= '9') {         mul(a, a, 10);         add(a, a, c-'0');         i++;         c = s[i];      }   }   if (c == '.') {      got_dot = 1;      i++;      c = s[i];      if (c >= '0' && c <= '9') {         got2 = 1;            while (c >= '0' && c <= '9') {            mul(a, a, 10);            add(a, a, c-'0');            mul(b, b, 10);            i++;            c = s[i];         }      }   }   if (got_dot && !got1 && !got2)  Error("bad xdouble input");   ZZ e;   long got_e = 0;   long e_sign;   if (c == 'e' || c == 'E') {      got_e = 1;      i++;      c = s[i];      if (c == '-') {         e_sign = -1;         i++;         c = s[i];      }      else if (c == '+') {         e_sign = 1;         i++;         c = s[i];      }      else         e_sign = 1;      if (c < '0' || c > '9') Error("bad xdouble input");      e = 0;      while (c >= '0' && c <= '9') {         mul(e, e, 10);         add(e, e, c-'0');         i++;         c = s[i];      }   }   if (!got1 && !got2 && !got_e) Error("bad xdouble input");   xdouble t1, t2, v;   if (got1 || got2) {      conv(t1, a);      conv(t2, b);      v = t1/t2;   }   else      v = 1;   if (sign < 0)      v = -v;   if (got_e) {      if (e_sign < 0) negate(e, e);      t1 = PowerOf10(e);      v = v * t1;   }   return v;}NTL_END_IMPL

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99久久精品国产麻豆演员表| 欧美精品v国产精品v日韩精品| 成人伦理片在线| av电影天堂一区二区在线| 97精品超碰一区二区三区| 一本一本久久a久久精品综合麻豆 一本一道波多野结衣一区二区 | 欧美高清视频不卡网| 6080午夜不卡| 久久免费美女视频| 国产精品国产成人国产三级| 亚洲男同性恋视频| 天天综合网 天天综合色| 日韩1区2区3区| 国产一区二区网址| 99久精品国产| 国产精品综合视频| 欧美亚洲国产一区在线观看网站| 91精品免费观看| 日韩精品一区国产麻豆| 亚洲色图在线播放| 日韩电影在线免费| 极品少妇xxxx偷拍精品少妇| 91福利精品视频| 欧美一级生活片| 国产日韩v精品一区二区| 亚洲444eee在线观看| 国产精品99久| 在线观看亚洲一区| 久久看人人爽人人| 亚洲国产一区视频| heyzo一本久久综合| 欧美日韩国产免费一区二区| 2023国产精品自拍| 一区二区三区在线高清| 加勒比av一区二区| 欧美日韩一区二区三区四区 | 国产高清成人在线| 欧美三级午夜理伦三级中视频| 精品国产三级电影在线观看| 亚洲一区二区三区四区中文字幕| 精品无人码麻豆乱码1区2区| 欧美中文字幕一区二区三区 | 91一区在线观看| 精品久久久久久久久久久久久久久 | 国产精品久久99| 精品亚洲免费视频| 欧美在线观看视频一区二区 | 美女任你摸久久| 一本久久a久久免费精品不卡| 久久久精品免费免费| 亚洲成a人片在线不卡一二三区| 国产高清不卡一区| 久久综合一区二区| 日本aⅴ精品一区二区三区| 99国产麻豆精品| 国产亚洲短视频| 精品一区二区三区在线播放| 福利一区二区在线观看| 久久久精品人体av艺术| 免费高清在线一区| 欧美一级久久久| 亚洲一区二区三区免费视频| www.欧美精品一二区| 亚洲国产精品ⅴa在线观看| 毛片av一区二区| 欧美视频一区在线观看| 亚洲国产中文字幕| 91久久精品网| 亚洲欧美另类久久久精品2019 | 中文字幕国产一区| 国产在线播放一区三区四| 欧美一区二区三区免费大片| 亚洲激情中文1区| 日本韩国一区二区三区| 国产精品护士白丝一区av| 国产激情偷乱视频一区二区三区| 国产欧美一区在线| 国产一区二区伦理| 在线成人av影院| 蜜臀a∨国产成人精品| 欧美视频你懂的| 日韩高清不卡在线| 日韩一区二区在线看片| 日一区二区三区| 日韩美女视频在线| 麻豆国产一区二区| 91精品蜜臀在线一区尤物| 精品一区二区三区免费| 欧美中文字幕不卡| 亚洲午夜在线电影| 欧美日韩激情一区二区三区| 亚洲成人黄色小说| 91麻豆精品国产91久久久更新时间| 偷窥国产亚洲免费视频| 欧美日本视频在线| 精品一区二区三区久久| 久久中文字幕电影| 国产午夜精品理论片a级大结局| 亚洲一区二区五区| 91久久精品日日躁夜夜躁欧美| 国产色91在线| 成人一道本在线| 久久久午夜精品理论片中文字幕| 国产成人99久久亚洲综合精品| 国产精品女人毛片| 色婷婷精品大视频在线蜜桃视频| 一区二区三区电影在线播| 日韩无一区二区| 国产一区二区网址| 国产精品蜜臀在线观看| 欧美无砖专区一中文字| 日韩黄色在线观看| 国产精品理论在线观看| 成人免费视频视频在线观看免费| 中文字幕av不卡| 欧美日韩视频在线观看一区二区三区 | 国产欧美综合在线观看第十页| 精油按摩中文字幕久久| 亚洲三级视频在线观看| 在线观看日韩高清av| 日韩不卡免费视频| 久久久久久久久岛国免费| 97精品久久久午夜一区二区三区 | 国产精品99久久久久久宅男| ...xxx性欧美| 日韩免费观看高清完整版在线观看| 国产福利一区在线观看| 亚洲狼人国产精品| 日韩一区二区视频在线观看| 国产精品亚洲一区二区三区妖精| 亚洲欧美视频一区| 日韩精品中文字幕一区二区三区| 国产精品69毛片高清亚洲| 亚洲电影你懂得| 久久久国产一区二区三区四区小说 | 91精品国产乱码久久蜜臀| 成人开心网精品视频| 午夜在线成人av| 国产精品剧情在线亚洲| 欧美tk—视频vk| 色婷婷精品大视频在线蜜桃视频| 日日夜夜精品视频天天综合网| 亚洲欧美综合网| 日韩一级二级三级| 99久久精品免费看| 日本人妖一区二区| 亚洲美女免费在线| 国产偷国产偷精品高清尤物 | 久久新电视剧免费观看| 欧美性生活大片视频| 激情综合色播激情啊| 亚洲综合久久久久| 久久九九99视频| 日韩情涩欧美日韩视频| 在线看国产一区二区| 国产一区二区免费看| 日韩成人精品在线观看| 中文字幕在线视频一区| 欧美理论电影在线| 日本精品裸体写真集在线观看| 国产乱人伦精品一区二区在线观看| 午夜精品久久久久久| 中文字幕中文字幕在线一区| 欧美tk丨vk视频| 欧美一级黄色录像| 欧美无砖砖区免费| 99久久国产综合色|国产精品| 国产一区二区三区免费看| 水蜜桃久久夜色精品一区的特点 | 日本va欧美va精品| 一区二区三区欧美日韩| 亚洲欧洲国产专区| 亚洲国产成人午夜在线一区| 日韩亚洲欧美高清| 日韩欧美一区二区久久婷婷| 欧美中文字幕亚洲一区二区va在线| 国产一区二区三区蝌蚪| 国产专区欧美精品| 免费久久99精品国产| 日本欧美一区二区在线观看| 亚洲综合网站在线观看| 亚洲乱码国产乱码精品精98午夜| 亚洲人成精品久久久久久| 国产精品午夜春色av| 日韩女优视频免费观看| 久久综合成人精品亚洲另类欧美 | 亚洲日本丝袜连裤袜办公室| 亚洲国产成人在线| 日本一区二区三区电影| 中文字幕乱码日本亚洲一区二区| 久久亚洲捆绑美女| 精品国产伦一区二区三区免费| 精品日产卡一卡二卡麻豆| 日韩精品一区二区三区老鸭窝| 欧美一级二级在线观看| 日韩欧美国产小视频| 日韩精品一区二区三区中文不卡 | 美女在线一区二区| 美洲天堂一区二卡三卡四卡视频| 国产一区二区三区最好精华液|