| 2636 | // ---------------------------------------------------------------------------------------- |
| 2637 | |
| 2638 | void trsbox_( |
| 2639 | const integer n, |
| 2640 | const integer npt, |
| 2641 | const doublereal *xpt, |
| 2642 | const doublereal *xopt, |
| 2643 | const doublereal *gopt, |
| 2644 | const doublereal *hq, |
| 2645 | const doublereal *pq, |
| 2646 | const doublereal *sl, |
| 2647 | const doublereal *su, |
| 2648 | const doublereal delta, |
| 2649 | doublereal *xnew, |
| 2650 | doublereal *d__, |
| 2651 | doublereal *gnew, |
| 2652 | doublereal *xbdi, |
| 2653 | doublereal *s, |
| 2654 | doublereal *hs, |
| 2655 | doublereal *hred, |
| 2656 | doublereal *dsq, |
| 2657 | doublereal *crvmin |
| 2658 | ) const |
| 2659 | { |
| 2660 | /* System generated locals */ |
| 2661 | integer xpt_dim1, xpt_offset, i__1, i__2; |
| 2662 | doublereal d__1, d__2, d__3, d__4; |
| 2663 | |
| 2664 | /* Local variables */ |
| 2665 | integer i__, j, k, ih; |
| 2666 | doublereal ds; |
| 2667 | integer iu; |
| 2668 | doublereal dhd, dhs, cth, one, shs, sth, ssq, half, beta, sdec, blen; |
| 2669 | integer iact = 0, nact = 0; |
| 2670 | doublereal angt, qred; |
| 2671 | integer isav; |
| 2672 | doublereal temp = 0, zero = 0, xsav = 0, xsum = 0, angbd = 0, dredg = 0, sredg = 0; |
| 2673 | integer iterc; |
| 2674 | doublereal resid = 0, delsq = 0, ggsav = 0, tempa = 0, tempb = 0, |
| 2675 | redmax = 0, dredsq = 0, redsav = 0, onemin = 0, gredsq = 0, rednew = 0; |
| 2676 | integer itcsav = 0; |
| 2677 | doublereal rdprev = 0, rdnext = 0, stplen = 0, stepsq = 0; |
| 2678 | integer itermax = 0; |
| 2679 | |
| 2680 | |
| 2681 | /* The arguments N, NPT, XPT, XOPT, GOPT, HQ, PQ, SL and SU have the same */ |
| 2682 | /* meanings as the corresponding arguments of BOBYQB. */ |
| 2683 | /* DELTA is the trust region radius for the present calculation, which */ |
| 2684 | /* seeks a small value of the quadratic model within distance DELTA of */ |
| 2685 | /* XOPT subject to the bounds on the variables. */ |
| 2686 | /* XNEW will be set to a new vector of variables that is approximately */ |
| 2687 | /* the one that minimizes the quadratic model within the trust region */ |
| 2688 | /* subject to the SL and SU constraints on the variables. It satisfies */ |
| 2689 | /* as equations the bounds that become active during the calculation. */ |
| 2690 | /* D is the calculated trial step from XOPT, generated iteratively from an */ |
| 2691 | /* initial value of zero. Thus XNEW is XOPT+D after the final iteration. */ |
| 2692 | /* GNEW holds the gradient of the quadratic model at XOPT+D. It is updated */ |
| 2693 | /* when D is updated. */ |
| 2694 | /* XBDI is a working space vector. For I=1,2,...,N, the element XBDI(I) is */ |
| 2695 | /* set to -1.0, 0.0, or 1.0, the value being nonzero if and only if the */ |