Lines Matching refs:stx
10 static PetscErrorCode Tao_mcstep(TaoLineSearch ls, PetscReal *stx, PetscReal *fx, PetscReal *dx, PetscReal *sty, PetscReal *fy, PetscReal *dy, PetscReal *stp, PetscReal *fp, PetscReal *dp);
28 PetscCall(PetscViewerASCIIPrintf(ls->viewer, "stx: %g, fx: %g, dgx: %g\n", (double)mt->stx, (double)mt->fx, (double)mt->dgx));
38 PetscReal dgx, dgy, dg, dg2, fx, fy, stx, sty, dgtest;
100 stx, fx, dgx - the step, function, and derivative at the best step
105 stx = 0.0;
116 ls->stepmin = PetscMin(stx, sty);
117 ls->stepmax = PetscMax(stx, sty);
119 ls->stepmin = stx;
120 ls->stepmax = ls->step + xtrapf * (ls->step - stx);
129 if (stx != 0 && ((mt->bracket && (ls->step <= ls->stepmin || ls->step >= ls->stepmax)) || (mt->bracket && (ls->stepmax - ls->stepmin <= ls->rtol * ls->stepmax)) || (ls->nfeval + ls->nfgeval >= ls->max_funcs - 1) || mt->infoc == 0))
130 ls->step = stx;
160 mt->stx = stx;
229 fxm = fx - stx * dgtest; /* and derivatives */
235 /* if (dgxm * (ls->step - stx) >= 0.0) */
237 PetscCall(Tao_mcstep(ls, &stx, &fxm, &dgxm, &sty, &fym, &dgym, &ls->step, &fm, &dgm));
239 fx = fxm + stx * dgtest; /* Reset the function and */
245 PetscCall(Tao_mcstep(ls, &stx, &fx, &dgx, &sty, &fy, &dgy, &ls->step, f, &dg));
250 if (PetscAbsReal(sty - stx) >= 0.66 * width1) ls->step = stx + 0.5 * (sty - stx);
252 width = PetscAbsReal(sty - stx);
311 the parameter stx contains the step with the least function
313 assumed that the derivative at stx is negative in the
316 with endpoints stx and sty.
320 subroutine mcstep(stx,fx,dx,sty,fy,dy,stp,fp,dp,bracket,
325 stx, fx, and dx are variables which specify the step,
328 of the step, that is, dx and stp-stx must have opposite
339 between stx and sty. On output stp is set to the new step.
363 static PetscErrorCode Tao_mcstep(TaoLineSearch ls, PetscReal *stx, PetscReal *fx, PetscReal *dx, PetscReal *sty, PetscReal *fy, PetscReal *dy, PetscReal *stp, PetscReal *fp, PetscReal *dp)
372 PetscCheck(!mtP->bracket || (*stp > PetscMin(*stx, *sty) && *stp < PetscMax(*stx, *sty)), PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "bad stp in bracket");
373 PetscCheck(*dx * (*stp - *stx) < 0.0, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "dx * (stp-stx) >= 0.0");
382 to stx than the quadratic step, the cubic step is taken,
387 theta = 3 * (*fx - *fp) / (*stp - *stx) + *dx + *dp;
391 if (*stp < *stx) gamma1 = -gamma1;
396 stpc = *stx + r * (*stp - *stx);
397 stpq = *stx + ((*dx / ((*fx - *fp) / (*stp - *stx) + *dx)) * 0.5) * (*stp - *stx);
399 if (PetscAbsReal(stpc - *stx) < PetscAbsReal(stpq - *stx)) stpf = stpc;
405 step is closer to stx than the quadratic (secant) step,
410 theta = 3 * (*fx - *fp) / (*stp - *stx) + *dx + *dp;
414 if (*stp > *stx) gamma1 = -gamma1;
418 stpc = *stp + r * (*stx - *stp);
419 stpq = *stp + (*dp / (*dp - *dx)) * (*stx - *stp);
432 closest to stx is taken, else the step farthest away is taken. */
436 theta = 3 * (*fx - *fp) / (*stp - *stx) + *dx + *dp;
443 if (*stp > *stx) gamma1 = -gamma1;
447 if (r < 0.0 && gamma1 != 0.0) stpc = *stp + r * (*stx - *stp);
448 else if (*stp > *stx) stpc = ls->stepmax;
450 stpq = *stp + (*dp / (*dp - *dx)) * (*stx - *stp);
478 } else if (*stp > *stx) {
494 *sty = *stx;
498 *stx = *stp;
508 if (*sty > *stx) *stp = PetscMin(*stx + 0.66 * (*sty - *stx), *stp);
509 else *stp = PetscMax(*stx + 0.66 * (*sty - *stx), *stp);