📄 predicates.cxx
字号:
eindex = findex = 0; if ((fnow > enow) == (fnow > -enow)) { Q = enow; enow = e[++eindex]; } else { Q = fnow; fnow = f[++findex]; } hindex = 0; if ((eindex < elen) && (findex < flen)) { if ((fnow > enow) == (fnow > -enow)) { Fast_Two_Sum(enow, Q, Qnew, hh); enow = e[++eindex]; } else { Fast_Two_Sum(fnow, Q, Qnew, hh); fnow = f[++findex]; } Q = Qnew; if (hh != 0.0) { h[hindex++] = hh; } while ((eindex < elen) && (findex < flen)) { if ((fnow > enow) == (fnow > -enow)) { Two_Sum(Q, enow, Qnew, hh); enow = e[++eindex]; } else { Two_Sum(Q, fnow, Qnew, hh); fnow = f[++findex]; } Q = Qnew; if (hh != 0.0) { h[hindex++] = hh; } } } while (eindex < elen) { Two_Sum(Q, enow, Qnew, hh); enow = e[++eindex]; Q = Qnew; if (hh != 0.0) { h[hindex++] = hh; } } while (findex < flen) { Two_Sum(Q, fnow, Qnew, hh); fnow = f[++findex]; Q = Qnew; if (hh != 0.0) { h[hindex++] = hh; } } if ((Q != 0.0) || (hindex == 0)) { h[hindex++] = Q; } return hindex;}/*****************************************************************************//* *//* linear_expansion_sum() Sum two expansions. *//* *//* Sets h = e + f. See either version of my paper for details. *//* *//* Maintains the nonoverlapping property. (That is, if e is *//* nonoverlapping, h will be also.) *//* *//*****************************************************************************/int linear_expansion_sum(int elen, REAL *e, int flen, REAL *f, REAL *h)/* h cannot be e or f. */{ REAL Q, q; INEXACT REAL Qnew; INEXACT REAL R; INEXACT REAL bvirt; REAL avirt, bround, around; int eindex, findex, hindex; REAL enow, fnow; REAL g0; enow = e[0]; fnow = f[0]; eindex = findex = 0; if ((fnow > enow) == (fnow > -enow)) { g0 = enow; enow = e[++eindex]; } else { g0 = fnow; fnow = f[++findex]; } if ((eindex < elen) && ((findex >= flen) || ((fnow > enow) == (fnow > -enow)))) { Fast_Two_Sum(enow, g0, Qnew, q); enow = e[++eindex]; } else { Fast_Two_Sum(fnow, g0, Qnew, q); fnow = f[++findex]; } Q = Qnew; for (hindex = 0; hindex < elen + flen - 2; hindex++) { if ((eindex < elen) && ((findex >= flen) || ((fnow > enow) == (fnow > -enow)))) { Fast_Two_Sum(enow, q, R, h[hindex]); enow = e[++eindex]; } else { Fast_Two_Sum(fnow, q, R, h[hindex]); fnow = f[++findex]; } Two_Sum(Q, R, Qnew, q); Q = Qnew; } h[hindex] = q; h[hindex + 1] = Q; return hindex + 2;}/*****************************************************************************//* *//* linear_expansion_sum_zeroelim() Sum two expansions, eliminating zero *//* components from the output expansion. *//* *//* Sets h = e + f. See either version of my paper for details. *//* *//* Maintains the nonoverlapping property. (That is, if e is *//* nonoverlapping, h will be also.) *//* *//*****************************************************************************/int linear_expansion_sum_zeroelim(int elen, REAL *e, int flen, REAL *f, REAL *h)/* h cannot be e or f. */{ REAL Q, q, hh; INEXACT REAL Qnew; INEXACT REAL R; INEXACT REAL bvirt; REAL avirt, bround, around; int eindex, findex, hindex; int count; REAL enow, fnow; REAL g0; enow = e[0]; fnow = f[0]; eindex = findex = 0; hindex = 0; if ((fnow > enow) == (fnow > -enow)) { g0 = enow; enow = e[++eindex]; } else { g0 = fnow; fnow = f[++findex]; } if ((eindex < elen) && ((findex >= flen) || ((fnow > enow) == (fnow > -enow)))) { Fast_Two_Sum(enow, g0, Qnew, q); enow = e[++eindex]; } else { Fast_Two_Sum(fnow, g0, Qnew, q); fnow = f[++findex]; } Q = Qnew; for (count = 2; count < elen + flen; count++) { if ((eindex < elen) && ((findex >= flen) || ((fnow > enow) == (fnow > -enow)))) { Fast_Two_Sum(enow, q, R, hh); enow = e[++eindex]; } else { Fast_Two_Sum(fnow, q, R, hh); fnow = f[++findex]; } Two_Sum(Q, R, Qnew, q); Q = Qnew; if (hh != 0) { h[hindex++] = hh; } } if (q != 0) { h[hindex++] = q; } if ((Q != 0.0) || (hindex == 0)) { h[hindex++] = Q; } return hindex;}/*****************************************************************************//* *//* scale_expansion() Multiply an expansion by a scalar. *//* *//* Sets h = be. See either version of my paper for details. *//* *//* Maintains the nonoverlapping property. If round-to-even is used (as *//* with IEEE 754), maintains the strongly nonoverlapping and nonadjacent *//* properties as well. (That is, if e has one of these properties, so *//* will h.) *//* *//*****************************************************************************/int scale_expansion(int elen, REAL *e, REAL b, REAL *h)/* e and h cannot be the same. */{ INEXACT REAL Q; INEXACT REAL sum; INEXACT REAL product1; REAL product0; int eindex, hindex; REAL enow; INEXACT REAL bvirt; REAL avirt, bround, around; INEXACT REAL c; INEXACT REAL abig; REAL ahi, alo, bhi, blo; REAL err1, err2, err3; Split(b, bhi, blo); Two_Product_Presplit(e[0], b, bhi, blo, Q, h[0]); hindex = 1; for (eindex = 1; eindex < elen; eindex++) { enow = e[eindex]; Two_Product_Presplit(enow, b, bhi, blo, product1, product0); Two_Sum(Q, product0, sum, h[hindex]); hindex++; Two_Sum(product1, sum, Q, h[hindex]); hindex++; } h[hindex] = Q; return elen + elen;}/*****************************************************************************//* *//* scale_expansion_zeroelim() Multiply an expansion by a scalar, *//* eliminating zero components from the *//* output expansion. *//* *//* Sets h = be. See either version of my paper for details. *//* *//* Maintains the nonoverlapping property. If round-to-even is used (as *//* with IEEE 754), maintains the strongly nonoverlapping and nonadjacent *//* properties as well. (That is, if e has one of these properties, so *//* will h.) *//* *//*****************************************************************************/int scale_expansion_zeroelim(int elen, REAL *e, REAL b, REAL *h)/* e and h cannot be the same. */{ INEXACT REAL Q, sum; REAL hh; INEXACT REAL product1; REAL product0; int eindex, hindex; REAL enow; INEXACT REAL bvirt; REAL avirt, bround, around; INEXACT REAL c; INEXACT REAL abig; REAL ahi, alo, bhi, blo; REAL err1, err2, err3; Split(b, bhi, blo); Two_Product_Presplit(e[0], b, bhi, blo, Q, hh); hindex = 0; if (hh != 0) { h[hindex++] = hh; } for (eindex = 1; eindex < elen; eindex++) { enow = e[eindex]; Two_Product_Presplit(enow, b, bhi, blo, product1, product0); Two_Sum(Q, product0, sum, hh); if (hh != 0) { h[hindex++] = hh; } Fast_Two_Sum(product1, sum, Q, hh); if (hh != 0) { h[hindex++] = hh; } } if ((Q != 0.0) || (hindex == 0)) { h[hindex++] = Q; } return hindex;}/*****************************************************************************//* *//* compress() Compress an expansion. *//* *//* See the long version of my paper for details. *//* *//* Maintains the nonoverlapping property. If round-to-even is used (as *//* with IEEE 754), then any nonoverlapping expansion is converted to a *//* nonadjacent expansion. *//* *//*****************************************************************************/int compress(int elen, REAL *e, REAL *h)/* e and h may be the same. */{ REAL Q, q; INEXACT REAL Qnew; int eindex, hindex; INEXACT REAL bvirt; REAL enow, hnow; int top, bottom; bottom = elen - 1; Q = e[bottom]; for (eindex = elen - 2; eindex >= 0; eindex--) { enow = e[eindex]; Fast_Two_Sum(Q, enow, Qnew, q); if (q != 0) { h[bottom--] = Qnew; Q = q; } else { Q = Qnew; } } top = 0; for (hindex = bottom + 1; hindex < elen; hindex++) { hnow = h[hindex]; Fast_Two_Sum(hnow, Q, Qnew, q); if (q != 0) { h[top++] = q; } Q = Qnew; } h[top] = Q; return top + 1;}/*****************************************************************************//* *//* estimate() Produce a one-word estimate of an expansion's value. *//* *//* See either version of my paper for details. *//* *//*****************************************************************************/REAL estimate(int elen, REAL *e){ REAL Q; int eindex; Q = e[0]; for (eindex = 1; eindex < elen; eindex++) { Q += e[eindex]; } return Q;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -