protected void updateCholeskyFactor(Matrix L,double[] D,double[] v,double coeff,boolean[] isFixed) throws Exception {
  double t, p, b;
  int n=v.length;
  double[] vp=new double[n];
  for (int i=0; i < v.length; i++) {
    if (!isFixed[i]) {
      vp[i]=v[i];
    }
 else {
      vp[i]=0.0;
    }
  }
  if (coeff > 0.0) {
    t=coeff;
    for (int j=0; j < n; j++) {
      if (isFixed[j]) {
        continue;
      }
      p=vp[j];
      double d=D[j], dbarj=d + t * p * p;
      D[j]=dbarj;
      b=p * t / dbarj;
      t*=d / dbarj;
      for (int r=j + 1; r < n; r++) {
        if (!isFixed[r]) {
          double l=L.get(r,j);
          vp[r]-=p * l;
          L.set(r,j,l + b * vp[r]);
        }
 else {
          L.set(r,j,0.0);
        }
      }
    }
  }
 else {
    double[] P=solveTriangle(L,v,true,isFixed);
    t=0.0;
    for (int i=0; i < n; i++) {
      if (!isFixed[i]) {
        t+=P[i] * P[i] / D[i];
      }
    }
    double sqrt=1.0 + coeff * t;
    sqrt=(sqrt < 0.0) ? 0.0 : Math.sqrt(sqrt);
    double alpha=coeff, sigma=coeff / (1.0 + sqrt), rho, theta;
    for (int j=0; j < n; j++) {
      if (isFixed[j]) {
        continue;
      }
      double d=D[j];
      p=P[j] * P[j] / d;
      theta=1.0 + sigma * p;
      t-=p;
      if (t < 0.0) {
        t=0.0;
      }
      double plus=sigma * sigma * p* t;
      if ((j < n - 1) && (plus <= m_Zero)) {
        plus=m_Zero;
      }
      rho=theta * theta + plus;
      D[j]=rho * d;
      if (Double.isNaN(D[j])) {
        throw new Exception("d[" + j + "] NaN! P="+ P[j]+ ",d="+ d+ ",t="+ t+ ",p="+ p+ ",sigma="+ sigma+ ",sclar="+ coeff);
      }
      b=alpha * P[j] / (rho * d);
      alpha/=rho;
      rho=Math.sqrt(rho);
      double sigmaOld=sigma;
      sigma*=(1.0 + rho) / (rho * (theta + rho));
      if ((j < n - 1) && (Double.isNaN(sigma) || Double.isInfinite(sigma))) {
        throw new Exception("sigma NaN/Inf! rho=" + rho + ",theta="+ theta+ ",P["+ j+ "]="+ P[j]+ ",p="+ p+ ",d="+ d+ ",t="+ t+ ",oldsigma="+ sigmaOld);
      }
      for (int r=j + 1; r < n; r++) {
        if (!isFixed[r]) {
          double l=L.get(r,j);
          vp[r]-=P[j] * l;
          L.set(r,j,l + b * vp[r]);
        }
 else {
          L.set(r,j,0.0);
        }
      }
    }
  }
}

protected void updateCholeskyFactor ( Matrix L , double [ ] D , double [ ] v , double coeff , boolean [ ] isFixed ) throws Exception { double t , p , b ; int n = v . length ; double [ ] vp = new double [ n ] ; for ( int i = 0 ; i < v . length ; i ++ ) { if ( ! isFixed [ i ] ) { vp [ i ] = v [ i ] ; } else { vp [ i ] = 0.0 ; } } if ( coeff > 0.0 ) { t = coeff ; for ( int j = 0 ; j < n ; j ++ ) { if ( isFixed [ j ] ) { continue ; } p = vp [ j ] ; double d = D [ j ] , dbarj = d + t * p * p ; D [ j ] = dbarj ; b = p * t / dbarj ; t *= d / dbarj ; for ( int r = j + 1 ; r < n ; r ++ ) { if ( ! isFixed [ r ] ) { double l = L . get ( r , j ) ; vp [ r ] -= p * l ; L . set ( r , j , l + b * vp [ r ] ) ; } else { L . set ( r , j , 0.0 ) ; } } } } else { double [ ] P = solveTriangle ( L , v , true , isFixed ) ; t = 0.0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! isFixed [ i ] ) { t += P [ i ] * P [ i ] / D [ i ] ; } } double sqrt = 1.0 + coeff * t ; sqrt = ( sqrt < 0.0 ) ? 0.0 : Math . sqrt ( sqrt ) ; double alpha = coeff , sigma = coeff / ( 1.0 + sqrt ) , rho , theta ; for ( int j = 0 ; j < n ; j ++ ) { if ( isFixed [ j ] ) { continue ; } double d = D [ j ] ; p = P [ j ] * P [ j ] / d ; theta = 1.0 + sigma * p ; t -= p ; if ( t < 0.0 ) { t = 0.0 ; } double plus = sigma * sigma * p * t ; if ( ( j < n - 1 ) && ( plus <= m_Zero ) ) { plus = m_Zero ; } rho = theta * theta + plus ; D [ j ] = rho * d ; if ( Double . isNaN ( D [ j ] ) ) { throw new Exception ( "d[" + j + "] NaN! P=" + P [ j ] + ",d=" + d + ",t=" + t + ",p=" + p + ",sigma=" + sigma + ",sclar=" + coeff ) ; } b = alpha * P [ j ] / ( rho * d ) ; alpha /= rho ; rho = Math . sqrt ( rho ) ; double sigmaOld = sigma ; sigma *= ( 1.0 + rho ) / ( rho * ( theta + rho ) ) ; if ( ( j < n - 1 ) && ( Double . isNaN ( sigma ) || Double . isInfinite ( sigma ) ) ) { throw new Exception ( "sigma NaN/Inf! rho=" + rho + ",theta=" + theta + ",P[" + j + "]=" + P [ j ] + ",p=" + p + ",d=" + d + ",t=" + t + ",oldsigma=" + sigmaOld ) ; } for ( int r = j + 1 ; r < n ; r ++ ) { if ( ! isFixed [ r ] ) { double l = L . get ( r , j ) ; vp [ r ] -= P [ j ] * l ; L . set ( r , j , l + b * vp [ r ] ) ; } else { L . set ( r , j , 0.0 ) ; } } } } }
one rank update of the cholesky factorization of b matrix in bfgs updates , i . e . b = ldl ' , and b_ { new } = ldl ' + coeff * ( vv ' ) where l is a unit lower triangle matrix and d is a diagonal matrix , and v is a vector . < br / > when coeff > 0 , we use c1 algorithm , and otherwise we use c2 algorithm described in ` ` methods for modifying matrix factorizations ' '
