1C> \ingroup nwad_tests 2C> @{ 3C> 4C> \brief test the implementation printing of the TAN function 5C> 6C> This is an NWAD unit test for the multivariate implementation. 7C> The derivatives of TAN function are compared 8C> against analytic derivatives. The function is 3-dimensional as that is 9C> sufficient for this test. The input data set is randomly generated. 10C> 11 program test_tan_p3 12 use nwadp1 13 implicit none 14 integer :: npt, i, mmvar 15 integer :: i1, i2, i3 16 integer :: ix, ix2, ix3 17 parameter (mmvar = 3) 18 parameter (npt = 1) 19 integer :: iv(mmvar) 20 integer :: numvar 21 type(nwad_dble) :: x, y, z, f 22 double precision fa,dfa(mmvar),dfa2(mmvar*(mmvar+1)/2) 23 double precision dfa3(mmvar*(mmvar+1)*(mmvar+2)/6), tol 24 double precision tmp(3), tf, df 25 parameter( tol = 1.0d-10) 26 call random_seed 27 open(UNIT=60,FILE="test_tan_p3.txt") 28 call set_unitno(60) 29 do i = 1, npt 30 call random_number(tmp) 31 tmp = tmp*2.0d0*acos(-1.0d0) 32 x = set_gamma_aa(tmp(1)) 33 y = set_gamma_ab(tmp(2)) 34 z = set_gamma_bb(tmp(3)) 35 call submaxima_tan_p3(x%d0,y%d0,z%d0,fa,dfa) 36 call subad_tan_p3(x,y,z,f) 37 if (abs((fa-f%d0)/(fa+f%d0)).gt.tol) then 38 write(*,*)"F : fail:",i,x%d0,y%d0,z%d0,fa 39 write(*,*)"F : fail:",i,x%d0,y%d0,z%d0,f%d0 40 write(*,*) 41 endif 42 numvar = get_nvar(f) 43 do i1 = 1, numvar 44 call get_d1(f,i1,tf,iv(i1)) 45 if (abs((dfa(i1)-tf)/(dfa(i1)+tf)).gt.tol) then 46 write(*,10)i,i1,x%d0,y%d0,z%d0,dfa(i) 47 write(*,10)i,i1,x%d0,y%d0,z%d0,tf 48 write(*,*) 49 endif 50 enddo 51 enddo 52 10 format("DF : fail:",i4, i2,3e10.3,e18.10) 53 end 54C> 55C> \brief The test routine 56C> 57 subroutine subad_tan_p3(x,y,z,f) 58 use nwadp1 59 implicit none 60 type(nwad_dble) :: x, y, z, t, f 61 t = 1.57d0 * sin(x) * sin(y) * sin(z) 62 f = tan(t) 63 end 64C> @} 65c $Id: test_add.F 26056 2014-08-26 19:03:07Z d3y133 $ 66