Skip to main content

ChebyshevFirst1D example 4

This example shows the usage of [[ChebyshevFirst1D_]] class. We test EvalGradient in this routine. the argument of EvalGradient is scalar in this routine.

Modules and classes

  • [[ChebyshevFirst1D_]]

Usage

PROGRAM main
use easifemBase
use easifemClasses
implicit none
type(ChebyshevFirst1D_) :: obj
type(String) :: astr
integer(i4b) :: ii, n
real( dfp ) :: x, yexact, y
real( dfp ), parameter :: tol=1.0E-10

n=1

  x = RAND()
yexact = 1
n=1
obj = ChebyshevFirst1D(varname="x", n=n)
y = obj%EvalGradient( x )
call OK( SOFTEQ( y, yexact, tol ), "test-1:" )

n=2

  x = RAND()
yexact = 4.0*x
n=2
obj = ChebyshevFirst1D(varname="x", n=n)
y = obj%EvalGradient( x )
call OK( SOFTEQ( y, yexact, tol ), "test-2:" )

n=3

  x = RAND()
yexact = 12.0*x**2 - 3.0
n=3
obj = ChebyshevFirst1D(varname="x", n=n)
y = obj%EvalGradient( x )
call OK( SOFTEQ( y, yexact, tol ), "test-3:" )

n=4

  x = RAND()
yexact = 32.0*x**3 - 16.0*x
n=4
obj = ChebyshevFirst1D(varname="x", n=n)
y = obj%EvalGradient( x )
call OK( SOFTEQ( y, yexact, tol ), "test-4:" )
END PROGRAM main