| 1765 | |
| 1766 | template <typename funct> |
| 1767 | void prelim_( |
| 1768 | const funct& calfun, |
| 1769 | const integer n, |
| 1770 | const integer npt, |
| 1771 | doublereal *x, |
| 1772 | const doublereal *xl, |
| 1773 | const doublereal *xu, |
| 1774 | const doublereal rhobeg, |
| 1775 | const integer maxfun, |
| 1776 | doublereal *xbase, |
| 1777 | doublereal *xpt, |
| 1778 | doublereal *fval, |
| 1779 | doublereal *gopt, |
| 1780 | doublereal *hq, |
| 1781 | doublereal *pq, |
| 1782 | doublereal *bmat, |
| 1783 | doublereal *zmat, |
| 1784 | const integer ndim, |
| 1785 | const doublereal *sl, |
| 1786 | const doublereal *su, |
| 1787 | integer& nf, |
| 1788 | integer& kopt |
| 1789 | ) const |
| 1790 | { |
| 1791 | /* System generated locals */ |
| 1792 | integer xpt_dim1, xpt_offset, bmat_dim1, bmat_offset, zmat_dim1, |
| 1793 | zmat_offset, i__1, i__2; |
| 1794 | doublereal d__1, d__2, d__3, d__4; |
| 1795 | |
| 1796 | |
| 1797 | /* Local variables */ |
| 1798 | doublereal f; |
| 1799 | integer i__, j, k, ih, np, nfm; |
| 1800 | doublereal one; |
| 1801 | integer nfx = 0, ipt = 0, jpt = 0; |
| 1802 | doublereal two = 0, fbeg = 0, diff = 0, half = 0, temp = 0, zero = 0, recip = 0, stepa = 0, stepb = 0; |
| 1803 | integer itemp; |
| 1804 | doublereal rhosq; |
| 1805 | |
| 1806 | |
| 1807 | |
| 1808 | /* The arguments N, NPT, X, XL, XU, RHOBEG, IPRINT and MAXFUN are the */ |
| 1809 | /* same as the corresponding arguments in SUBROUTINE BOBYQA. */ |
| 1810 | /* The arguments XBASE, XPT, FVAL, HQ, PQ, BMAT, ZMAT, NDIM, SL and SU */ |
| 1811 | /* are the same as the corresponding arguments in BOBYQB, the elements */ |
| 1812 | /* of SL and SU being set in BOBYQA. */ |
| 1813 | /* GOPT is usually the gradient of the quadratic model at XOPT+XBASE, but */ |
| 1814 | /* it is set by PRELIM to the gradient of the quadratic model at XBASE. */ |
| 1815 | /* If XOPT is nonzero, BOBYQB will change it to its usual value later. */ |
| 1816 | /* NF is maintaned as the number of calls of CALFUN so far. */ |
| 1817 | /* KOPT will be such that the least calculated value of F so far is at */ |
| 1818 | /* the point XPT(KOPT,.)+XBASE in the space of the variables. */ |
| 1819 | |
| 1820 | /* SUBROUTINE PRELIM sets the elements of XBASE, XPT, FVAL, GOPT, HQ, PQ, */ |
| 1821 | /* BMAT and ZMAT for the first iteration, and it maintains the values of */ |
| 1822 | /* NF and KOPT. The vector X is also changed by PRELIM. */ |
| 1823 | |
| 1824 | /* Set some constants. */ |