Generated by TAPENADE

    !        Generated by TAPENADE     (INRIA, Tropics team)
    !  Tapenade 3.4 (r3375) - 10 Feb 2010 15:08
    !
    !  Differentiation of loggausspdf in forward (tangent) mode: (multi-directional mode)
    !   variations   of useful results: res
    !   with respect to varying inputs: pars
    ! pars(1) = mu_x
    ! pars(2) = mu_y
    ! pars(3) = sigma_x
    ! pars(4) = sigma_y
    ! pars(5) = rho
    SUBROUTINE LOGGAUSSPDF_DV_CD(n, x, y, pars, parsd, res, resd, nbdirs)
      USE DIFFSIZES_DV
      IMPLICIT NONE
      REAL*8, PARAMETER :: twopi=6.283185307179586e+00_8
      INTEGER, INTENT(IN) :: n
      REAL*8, DIMENSION(n), INTENT(IN) :: x
      REAL*8, DIMENSION(n), INTENT(IN) :: y
      REAL*8, DIMENSION(5), INTENT(IN) :: pars
      REAL*8, DIMENSION(nbdirsmax, 5), INTENT(IN) :: parsd
      REAL*8, DIMENSION(n), INTENT(OUT) :: res
      REAL*8, DIMENSION(nbdirsmax, n), INTENT(OUT) :: resd
      REAL*8, DIMENSION(n) :: cen1, cen2
      REAL*8, DIMENSION(nbdirsmax, n) :: cen1d, cen2d
      REAL*8 :: t1, f1, f2, f12
      REAL*8, DIMENSION(nbdirsmax) :: t1d, f1d, f2d, f12d
      REAL*8 :: arg1
      REAL*8, DIMENSION(nbdirsmax) :: arg1d
      REAL*8 :: result1
      REAL*8, DIMENSION(nbdirsmax) :: result1d
      REAL*8 :: arg2
      REAL*8, DIMENSION(nbdirsmax) :: arg2d
      INTEGER :: nd
      INTEGER :: nbdirs
      INTRINSIC LOG
      INTRINSIC SQRT
      REAL*8 :: result10
      t1 = -(0.5_8/(1.0_8-pars(5)**2))
      f1 = t1/pars(3)**2
      f2 = t1/pars(4)**2
      f12 = -(2.0*pars(5)*t1/(pars(3)*pars(4)))
      cen1 = x - pars(1)
      cen2 = y - pars(2)
      arg1 = 1.0_8 - pars(5)**2
      result1 = SQRT(arg1)
      arg2 = twopi*pars(3)*pars(4)*result1
      DO nd=1,nbdirs
        t1d(nd) = (-(0.5_8*2*pars(5)*parsd(nd, 5)))/(1.0_8-pars(5)**2)**2
        f1d(nd) = (t1d(nd)*pars(3)**2-t1*2*pars(3)*parsd(nd, 3))/(pars(3)**2&
    &      )**2
        f2d(nd) = (t1d(nd)*pars(4)**2-t1*2*pars(4)*parsd(nd, 4))/(pars(4)**2&
    &      )**2
        f12d(nd) = -((2.0*(parsd(nd, 5)*t1+pars(5)*t1d(nd))*pars(3)*pars(4)-&
    &      2.0*pars(5)*t1*(parsd(nd, 3)*pars(4)+pars(3)*parsd(nd, 4)))/(pars(&
    &      3)*pars(4))**2)
        cen1d(nd, :) = -parsd(nd, 1)
        cen2d(nd, :) = -parsd(nd, 2)
        arg1d(nd) = -(2*pars(5)*parsd(nd, 5))
        IF (arg1 .EQ. 0.0) THEN
          result1d(nd) = 0.0
        ELSE
          result10 = SQRT(arg1)
          result1d(nd) = arg1d(nd)/(2.0*result10)
        END IF
        arg2d(nd) = twopi*((parsd(nd, 3)*result1+pars(3)*result1d(nd))*pars(&
    &      4)+pars(3)*result1*parsd(nd, 4))
        resd(nd, :) = f1d(nd)*cen1**2 - arg2d(nd)/arg2 + f1*2*cen1*cen1d(nd&
    &      , :) + f2d(nd)*cen2**2 + f2*2*cen2*cen2d(nd, :) + (f12d(nd)*cen1+&
    &      f12*cen1d(nd, :))*cen2 + f12*cen1*cen2d(nd, :)
      END DO
      res = -LOG(arg2) + f1*cen1**2 + f2*cen2**2 + f12*cen1*cen2
    END SUBROUTINE LOGGAUSSPDF_DV_CD