/*Translated by FOR_C, v3.4.2 (-), on 07/09/115 at 08:33:16 */ /*FOR_C Options SET: ftn=u io=c no=p op=aimnv pf=,p_sfmin s=dbov str=l x=f - prototypes */ #include #include "fcrt.h" #include #include #include "p_sfmin.h" /* program DRSFMIN *>> 1996-05-28 DRSFMIN Krogh Moved format up. *>> 1994-10-19 DRSFMIN Krogh Changes to use M77CON *>> 1994-07-15 DRSFMIN CLL *>> 1993-03-01 CLL Changed "zero" to "minimum". *>> 1992-03-24 CLL Added missing comma in format statement. *>> 1987-12-09 DRSFMIN Lawson Initial Code. * Demo driver for SFMIN. Finds minimum of a univariate function. * C. L. Lawson & S. Y. Chiu, JPL, Aug 1987, Oct 1987 * F. T. Krogh, Oct. 1987. * ------------------------------------------------------------------ *--S replaces "?": DR?FMIN, ?FMIN * ------------------------------------------------------------------ */ /* PARAMETER translations */ #define A (-1.0e0) #define B 1.0e0 #define TWO 2.0e0 #define XTOL 1.0e-7 /* end of PARAMETER translations */ int main( ) { long int mode; float tol, x, xorf; /* ------------------------------------------------------------------ */ printf(" DRSFMIN.. Demo driver for SFMIN, univariate minimum finder.\n " "Problem: Find minimum of 2**X + 2**(-2*X).\n Exact result: X = 1/3\n " "Min value: 1.5 * 2**(1/3) = 1.88988157...\n"); x = A; xorf = B; tol = XTOL; mode = 0; L_10: sfmin( &x, &xorf, &mode, tol ); if (mode != 1) goto L_20; xorf = powf(TWO,x) + powf(TWO,-TWO*x); goto L_10; L_20: ; printf(" Results returned by SFMIN:\n MODE = %3ld\n Solution: X = %16.8f\n f(X) = %16.8f\n", mode, x, xorf); exit(0); } /* end of function */