clpmn Subroutine

public subroutine clpmn(mm, m, n, x, y, ntype, Cpm, Cpd)

Compute the associated Legendre functions Pmn(z) and their derivatives Pmn'(z) for a complex argument

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: mm

Physical dimension of CPM and CPD

integer, intent(in) :: m

Order of Pmn(z), m = 0,1,2,...,n

integer, intent(in) :: n

Degree of Pmn(z), n = 0,1,2,...,N

real(kind=wp), intent(in) :: x

Real part of z

real(kind=wp), intent(in) :: y

Imaginary part of z

integer, intent(in) :: ntype

type of cut, either 2 or 3

complex(kind=wp), intent(out) :: Cpm(0:Mm,0:n)

Pmn(z)

complex(kind=wp), intent(out) :: Cpd(0:Mm,0:n)

Pmn'(z)


Calls

proc~~clpmn~~CallsGraph proc~clpmn specfun_module::clpmn proc~dinf specfun_module::dinf proc~clpmn->proc~dinf

Source Code

   subroutine clpmn(Mm,m,n,x,y,Ntype,Cpm,Cpd)

      integer,intent(in) :: mm !! Physical dimension of CPM and CPD
      integer,intent(in) :: m !! Order of Pmn(z),  m = 0,1,2,...,n
      integer,intent(in) :: n !! Degree of Pmn(z), n = 0,1,2,...,N
      real(wp),intent(in) :: x !! Real part of z
      real(wp),intent(in) :: y !! Imaginary part of z
      integer,intent(in) :: ntype !! type of cut, either 2 or 3
      complex(wp),intent(out) :: Cpm(0:Mm,0:n)  !! Pmn(z)
      complex(wp),intent(out) :: Cpd(0:Mm,0:n)  !! Pmn'(z)

      integer :: i , j , ls
      complex(wp) :: z , zq , zs

      z = cmplx(x,y,wp)
      do i = 0 , n
         do j = 0 , m
            Cpm(j,i) = (0.0_wp,0.0_wp)
            Cpd(j,i) = (0.0_wp,0.0_wp)
         enddo
      enddo
      Cpm(0,0) = (1.0_wp,0.0_wp)
      if ( n==0 ) return
      if ( abs(x)==1.0_wp .and. y==0.0_wp ) then
         do i = 1 , n
            Cpm(0,i) = x**i
            Cpd(0,i) = 0.5_wp*i*(i+1)*x**(i+1)
         enddo
         do j = 1 , n
            do i = 1 , m
               if ( i==1 ) then
                  Cpd(i,j) = dinf()
               elseif ( i==2 ) then
                  Cpd(i,j) = -0.25_wp*(j+2)*(j+1)*j*(j-1)*x**(j+1)
               endif
            enddo
         enddo
         return
      endif
      if ( Ntype==2 ) then
         ! sqrt(1 - z^2) with branch cut on |x|>1
         zs = (1.0_wp-z*z)
         zq = -sqrt(zs)
         ls = -1
      else
         ! sqrt(z^2 - 1) with branch cut between [-1, 1]
         zs = (z*z-1.0_wp)
         zq = sqrt(zs)
         if ( x<0.0_wp ) zq = -zq
         ls = 1
      endif
      do i = 1 , m
         ! DLMF 14.7.15
         Cpm(i,i) = (2.0_wp*i-1.0_wp)*zq*Cpm(i-1,i-1)
      enddo
      do i = 0 , min(m,n-1)
         ! DLMF 14.10.7
         Cpm(i,i+1) = (2.0_wp*i+1.0_wp)*z*Cpm(i,i)
      enddo
      do i = 0 , m
         do j = i + 2 , n
            ! DLMF 14.10.3
            Cpm(i,j) = ((2.0_wp*j-1.0_wp)*z*Cpm(i,j-1)-(i+j-1.0_wp) &
                       *Cpm(i,j-2))/(j-i)
         enddo
      enddo
      Cpd(0,0) = (0.0_wp,0.0_wp)
      do j = 1 , n
         ! DLMF 14.10.5
         Cpd(0,j) = ls*j*(z*Cpm(0,j)-Cpm(0,j-1))/zs
      enddo
      do i = 1 , m
         do j = i , n
            ! derivative of DLMF 14.7.11 & DLMF 14.10.6 for type 3
            ! derivative of DLMF 14.7.8 & DLMF 14.10.1 for type 2
            Cpd(i,j) = ls*(-i*z*Cpm(i,j)/zs+(j+i)*(j-i+1.0_wp) &
                       /zq*Cpm(i-1,j))
         enddo
      enddo
   end subroutine clpmn