Search Site | Contact Details | FAQ

ADAS Subroutine xxmnmx

      SUBROUTINE XXMNMX( LOGFIT , MAXDEG , TOLVAL ,
     &                   NIN    , XIN    , YIN    ,
     &                   NOUT   , XOUT   , YOUT   ,
     &                   NCOEF  , COEF ,
     &                   MINFO
     &                 )
C-----------------------------------------------------------------------
C
C  ****************** FORTRAN77 SUBROUTINE: XXMNMX *********************
C
C  PURPOSE:           TO EVALUATE THE TAYLOR COEFFICIENTS OF THE MINIMAX
C                     POLYNOMIAL.
C
C                     OUTPUTS 'NOUT' INTERPOLATED COORDINATES  USING THE
C                     MINIMAX EVALUATION, WHICH ARE EVENLY  SPACED ALONG
C                     THE X-AXIS COVERING THE X-VALUE RANGE  INPUT.   IF
C                     REQUIRED THE SPACING WILL BE EVENLY  SPACED  ALONG
C                     THE LOG10 TRANSFORMATION OF THE  X-AXIS  (IN  THIS
C                     CASE THE Y-VALUES ARE SIMILARLY TRANSFORMED).
C
C                     * IMPORTANT: 'NOUT' >= 'NIN' (NO. OF INPUT VALUES)
C
C                     MINFO(CHARACTER*80) ON OUTPUT CONTAINS INFORMATION
C                     REGARDING THE SLOPE OF THE CURVE AT THE BOUNDARIES
C                     OF THE EXPERIMENTAL REGION, AND AN ESTIMATE OF THE
C                     MAXIMUM ERROR IN THE MINIMAX INTERPOLATION.
C
C  CALLING PROGRAMS:  GENERAL USE
C
C  SUBROUTINE:
C
C  INPUT : (L*4)  LOGFIT  = .TRUE.  => PERFORM MINIMAX POLYNOMIAL EVAL-
C                                      UATION ON LOG10 TRANSFORMATIONS
C                                      OF THE INPUT X AND Y DATA.
C                           .FALSE  => PERFORM MINIMAX POLYNOMIAL EVAL-
C                                      UATION ON THE X AND Y VALUES AS
C                                      INPUT.
C  INPUT : (I*4)  MAXDEG  = MAXIMUM   POSSIBLE  DEGREE  OF   POLYNOMIAL
C                           ALLOWED IN THE MINIMAX FITTING (MUST BE< 26)
C                           (IF 'NOUT'<100 => MAX. DEGREES ALLOWED = 22)
C                           NOTE:
C                           'COEF()' MUST HAVE .GE. 'MAXDEG+1' ELEMENTS
C  INPUT : (R*8)  TOLVAL  = PARAMETER = FRACTIONAL TOLERANCE FOR ACCEPT-
C                                       ANCE OF DATA FITTED  BY  MINIMAX
C                                       POLYNOMIAL.  (IF IT EQUALS  ZERO
C                                       THEN RUNS TO MAX. DEGREE).
C
C  INPUT : (I*4)  NIN     = NUMBER OF INPUT KNOTS
C  INPUT : (R*8)  XIN()   = INPUT X-VALUES OF KNOTS
C  INPUT : (R*8)  YIN()   = INPUT Y-VALUES OF KNOTS
C
C  INPUT : (I*4)  NOUT    = NUMBER  OF  OUTPUT  VALUES  REQUIRED  TO  BE
C                           INTERPOLATED USING MINIMAX POLYNOMIAL EVAL-
C                           UATION - SPACED EVENLY BETWEEN THE MINIMUM
C                           AND MAXIMUM VALUES OF THE (TRANSFORMED) X-
C                           VALUES INPUT.
C  OUTPUT: (R*8)  XOUT()  = INITIALLY: ORDERED/(TRANSFORMED) 'XIN()'
C                                      (ASCENDING ORDER).
C                                      'NIN' VALUES
C                           OUTPUT   : X-VALUES FOR WHICH INTERPOLATION
C                                      IS CARRIED OUT.
C                                      'NOUT' VALUES
C  OUTPUT: (R*8)  YOUT()  = INITIALLY: ORDERED/(TRANSFORMED) 'YIN()'
C                                      (ORDERED ACCORDING TO 'XOUT()').
C                                      'NIN' VALUES
C                           OUTPUT   : INTERPOLATED Y-VALUES FOR THE
C                                      X-VALUES ('XOUT()' - OUTPUT)
C                                      'NOUT' VALUES
C
C  OUTPUT: (I*4)  NCOEF   = NUMBER OF MINIMAX FIT COEFFICIENTS
C  OUTPUT: (R*8)  COEF()  = MINIMAX COEFFICIENTS - ARRAY SIZE: MAXDEG+1
C
C  OUTPUT: (C*80) MINFO   = DIAGNOSTIC INFORMATION STRING
C
C          (I*4)  MAXOUT  = PARAMETER = MAXIMUM NUMBER OF OUTPUT X,Y CO-
C                                       ORDINATES THAT CAN BE INTERPOLA-
C                                       TED.
C          (I*4)  MAXTOL  = PARAMETER = POWER OF 10 WHICH REPRESENTS THE
C                                       MAXIMUM FRACTIONAL DIFFERENCE
C                                       ALLOWED BETWEEN ACTUAL (YDATA)
C                                       AND FITTED (YFIT) DATA.
C          (I*4)  MINTOL  = PARAMETER = POWER OF 10 WHICH REPRESENTS THE
C                                       MINIMUM FRACTIONAL DIFFERENCE
C                                       ALLOWED BETWEEN ACTUAL (YDATA)
C                                       AND FITTED (YFIT) DATA.
C
C          (I*4)  I4UNIT  = FUNCTION (SEE ROUTINE SECTION BELOW)
C          (I*4)  ILIMIT  = UPPER LIMIT  OF  THE  NUMBER  OF  DEGREES
C                           ALLOWED FOR MINIMAX POLYNOMIAL EVALUATION.
C          (I*4)  IDEG    = NUMBER OF DEGREES BEING USED FOR MINIMAX
C                           POLYNOMIAL EVALUATION.
C          (I*4)  NDEG    = NUMBER OF DEGREES FOR ACCEPTED MINIMAX FIT.
C          (I*4)  I1      = GENERAL ARRAY INDEX
C          (I*4)  I2      = GENERAL ARRAY INDEX
C
C          (R*8)  XMIN    = MINIMUM (TRANSFORMED) X-VALUE INPUT
C          (R*8)  XMAX    = MAXIMUM (TRANSFORMED) X-VALUE INPUT
C          (R*8)  REF     = OUTPUT FROM 'XXCHEB' = NEGATIVE IF MINIMAX
C                           FITTING PROCEDURE IS CYCLING.
C          (R*8)  SUM     = USED TO SUM UP POLYNOMIAL TERMS WHEN CALCUL-
C                           ATING VALUE OF 'Y' AT GIVEN 'X'.
C          (R*8)  YFIT    = FITTED Y-VALUE USING MINIMAX POLYNOMIAL
C          (R*8)  YDATA   = INPUT Y-VALUE FOR COMPARISON TO FITTED VALUE
C          (R*8)  DIFF    = FRACTIONAL DIFFERENCE BETWEEN ACTUAL (YDATA)
C                           AND  FITTED  (YFIT)  Y-VALUE   FROM  MINIMAX
C                           POLYNOMIAL FITTED.
C          (R*8)  BIG     = LARGEST FRACTIONAL ERROR BETWEEN ACTUAL AND
C                           FITTED Y-VALUES FOR POLYNOMIAL EVALUATION.
C          (R*8)  GRADL   = GRADIENT OF FITTED MINIMAX POLYNOMIAL CURVE
C                           AT LOWER BOUNDARY OF INPUT DATA.
C          (R*8)  GRADU   = GRADIENT OF FITTED MINIMAX POLYNOMIAL CURVE
C                           AT UPPER BOUNDARY OF INPUT DATA.
C          (R*8)  XSTEP   = SEPERATION   OF   OUTPUT  X-VALUES  TO   BE
C                           INTERPOLATED.
C          (R*8)  XVAL    = X-VALUES AT WHICH INTERPOLATION IS TAKING
C                           PLACE.
C
C          (C*6)  CFTYPE  = 'LOGFIT' IF 'LOGFIT=.TRUE.'
C                           'LINFIT' IF 'LOGFIT=.FALSE.'
C
C          (L*4)  LMFIT   = .TRUE.  => MINIMAX POLYNIOMIAL FOUND WHICH
C                                      IS WITHIN DESIRED TOLERANCE.
C                                      (SEE 'TOLVAL')
C                           .FALSE. => NO MINIMAX POLYNIOMIAL FOUND WITH
C                                      DESIRED TOLERANCE.
C                                      (SEE 'TOLVAL')
C
C          (I*4)  INDX()  = ASCENDING ORDER INDEX FOR INPUT X-VALUES
C
C          (R*8)  WRK()   = WORKING SPACE FOR ORDERING DATA
C
C
C NOTES:
C          THIS SUBROUTINE IS AN AMMENDED AND STRUCTURED VERSION OF  THE
C          SUBROUTINE  'MINIMAX'  WRITTEN BY  STEPHEN TURNER,  JET  30TH
C          JULY 1989. IT NO LONGER ORDERS THE INPUT COORDINATES DIRECTLY
C          BUT COPIES THE TO A SECOND ARRAY AND ORDERS THEM.   THEREFORE
C          IF THE INPUT COORDINATES ARE REQUIRED TO BE ORDERED THIS MUST
C          BE CARRIED OUT EXPLICITLY IN THE CALLING OPROGRAM/ROUTINE.
C          THE SUBROUTINE NO LONGERS REQUIRES THE INPUT CO-ORDINATES  IN
C          LOG10 FORM, THIS TRANSFORMATION CAN BE CARRIED OUT EXPLICITLY
C          BY THE SUBROUTINE.   THE  ROUTINE HAS BEEN WRITTEN TO  BE  OF
C          GENERAL RATHER THAN SPECIFIC USE.
C
C          IN THE ORIGINAL 'MINIMAX' SUBROUTINE THE MINIMUM NUMBER OF
C          DEGREES ACCEPTED FOR A FIT WAS 2, IN 'XXMNMX' IT IS 1.
C
C ROUTINES:
C          ROUTINE    SOURCE    BRIEF DESCRIPTION
C          ------------------------------------------------------------
C          I4UNIT     ADAS      FETCH UNIT NUMBER FOR OUTPUT OF MESSAGES
C          XXINDX     ADAS     GIVES INDICES OF SORTED ARRAY (ASCENDNG)
C          XXISRT     ADAS     RE-ORDERS ARRAY ACCORDING TO 'XXINDX'
C          XXCHEB     ADAS     MINIMAX POLYNOMIAL COEFT. EVALUATION
C
C AUTHOR:   PAUL E. BRIDEN (TESSELLA SUPPORT SERVICES PLC)
C           K1/0/81
C           JET EXT. 4569
C
C DATE:     12/10/90
C
C UPDATE:  23/04/93 - PE BRIDEN - ADAS91: ADDED I4UNIT FUNCTION TO WRITE
C                                         STATEMENTS FOR SCREEN MESSAGES
C
C UPDATE:  24/05/93 - PE BRIDEN - ADAS91: CHANGED I4UNIT(0)-> I4UNIT(-1)
C
C UPDATE:  14/02/94 - PE BRIDEN - ADAS91: CORRECTED BUG WHEN CHECKING
C                                         TOLERANCE FOR LOGFIT - CHANGED
C                                         THE LINE:
C                                                  YDATA = YIN(I1)
C                                         TO:
C                                                  YDATA = YIN(INDX(I1))
C                                         (WOULD CAUSE PROBLEMS IF YIN
C                                          NOT ORDERED ON INPUT.)
C
C UPDATE:  14/02/94 - PE BRIDEN - ADAS91: RECODED SECTION USE TO TEST
C                                         TOLERANCE VALUE - NOW CHECKS
C                                         FOR DIVISION BY 0 AND USES
C                                         LOG10 TO STORES VALUES THUS
C                                         AVOIDING OVERFLOWS.
C                                         (BIG IS NOW STORED AS LOG10
C                                          VALUES INITIALLY)
C                                         INTRODUCED: MAXTOL & MINTOL
C                                                 - / -
C                                         STOP EXECUTING XXCHEB IF
C                                         CYCLING (CHECK REF VARIABLE)
C                                                 - / -
C                                         INITIALISED NDEG AND BIG TO
C                                         STOP ICA WARNING.
C
C UPDATE:  31/10/94 - PE BRIDEN - ADAS91: REPLACED CALL TO NAG ROUTINE
C                                         E02ACF WITH A CALL TO THE NEW
C                                         EQUIVALENT ADAS ROUTINE CALLED
C                                         XXCHEB (IDENTICAL ARGUMENTS).
C UPDATE:  17/1/95 - L JALOTA - IDL-ADAS : MODIFIED ERROR CHECKING 
C					   SECTION TO WRITE TO UNIT 0
C					   NOT STDOUT WHICH INTERFERES
C					   WITH PIPE COMMUNICATIONS.
C       :   6/3/95 - L JALOTA - IDL-ADAS : REPLACED CALL TO I4UNIT.
C
C UNIX-IDL PORT:
C
C VERSION: 1.2                          DATE: 10-11-95
C MODIFIED: TIM HAMMOND (TESSELLA SUPPORT SERVICES PLC)
C               - INCREASED PARAMETER MAXOUT FROM 100 TO 120
C                 PRIMARILY TO PREVENT PROBLEMS WITH ADAS 506 WHERE
C                 101 POINTS ARE REQUIRED.
C
C VERSION  : 1.3                          
C DATE     : 10-04-2007
C MODIFIED : Allan Whiteford
C               - Modified documentation as part of automated
C		  subroutine documentation preparation.
C
C----------------------------------------------------------------------
C
C----------------------------------------------------------------------
      CHARACTER*80        MINFO
      INTEGER             MAXDEG,      NCOEF,       NIN,         NOUT
      LOGICAL             LOGFIT
      REAL*8              COEF(MAXDEG+1),           TOLVAL
      REAL*8              XIN(NIN),    XOUT(NOUT),  YIN(NIN)
      REAL*8              YOUT(NOUT)
© Copyright 1995-2024 The ADAS Project
Comments and questions to: adas-at-adas.ac.uk