C----------------------------------------------------------------------- C IMSL Name: SUMAG (Single precision version) C C Purpose: This routine handles MATH/LIBRARY and STAT/LIBRARY C type SINGLE PRECISION options. C C Usage: CALL SUMAG (PRODNM, ICHP, IACT, NUMOPT, IOPTS, SVALS) C C Example 1: C C Solve the following in the least squares sense: C 3x1 + 2x2 + x3 = 3.3 C 4x1 + 2x2 + x3 = 2.3 C 2x1 + 2x2 + x3 = 1.3 C x1 + x2 + x3 = 1.0 C C Subject to: x1 + x2 + x3 <= 1 C 0 <= x1 <= .5 C 0 <= x2 <= .5 C 0 <= x3 <= .5 C C ---------------------------------------------------------------------- C Declaration of variables C INTEGER ICHP, IPUT, LDA, LDC, MCON, NCA, NEWTOL, NRA, NUMOPT PARAMETER (ICHP=1, IPUT=2, MCON=1, NCA=3, NEWTOL=2, NRA=4, & NUMOPT=1, LDA=NRA, LDC=MCON) C INTEGER IOPT(1), IRTYPE(MCON), NOUT REAL A(LDA,NCA), B(NRA), BC(MCON), C(LDC,NCA), RES(NRA), & RESNRM, SNRM2, SVAL(1), XLB(NCA), XSOL(NCA), XUB(NCA) EXTERNAL LCLSQ, SNRM2, SUMAG, UMACH C Data initialization C DATA A/3.0E0, 4.0E0, 2.0E0, 1.0E0, 2.0E0, 2.0E0, 2.0E0, 1.0E0, & 1.0E0, 1.0E0, 1.0E0, 1.0E0/, B/3.3E0, 2.3E0, 1.3E0, 1.0E0/, & C/3*1.0E0/, BC/1.0E0/, IRTYPE/1/, XLB/3*0.0E0/, XUB/3*.5E0/ C ---------------------------------------------------------------------- C C Reset the rank determination C tolerance used in the solver. C The value 2 is the option number. C The value 0.01 is the new tolerance. C IOPT(1) = NEWTOL SVAL(1) = 0.01E+0 CALL SUMAG ('math', ICHP, IPUT, NUMOPT, IOPT, SVAL) C ------------------------------------- C --------------------------------- C C Solve the bounded, constrained C least squares problem. C CALL LCLSQ (NRA, NCA, MCON, A, LDA, B, C, LDC, BC, BC, IRTYPE, & XLB, XUB, XSOL, RES) C Compute the 2-norm of the residuals. RESNRM = SNRM2(NRA,RES,1) C Print results CALL UMACH (2, NOUT) WRITE (NOUT,99999) XSOL, RES, RESNRM C ------------------------------------- C --------------------------------- C Reset the rank determination C tolerance to its default value. C This is not required but is C recommended programming practice. IOPT(1) = -IOPT(1) CALL SUMAG ('math', ICHP, IPUT, NUMOPT, IOPT, SVAL) C ------------------------------------- C --------------------------------- C 99999 FORMAT (' The solution is ', 3F9.4, //, ' The residuals ', & 'evaluated at the solution are ', /, 18X, 4F9.4, //, & ' The norm of the residual vector is ', F8.4) C END C The solution is 0.5000 0.3000 0.2000 C C The residuals evaluated at the solution are C -1.0000 0.5000 0.5000 0.0000 C C The norm of the residual vector is 1.2247