GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
csevl.f
Go to the documentation of this file.
1 *DECK CSEVL
2  FUNCTION csevl (X, CS, N)
3 C***BEGIN PROLOGUE CSEVL
4 C***PURPOSE Evaluate a Chebyshev series.
5 C***LIBRARY SLATEC (FNLIB)
6 C***CATEGORY C3A2
7 C***TYPE SINGLE PRECISION (CSEVL-S, DCSEVL-D)
8 C***KEYWORDS CHEBYSHEV SERIES, FNLIB, SPECIAL FUNCTIONS
9 C***AUTHOR Fullerton, W., (LANL)
10 C***DESCRIPTION
11 C
12 C Evaluate the N-term Chebyshev series CS at X. Adapted from
13 C a method presented in the paper by Broucke referenced below.
14 C
15 C Input Arguments --
16 C X value at which the series is to be evaluated.
17 C CS array of N terms of a Chebyshev series. In evaluating
18 C CS, only half the first coefficient is summed.
19 C N number of terms in array CS.
20 C
21 C***REFERENCES R. Broucke, Ten subroutines for the manipulation of
22 C Chebyshev series, Algorithm 446, Communications of
23 C the A.C.M. 16, (1973) pp. 254-256.
24 C L. Fox and I. B. Parker, Chebyshev Polynomials in
25 C Numerical Analysis, Oxford University Press, 1968,
26 C page 56.
27 C***ROUTINES CALLED R1MACH, XERMSG
28 C***REVISION HISTORY (YYMMDD)
29 C 770401 DATE WRITTEN
30 C 890831 Modified array declarations. (WRB)
31 C 890831 REVISION DATE from Version 3.2
32 C 891214 Prologue converted to Version 4.0 format. (BAB)
33 C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
34 C 900329 Prologued revised extensively and code rewritten to allow
35 C X to be slightly outside interval (-1,+1). (WRB)
36 C 920501 Reformatted the REFERENCES section. (WRB)
37 C***END PROLOGUE CSEVL
38  REAL b0, b1, b2, cs(*), onepl, twox, x
39  LOGICAL first
40  SAVE first, onepl
41  DATA first /.true./
42 C***FIRST EXECUTABLE STATEMENT CSEVL
43  IF (first) onepl = 1.0e0 + r1mach(4)
44  first = .false.
45  IF (n .LT. 1) CALL xermsg ('SLATEC', 'CSEVL',
46  + .LE.'NUMBER OF TERMS 0', 2, 2)
47  IF (n .GT. 1000) CALL xermsg ('SLATEC', 'CSEVL',
48  + .GT.'NUMBER OF TERMS 1000', 3, 2)
49  IF (abs(x) .GT. onepl) CALL xermsg ('SLATEC', 'CSEVL',
50  + 'X OUTSIDE THE INTERVAL (-1,+1)', 1, 1)
51 C
52  b1 = 0.0e0
53  b0 = 0.0e0
54  twox = 2.0*x
55  DO 10 i = 1,n
56  b2 = b1
57  b1 = b0
58  ni = n + 1 - i
59  b0 = twox*b1 - b2 + cs(ni)
60  10 CONTINUE
61 C
62  csevl = 0.5e0*(b0-b2)
63 C
64  RETURN
65  END
function csevl(X, CS, N)
Definition: csevl.f:3
real function r1mach(i)
Definition: r1mach.f:23
subroutine xermsg(LIBRAR, SUBROU, MESSG, NERR, LEVEL)
Definition: xermsg.f:3