Legenders polynomial [message #80370] |
Mon, 11 June 2012 12:06 |
Baro
Messages: 19 Registered: May 2012
|
Junior Member |
|
|
Dear All,
I was trying to compute the legender function. I wrote the code as shown below. But it is not working right. could you help. Thank you in advance
-------------------------------------------------------
PRO legenders_function,theta,lmax
;Give the IDL compiler information that changes some of the default rules
COMPILE_OPT idl2, HIDDEN
; Error handling.
; CATCH, theError
; IF theError NE 0 THEN BEGIN
; Catch, /CANCEL
; void = ERROR_MESSAGE()
; RETURN
; ENDIF
;declare global variables
COMMON MYGLOBAL,alm,blm
;set maximum degree,i.e lmax
lmax = 60
;initialization legenders function factors
m = fltarr(lmax+1)
l = fltarr(lmax+1)
X = replicate(0.0,lmax+1, lmax+1)
alm = replicate(0.0,lmax+1, lmax+1)
blm = replicate(0.0,lmax+1, lmax+1)
alm[2,2] = sqrt(3)
;compute the legenders function factors
IF size(alm[*,0],/dimensions)LT lmax+1 THEN BEGIN
FOR l=2,lmax-1 DO BEGIN
alm[l+1,l+1] = sqrt((2.0*l+1.0)/(2.0*l))
ENDFOR
FOR m=0,lmax-1 DO BEGIN
FOR l=m+1,lmax-1 DO BEGIN
X=(2.0*l+1.0)/((l+m)*(l-m))
alm = sqrt(X*(2.0*l-1.0))
blm = sqrt(X*(l-m-1.0)*(l+m-1.0)/(2.0*l-3.0))
ENDFOR
ENDFOR
ENDIF
; set the values of theta in radian
cosTheta = cos(3)
sinTheta = sin(3)
;initialization of legenders function
Plm = replicate(0.0,lmax+1, lmax+1)
Plm[1,1] = 1.0
;compute the legenders function values
FOR l=0,lmax-1 DO BEGIN
Plm[l+1,l+1] = alm[l+1,l+1]*sinTheta*Plm[l,l]
ENDFOR
FOR m=0,lmax-1 DO BEGIN
Plm[m+2,m+1] = alm[m+2,m+1]*cosTheta*Plm[m+1,m+1]
ENDFOR
FOR m=0,lmax-1 DO BEGIN
FOR l=m+2,lmax DO BEGIN
Plm[l+1,m+1] = alm[l+1,m+1]*cosTheta*Plm[l,m+1]-blm[l+1,m+1]*Plm[l-1,m+1]
ENDFOR
ENDFOR
print,'program completed'
END
--http://compgroups.net/comp.lang.idl-pvwave/
|
|
|