Chebyshev1Eval
Evaluate Chebyshev1 polynomials of order n at single or several points.
Interface 1
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION Chebyshev1Eval(n, x) RESULT(ans)
INTEGER(I4B), INTENT(IN) :: n
!! order of polynomial
REAL(DFP), INTENT(IN) :: x
!! point of evaluation, it should be between -1 and 1
REAL(DFP) :: ans
!! Evaluate Chebyshev1 polynomial of order n at point x
END FUNCTION Chebyshev1Eval
END INTERFACE
program main
use easifembase
implicit none
integer( i4b ) :: n
real( dfp ) :: ans, x, exact
real( dfp ), parameter :: tol=1.0E-10
n = 5
x = -1.0_DFP; call callme
exact = 16.0_DFP * x**5 - 20.0_DFP * x**3 + 5.0_DFP * x
call ok( SOFTEQ(ans, exact, tol ))
x = 0.0_DFP; call callme
exact = 16.0_DFP * x**5 - 20.0_DFP * x**3 + 5.0_DFP * x
call ok( SOFTEQ(ans, exact, tol ))
x = +1.0_DFP; call callme
exact = 16.0_DFP * x**5 - 20.0_DFP * x**3 + 5.0_DFP * x
call ok( SOFTEQ(ans, exact, tol ))
contains
subroutine callme
ans= Chebyshev1Eval( n=n, x=x )
end subroutine callme
end program main
Interface 2
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE FUNCTION Chebyshev1Eval(n, x) RESULT(ans)
INTEGER(I4B), INTENT(IN) :: n
!! order of polynomial
REAL(DFP), INTENT(IN) :: x(:)
!! several points of evaluation
REAL(DFP) :: ans(SIZE(x))
!! Evaluate Chebyshev1 polynomial of order n at points x
END FUNCTION Chebyshev1Eval
END INTERFACE
program main
use easifembase
implicit none
integer( i4b ) :: n
real( dfp ), allocatable :: ans(:), x(:), exact(:)
real( dfp ), parameter :: tol=1.0E-10
type(string) :: astr
n = 5
x = [-1.0, -0.5, 0.0, 0.5, 1.0]; call callme
exact = 16.0_DFP * x**5 - 20.0_DFP * x**3 + 5.0_DFP * x
call ok( ALL(SOFTEQ(ans, exact, tol )))
contains
subroutine callme
ans= Chebyshev1Eval( n=n, x=x )
end subroutine callme
end program main