comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Legendre Polynomials
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Legendre Polynomials [message #3274] Thu, 29 December 1994 15:27 Go to next message
ganga is currently offline  ganga
Messages: 4
Registered: November 1994
Junior Member
Hello,

Does anyone know where I might find IDL code for calculating Legendre
Polynomials?

Thanks,

Ken

--
Ken Ganga | (510)642-3618
433 LeConte Hall | (510)643-5204 (Fax)
Berkeley, CA 94720 | ganga@physics.berkeley.edu
--
Ken Ganga | (510)642-3618
433 LeConte Hall | (510)643-5204 (Fax)
Berkeley, CA 94720 | ganga@physics.berkeley.edu
Re: Legendre Polynomials [message #3275 is a reply to message #3274] Thu, 29 December 1994 15:58 Go to previous message
thompson is currently offline  thompson
Messages: 584
Registered: August 1991
Senior Member
ganga@physics23 (Ken Ganga) writes:

> Does anyone know where I might find IDL code for calculating Legendre
> Polynomials?

I wrote the following routine some years ago. I can't guarantee that it works,
or that it's even what you want. It's been a long time since I used it.

Sorry that it's undocumented. I've learned better since then. The technique
may be based on Abromowitz and Stegun--I tended to get that sort of thing from
there in those days.

Bill Thompson

============================================================ ===================
FUNCTION LEGENDRE,X,L,M
;
IF N_PARAMS(0) LT 2 THEN BEGIN
PRINT,'*** LEGENDRE must be called with 2-3 parameters:'
PRINT,' X, L [, M ]'
RETURN,X
END ELSE IF N_PARAMS(0) EQ 2 THEN M = 0
;
IF M LT 0 THEN BEGIN
PRINT,'*** M must not be less than 0, routine LEGENDRE.'
RETURN,X
END ELSE IF M GT L THEN BEGIN
PRINT,'*** M must not be greater than L, routine LEGENDRE.'
RETURN,X
END ELSE BEGIN
S = SIZE(X)
IF S(0) EQ 0 THEN TEST = ABS(X) ELSE TEST = MAX(ABS(X))
IF TEST GT 1 THEN BEGIN
PRINT,'*** X must be in the range -1 to 1, routine LEGENDRE.'
RETURN,X
ENDIF
ENDELSE
;
PMM = 0.*X + 1.
IF M GT 0 THEN BEGIN
SOMX2 = SQRT( (1. - X) * (1. + X) )
FACT = 1.
FOR I = 1,M DO BEGIN
PMM = -PMM*FACT*SOMX2
FACT = FACT + 2.
ENDFOR
ENDIF
;
IF L EQ M THEN PLGNDR = PMM ELSE BEGIN
PMMP1 = X * (2*M + 1) * PMM
IF L EQ M+1 THEN PLGNDR = PMMP1 ELSE BEGIN
FOR LL = M+2,L DO BEGIN
PLL = (X*(2*LL-1)*PMMP1 - (LL+M-1)*PMM) / (LL-M)
PMM = PMMP1
PMMP1 = PLL
ENDFOR
PLGNDR = PLL
ENDELSE
ENDELSE
;
RETURN,PLGNDR
END
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Best way of detecting a directory
Next Topic: Re: Best way of detecting a directory

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 18:58:51 PDT 2025

Total time taken to generate the page: 0.23883 seconds