Пример #1
0
bool SingularPart::fillSigma(double* sigma) const {
  // Set up the variables.
  int nTheta = basis->getRank();
  const double* u = basis->getAbscissas();
  double* theta = new double[nTheta];
  for (int i = 0; i < nTheta; i++) theta[i] = acos(-1.)*0.5*(u[i] + 1.);
  double* beta =  curvature.getBeta(theta, nTheta);
  double p = getRegularityPower();

  // Set sigma to the solution if beta were constant.
  for (int i = 0; i < nTheta; i++) sigma[i] = p < 1. ?
    pow(beta[i]*0.125/(p*(1.-p)), 0.125) :
    pow(beta[i]*0.125/(p*(p - 1.)), 0.125) ;

  double* lap = getOperator(theta);
  bool converged = newtonRaphson(sigma, beta, lap);
  if (!converged) {
    std::clog << "Newton-Raphson did not converge.\n";
  }

  delete[] lap;
  delete[] theta;
  delete[] beta;
  return converged;
}
Пример #2
0
 double newtonRaphson ( // finds root f_(x_) = y_ in [p_, q_] with derivative y_'
 double y_, // f_ (x_) = y_
 double (*f_) (double x_), // function
 double (*df_) (double x_), // derivative of function
 double p_, // end-point
 double x_, // initial guess : can be arbitrary
 double q_, // end-point
 double tol_, // absolute tolerance
 double rtol_, // relative tolerance
 Int4 *itmax_) // maximum # of permitted iterations
 {
    s_f = f_;
    s_df = df_;
    return newtonRaphson (y_, f, df, ZERO, p_, x_, q_, tol_, rtol_, itmax_);
 }