external/blend2d/src/blend2d/blmath.cpp
// Variable-shift k-polynomial iteration for a quadratic factor converges only
// if the zeros are equimodular or nearly so.
//
// uu, vv - coefficients of starting quadratic.
// nz     - number of zeros found.
Variable-shift k-polynomial iteration for a quadratic factor converges only
if the zeros are equimodular or nearly so.

uu, vv - coefficients of starting quadratic.
nz     - number of zeros found.
Variable - shift k - polynomial iteration for a quadratic factor converges only if the zeros are equimodular or nearly so . uu vv - coefficients of starting quadratic . nz - number of zeros found .
void BLJenkinsTraubSolver::quadit(double* uu, double* vv, int* nz) {
  double ui, vi;
  double mp, omp, ee, relstp, t, zm;
  int type, i, j, tried;
  *nz = 0;
  tried = 0;
  u = *uu;
  v = *vv;
  j = 0;
  for (;;) {
    itercnt++;
    quad(1.0, u, v, &szr, &szi, &lzr, &lzi);
    if (blAbs(blAbs(szr) - blAbs(lzr)) > 0.01 * blAbs(lzr))
      return;
    quadsd(n, &u, &v, p, qp, &a, &b);
    mp = blAbs(a - szr * b) + blAbs(szi * b);
    zm = blSqrt(blAbs(v));
    ee = 2.0 * blAbs(qp[0]);
    t = -szr*b;
    for (i = 1; i < n; i++)
      ee = ee * zm + blAbs(qp[i]);
    ee = ee * zm + blAbs(a+t);
    ee *= (5.0 * mre + 4.0 * are);
    ee = ee - (5.0 * mre + 2.0 * are) * (blAbs(a + t) + blAbs(b) * zm);
    ee = ee + 2.0*are * blAbs(t);
    if (mp <= 20.0 * ee) {
      *nz = 2;
      return;
    }
    if (++j > 20)
      return;
    if (!(j < 2 || relstp > 0.01 || mp < omp || tried)) {
      if (relstp < JT_ETA)
        relstp = JT_ETA;
      relstp = blSqrt(relstp);
      u = u - u * relstp;
      v = v + v * relstp;
      quadsd(n, &u, &v, p, qp, &a, &b);
      for (i = 0; i < 5; i++) {
        calcsc(&type);
        nextk(&type);
      }
      tried = 1;
      j = 0;
    }
    omp = mp;
    calcsc(&type);
    nextk(&type);
    calcsc(&type);
    newest(type,&ui,&vi);
    if (vi == 0.0)
      return;
    relstp = blAbs((vi - v) / vi);
    u = ui;
    v = vi;
  }
}
void BLJenkinsTraubSolver :: quadit ( double * uu , double * vv , int * nz ) { double ui , vi ; double mp , omp , ee , relstp , t , zm ; int type , i , j , tried ; * nz = 0 ; tried = 0 ; u = * uu ; v = * vv ; j = 0 ; for ( ; ; ) { itercnt ++ ; quad ( 1.0 , u , v , & szr , & szi , & lzr , & lzi ) ; if ( blAbs ( blAbs ( szr ) - blAbs ( lzr ) ) > 0.01 * blAbs ( lzr ) ) return ; quadsd ( n , & u , & v , p , qp , & a , & b ) ; mp = blAbs ( a - szr * b ) + blAbs ( szi * b ) ; zm = blSqrt ( blAbs ( v ) ) ; ee = 2.0 * blAbs ( qp [ 0 ] ) ; t = - szr * b ; for ( i = 1 ; i < n ; i ++ ) ee = ee * zm + blAbs ( qp [ i ] ) ; ee = ee * zm + blAbs ( a + t ) ; ee *= ( 5.0 * mre + 4.0 * are ) ; ee = ee - ( 5.0 * mre + 2.0 * are ) * ( blAbs ( a + t ) + blAbs ( b ) * zm ) ; ee = ee + 2.0 * are * blAbs ( t ) ; if ( mp <= 20.0 * ee ) { * nz = 2 ; return ; } if ( ++ j > 20 ) return ; if ( ! ( j < 2 || relstp > 0.01 || mp < omp || tried ) ) { if ( relstp < JT_ETA ) relstp = JT_ETA ; relstp = blSqrt ( relstp ) ; u = u - u * relstp ; v = v + v * relstp ; quadsd ( n , & u , & v , p , qp , & a , & b ) ; for ( i = 0 ; i < 5 ; i ++ ) { calcsc ( & type ) ; nextk ( & type ) ; } tried = 1 ; j = 0 ; } omp = mp ; calcsc ( & type ) ; nextk ( & type ) ; calcsc ( & type ) ; newest ( type , & ui , & vi ) ; if ( vi == 0.0 ) return ; relstp = blAbs ( ( vi - v ) / vi ) ; u = ui ; v = vi ; } }
Variable-shift k-polynomial iteration for a quadratic factor converges only
if the zeros are equimodular or nearly so.
Variable - shift k - polynomial iteration for a quadratic factor converges only if the zeros are equimodular or nearly so .
// Main loop. // Return if roots of the quadratic are real and not close to multiple or // nearly equal and of opposite sign. // Evaluate polynomial by quadratic synthetic division. // Compute a rigorous bound on the rounding error in evaluating p. // Iteration has converged sufficiently if the polynomial value is less than // 20 times this bound. // Stop iteration after 20 steps. // A cluster appears to be stalling the convergence. Five fixed shift steps // are taken with a u,v close to the cluster. // Calculate next k polynomial and new u and v. // If vi is zero the iteration is not converging.