Chebyshev1EvalSum
Evaluate the finite sum of Chebyshev1 polynomials at point x.
Interface 1
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION Chebyshev1EvalSum(n, x, coeff) &
& RESULT(ans)
INTEGER(I4B), INTENT(IN) :: n
!! order of polynomial
REAL(DFP), INTENT(IN) :: x
!! point
REAL(DFP), INTENT(IN) :: coeff(0:n)
!! Coefficient of finite sum, size = n+1
REAL(DFP) :: ans
!! Evaluate Chebyshev1 polynomial of order n at point x
END FUNCTION Chebyshev1EvalSum
END INTERFACE
program main
use easifembase
implicit none
integer( i4b ) :: n
real( dfp ), allocatable :: ans(:), x(:), exact(:), &
& coeff(:)
real( dfp ), parameter :: tol=1.0E-10
type(string) :: astr
n = 3
x = [-0.5, 0.5, 0.25]
coeff = [1, 0, 0, 0]
ans = Chebyshev1EvalSum( n=n, x=x, coeff=coeff )
exact = Chebyshev1Eval( n=0_I4B, x=x )
call ok( ALL(SOFTEQ(ans, exact, tol )))
n = 3
x = [-0.5, 0.5, 0.25]
coeff = [0, 0, 0, 1]
ans = Chebyshev1EvalSum( n=n, x=x, coeff=coeff )
exact = Chebyshev1Eval( n=3_I4B, x=x)
call ok( ALL(SOFTEQ(ans, exact, tol )))
n = 100
x = [-0.5, 0.5, 0.25]
coeff = zeros(n+1, 0.0_DFP)
coeff( n+1 ) = 1.0_DFP
ans = Chebyshev1EvalSum( n=n, x=x, coeff=coeff )
exact = Chebyshev1Eval( n=n, x=x )
call ok( ALL(SOFTEQ(ans, exact, tol )))
end program main
Interface 2
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION Chebyshev1EvalSum(n, x, coeff) RESULT(ans)
INTEGER(I4B), INTENT(IN) :: n
!! order of polynomial
REAL(DFP), INTENT(IN) :: x(:)
!! point
REAL(DFP), INTENT(IN) :: coeff(0:n)
!! Coefficient of finite sum, size = n+1
REAL(DFP) :: ans(SIZE(x))
!! Evaluate Chebyshev1 polynomial of order n at point x
END FUNCTION Chebyshev1EvalSum
END INTERFACE
See above example.