IUMAG

This routine handles MATH/LIBRARY and STAT/LIBRARY type INTEGER options.

Required Arguments

PRODNM — Product name. Use either “MATH” or “STAT.” (Input)

ICHP — Chapter number of the routine that uses the options. (Input)

IACT — 1 if user desires to “get” or read options, or 2 if user desires to “put” or write options. (Input)

NUMOPT — Size of IOPTS. (Input)

IOPTS — Integer array of size NUMOPT containing the option numbers to “get” or “put.” (Input)

IVALS — Integer array containing the option values. These values are arrays corresponding to the individual options in IOPTS in sequential order. The size of IVALS is the sum of the sizes of the individual options. (Input/Output)

FORTRAN 90 Interface

Generic: CALL IUMAG (PRODNM, ICHP, IACT, NUMOPT, IOPTS, IVALS)

Specific: The specific interface name is IUMAG.

FORTRAN 77 Interface

Single: CALL IUMAG (PRODNM, ICHP, IACT, NUMOPT, IOPTS, IVALS)

Description

The Options Manager routine IUMAG reads or writes INTEGER data for some MATH/LIBRARY and STAT/LIBRARY codes. See Atchison and Hanson (1991) for more complete details.

There are MATH/LIBRARY routines in Chapters 1, 2, and 5 that now use IUMAG to communicate optional data from the user.

Comments

1. Users can normally avoid reading about options when first using a routine that calls IUMAG.

2. Let I be any value between 1 and NUMOPT. A negative value of IOPTS(I) refers to option number ‑IOPTS(I) but with a different effect: For a “get” operation, the default values are returned in IVALS. For a “put” operation, the default values replace the current values. In the case of a “put,” entries of IVALS are not allocated by the user and are not used by IUMAG.

3. Both positive and negative values of IOPTS can be used.

4. INTEGER Options

1 If the value is positive, print the next activity for any library routine that uses the Options Manager codes IUMAG, SUMAG, or DUMAG. Each printing step decrements the value if it is positive. Default value is 0.

2 If the value is 2, perform error checking in IUMAG, SUMAG , and DUMAG such as the verifying of valid option numbers and the validity of input data. If the value is 1, do not perform error checking. Default value is 2.

3 This value is used for testing the installation of IUMAG by other IMSL software.
Default value is 3.

Example

The number of iterations allowed for the constrained least squares solver LCLSQ that calls L2LSQ is changed from the default value of max(nra, nca) to the value 6. The default value is restored after the call to LCLSQ. This change has no effect on the solution. It is used only for illustration. The first two arguments required for the call to IUMAG are defined by the product name, “MATH,” and chapter number, 1, where LCLSQ is documented. The argument IACT denotes a write or “put” operation. There is one option to change so NUMOPT has the value 1. The arguments for the option number, 14, and the new value, 6, are defined by reading the documentation for LCLSQ.

 

USE IUMAG_INT

USE LCLSQ_INT

USE UMACH_INT

USE SNRM2_INT

 

IMPLICIT NONE

!

! Solve the following in the least squares sense:

! 3x1 + 2x2 + x3 = 3.3

! 4x1 + 2x2 + x3 = 2.3

! 2x1 + 2x2 + x3 = 1.3

! x1 + x2 + x3 = 1.0

!

! Subject to: x1 + x2 + x3 <= 1

! 0 <= x1 <= .5

! 0 <= x2 <= .5

! 0 <= x3 <= .5

!

! ----------------------------------------------------------------------

! Declaration of variables

!

INTEGER ICHP, IPUT, LDA, LDC, MCON, NCA, NEWMAX, NRA, NUMOPT

PARAMETER (ICHP=1, IPUT=2, MCON=1, NCA=3, NEWMAX=14, NRA=4, &

NUMOPT=1, LDA=NRA, LDC=MCON)

!

INTEGER IOPT(1), IRTYPE(MCON), IVAL(1), NOUT

REAL A(LDA,NCA), B(NRA), BC(MCON), C(LDC,NCA), RES(NRA), &

RESNRM, XLB(NCA), XSOL(NCA), XUB(NCA)

! Data initialization

!

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/

! ----------------------------------------------------------------------

!

! Reset the maximum number of

 

! iterations to use in the solver.

! The value 14 is the option number.

! The value 6 is the new maximum.

IOPT(1) = NEWMAX

IVAL(1) = 6

CALL IUMAG ('math', ICHP, IPUT, NUMOPT, IOPT, IVAL)

! -------------------------------------

! ---------------------------------

!

! Solve the bounded, constrained

! least squares problem.

!

CALL LCLSQ (A, B, C, BC, B, IRTYPE, XLB, XUB, XSOL, RES=RES)

 

! Compute the 2-norm of the residuals.

RESNRM = SNRM2(NRA,RES,1)

! Print results

CALL UMACH (2, NOUT)

WRITE (NOUT,99999) XSOL, RES, RESNRM

! -------------------------------------

! ---------------------------------

! Reset the maximum number of

! iterations to its default value.

! This is not required but is

! recommended programming practice.

IOPT(1) = -IOPT(1)

CALL IUMAG ('math', ICHP, IPUT, NUMOPT, IOPT, IVAL)

! -------------------------------------

! ---------------------------------

!

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)

!

END

Output

 

The solution is 0.5000 0.3000 0.2000

 

The residuals evaluated at the solution are

-1.0000 0.5000 0.5000 0.0000

 

The norm of the residual vector is 1.2247