;ō
EFc           @   sC   d  Z  d k l Z d e f d     YZ [ d f  d     YZ d S(   sĄ   Legendre polynomials and spherical harmonics.

See http://www.chaos.org.uk/~eddy/math/smooth/harmony.html

$Id: Legendre.py,v 1.2 2007/03/08 23:40:31 eddy Exp $
(   s
   Polynomials   Legendrec           B   sX   t  Z e i Z d k l Z d k l Z e e d  Z [ [ e d d d  d  Z	 RS(   N(   s   hcf(   s	   factorialc   	      C   sĨ  | d j  p> | | j p1 | | j  p# | t |  j p | t |  j o t d | |   n | d j  o | } n | |  _ | | | d | f \ } } d g | | |  | d f \ } } } | | | d d o | } n x` | | | j  oN | | | <| | | | | d | | d f \ } } | | d | } qņ W| | | j p t  | i |  |  i t t | t |   d  |   d  S(   Ni    sH   Legendre(b, q) is defined for natural b and integers q between -b and +bi   i   c         C   s   |  | S(   N(   s   xs   n(   s   xs   n(    (    s*   /home/eddy/.sys/py/study/maths/Legendre.pys   <lambda>!   s    (   s   bs   qs   ints
   ValueErrors   selfs   _Legendre__qs   js   Ls   plings   ks   lasts   AssertionErrors   appends   _Legendre__upinits   maps   applys   hcfs   tuple(	   s   selfs   bs   qs   hcfs   plings   lasts   js   Ls   k(    (    s*   /home/eddy/.sys/py/study/maths/Legendre.pys   __init__   s"    N 	)  
.i   i    iĸĸĸĸc         C   s-   |  d | |  i i d d  d  d Sd  S(   Ni   iĸĸĸĸi    i   f0.5(   s   selfs   cosps   _Legendre__qs   integral(   s   selfs   igs   cosp(    (    s*   /home/eddy/.sys/py/study/maths/Legendre.pys   _lazy_get_scale_&   s    (
   s   __name__s
   __module__s
   Polynomials   __init__s   _Legendre__upinits   naturals   hcfs   Pascals	   factorials   _lazy_get_scale_(    (    (    s*   /home/eddy/.sys/py/study/maths/Legendre.pys   Legendre	   s   	s	   Sphericalc           B   sS   t  Z d  Z h  d  Z d d e d  Z [ d k l Z d e d d  Z [ RS(   s  A spherical harmonic.

    Attributes l and j correspond to total spin and its component parallel to
    the co-ordinate axis.  Supports being called as a function of two
    parameters, longitude and latitude, both of which must be Quantity()s with
    units of angle.c         C   sO   y | |  | f } Wn0 t j
 o$ t |  |  | |  | f <} n X| Sd  S(   N(   s   caches   bs   qs   anss   KeyErrors   Legendre(   s   bs   qs   caches   ans(    (    s*   /home/eddy/.sys/py/study/maths/Legendre.pys   azimuth3   s
      "i    c         C   sU   | | f \ |  _  |  _ | d j  o | } n | | |  | f \ |  _ |  _ d  S(   Ni    (   s   ls   js   selfs   Legendres   _Spherical__polys   _Spherical__q(   s   selfs   ls   js   Legendre(    (    s*   /home/eddy/.sys/py/study/maths/Legendre.pys   __init__8   s     (   s   pii   f0.5c         C   s>   |  i | i |  i | i  | i |  i |  i i	 | Sd  S(   N(   s   selfs   js   phis   iExps   _Spherical__polys   thetas   Sins   Coss   _Spherical__qs   scales   tp(   s   selfs   phis   thetas   tp(    (    s*   /home/eddy/.sys/py/study/maths/Legendre.pys   __call__@   s    (   s   __name__s
   __module__s   __doc__s   azimuths   __init__s   maths   pis   __call__(    (    (    s*   /home/eddy/.sys/py/study/maths/Legendre.pys	   Spherical+   s    N(   s   __doc__s
   polynomials
   Polynomials   Legendres	   Spherical(   s
   Polynomials	   Sphericals   Legendre(    (    s*   /home/eddy/.sys/py/study/maths/Legendre.pys   ?   s    