external/blend2d/src/blend2d/blmath.cpp
// Variable-shift H polynomial iteration for a real zero.
//
// sss - starting iterate
// nz  - number of zeros found
// iflag - flag to indicate a pair of zeros near real axis.
Variable-shift H polynomial iteration for a real zero.
sss - starting iterate
nz  - number of zeros found
iflag - flag to indicate a pair of zeros near real axis.
Variable - shift H polynomial iteration for a real zero . sss - starting iterate nz - number of zeros found iflag - flag to indicate a pair of zeros near real axis .
void BLJenkinsTraubSolver::realit(double sss, int* nz, int* iflag) {
  double pv, kv, t, s;
  double ms, mp, omp, ee;
  int i, j;
  *nz = 0;
  *iflag = 0;
  s = sss;
  j = 0;
  for (;;) {
    itercnt++;
    pv = p[0];
    qp[0] = pv;
    for (i = 1; i <= n; i++) {
      pv = pv*s + p[i];
      qp[i] = pv;
    }
    mp = blAbs(pv);
    ms = blAbs(s);
    ee = (mre / (are + mre)) * blAbs(qp[0]);
    for (i = 1; i <= n; i++)
      ee = ee * ms + blAbs(qp[i]);
    if (mp <= 20.0 * ((are+mre)*ee-mre*mp)) {
      *nz = 1;
      szr = s;
      szi = 0.0;
      return;
    }
    j++;
    if (j > 10) return;
    if (j < 2) goto _50;
    if (blAbs(t) > 0.001 * blAbs(s-t) || mp < omp) goto _50;
    *iflag = 1;
    sss = s;
    return;
_50:
    omp = mp;
    kv = k[0];
    qk[0] = kv;
    for (i = 1; i < n; i++) {
      kv = kv*s + k[i];
      qk[i] = kv;
    }
    if (blAbs(kv) <= blAbs(k[n-1])*10.0*JT_ETA) {
      k[0] = 0.0;
      for (i = 1; i < n; i++)
        k[i] = qk[i-1];
    }
    else {
      t = -pv / kv;
      k[0] = qp[0];
      for (i = 1; i < n; i++)
        k[i] = t*qk[i-1] + qp[i];
    }
    kv = k[0];
    for (i = 1; i < n; i++)
      kv = kv*s + k[i];
    t = 0.0;
    if (blAbs(kv) > blAbs(k[n-1] * 10.0 * JT_ETA))
      t = -pv/kv;
    s += t;
  }
}
void BLJenkinsTraubSolver :: realit ( double sss , int * nz , int * iflag ) { double pv , kv , t , s ; double ms , mp , omp , ee ; int i , j ; * nz = 0 ; * iflag = 0 ; s = sss ; j = 0 ; for ( ; ; ) { itercnt ++ ; pv = p [ 0 ] ; qp [ 0 ] = pv ; for ( i = 1 ; i <= n ; i ++ ) { pv = pv * s + p [ i ] ; qp [ i ] = pv ; } mp = blAbs ( pv ) ; ms = blAbs ( s ) ; ee = ( mre / ( are + mre ) ) * blAbs ( qp [ 0 ] ) ; for ( i = 1 ; i <= n ; i ++ ) ee = ee * ms + blAbs ( qp [ i ] ) ; if ( mp <= 20.0 * ( ( are + mre ) * ee - mre * mp ) ) { * nz = 1 ; szr = s ; szi = 0.0 ; return ; } j ++ ; if ( j > 10 ) return ; if ( j < 2 ) goto _50 ; if ( blAbs ( t ) > 0.001 * blAbs ( s - t ) || mp < omp ) goto _50 ; * iflag = 1 ; sss = s ; return ; _50 : omp = mp ; kv = k [ 0 ] ; qk [ 0 ] = kv ; for ( i = 1 ; i < n ; i ++ ) { kv = kv * s + k [ i ] ; qk [ i ] = kv ; } if ( blAbs ( kv ) <= blAbs ( k [ n - 1 ] ) * 10.0 * JT_ETA ) { k [ 0 ] = 0.0 ; for ( i = 1 ; i < n ; i ++ ) k [ i ] = qk [ i - 1 ] ; } else { t = - pv / kv ; k [ 0 ] = qp [ 0 ] ; for ( i = 1 ; i < n ; i ++ ) k [ i ] = t * qk [ i - 1 ] + qp [ i ] ; } kv = k [ 0 ] ; for ( i = 1 ; i < n ; i ++ ) kv = kv * s + k [ i ] ; t = 0.0 ; if ( blAbs ( kv ) > blAbs ( k [ n - 1 ] * 10.0 * JT_ETA ) ) t = - pv / kv ; s += t ; } }
Variable-shift H polynomial iteration for a real zero.
Variable - shift H polynomial iteration for a real zero .
// Evaluate p at s. // Compute a rigorous bound on the error in evaluating p. // Iteration has converged sufficiently if the polynomial value is less // than 20 times this bound. // Stop iteration after 10 steps. // A cluster of zeros near the real axis has been encountered. Return with // iflag set to initiate a quadratic iteration. // Compute t, the next polynomial, and the new iterate. // HVE n -> n-1 // Use the unscaled form. // Use the scaled form of the recurrence if the value of k at s is nonzero.