OpenLibm/slatec/inits.f
Viral B. Shah c977aa998f Add Makefile.extras to build libopenlibm-extras.
Replace amos with slatec
2012-12-31 16:37:05 -05:00

53 lines
1.8 KiB
Fortran

*DECK INITS
FUNCTION INITS (OS, NOS, ETA)
C***BEGIN PROLOGUE INITS
C***PURPOSE Determine the number of terms needed in an orthogonal
C polynomial series so that it meets a specified accuracy.
C***LIBRARY SLATEC (FNLIB)
C***CATEGORY C3A2
C***TYPE SINGLE PRECISION (INITS-S, INITDS-D)
C***KEYWORDS CHEBYSHEV, FNLIB, INITIALIZE, ORTHOGONAL POLYNOMIAL,
C ORTHOGONAL SERIES, SPECIAL FUNCTIONS
C***AUTHOR Fullerton, W., (LANL)
C***DESCRIPTION
C
C Initialize the orthogonal series, represented by the array OS, so
C that INITS is the number of terms needed to insure the error is no
C larger than ETA. Ordinarily, ETA will be chosen to be one-tenth
C machine precision.
C
C Input Arguments --
C OS single precision array of NOS coefficients in an orthogonal
C series.
C NOS number of coefficients in OS.
C ETA single precision scalar containing requested accuracy of
C series.
C
C***REFERENCES (NONE)
C***ROUTINES CALLED XERMSG
C***REVISION HISTORY (YYMMDD)
C 770401 DATE WRITTEN
C 890831 Modified array declarations. (WRB)
C 891115 Modified error message. (WRB)
C 891115 REVISION DATE from Version 3.2
C 891214 Prologue converted to Version 4.0 format. (BAB)
C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
C***END PROLOGUE INITS
REAL OS(*)
C***FIRST EXECUTABLE STATEMENT INITS
IF (NOS .LT. 1) CALL XERMSG ('SLATEC', 'INITS',
+ 'Number of coefficients is less than 1', 2, 1)
C
ERR = 0.
DO 10 II = 1,NOS
I = NOS + 1 - II
ERR = ERR + ABS(OS(I))
IF (ERR.GT.ETA) GO TO 20
10 CONTINUE
C
20 IF (I .EQ. NOS) CALL XERMSG ('SLATEC', 'INITS',
+ 'Chebyshev series too short for specified accuracy', 1, 1)
INITS = I
C
RETURN
END