Esempio n. 1
0
def lpmn(m,n,z):
    """Associated Legendre functions of the first kind, Pmn(z) and its
    derivative, Pmn'(z) of order m and degree n.  Returns two
    arrays of size (m+1,n+1) containing Pmn(z) and Pmn'(z) for
    all orders from 0..m and degrees from 0..n.

    z can be complex.
    """
    if not isscalar(m) or (abs(m)>n):
        raise ValueError, "m must be <= n."
    if not isscalar(n) or (n<0):
        raise ValueError, "n must be a non-negative integer."
    if not isscalar(z):
        raise ValueError, "z must be scalar."
    if (m < 0):
        mp = -m
        mf,nf = mgrid[0:mp+1,0:n+1]
        sv = errprint(0)
        fixarr = where(mf>nf,0.0,(-1)**mf * gamma(nf-mf+1) / gamma(nf+mf+1))
        sv = errprint(sv)
    else:
        mp = m
    if iscomplex(z):
        p,pd = specfun.clpmn(mp,n,real(z),imag(z))
    else:
        p,pd = specfun.lpmn(mp,n,z)
    if (m < 0):
        p = p * fixarr
        pd = pd * fixarr
    return p,pd
Esempio n. 2
0
def lpmn(m, n, z):
    """Associated Legendre functions of the first kind, Pmn(z) and its
    derivative, Pmn'(z) of order m and degree n.  Returns two
    arrays of size (m+1,n+1) containing Pmn(z) and Pmn'(z) for
    all orders from 0..m and degrees from 0..n.

    z can be complex.
    """
    if not isscalar(m) or (abs(m) > n):
        raise ValueError, "m must be <= n."
    if not isscalar(n) or (n < 0):
        raise ValueError, "n must be a non-negative integer."
    if not isscalar(z):
        raise ValueError, "z must be scalar."
    if (m < 0):
        mp = -m
        mf, nf = mgrid[0:mp + 1, 0:n + 1]
        sv = errprint(0)
        fixarr = where(mf > nf, 0.0,
                       (-1)**mf * gamma(nf - mf + 1) / gamma(nf + mf + 1))
        sv = errprint(sv)
    else:
        mp = m
    if iscomplex(z):
        p, pd = specfun.clpmn(mp, n, real(z), imag(z))
    else:
        p, pd = specfun.lpmn(mp, n, z)
    if (m < 0):
        p = p * fixarr
        pd = pd * fixarr
    return p, pd
Esempio n. 3
0
File: basic.py Progetto: minrk/scipy
def lpmn(m, n, z):
    """Associated Legendre functions of the first kind, Pmn(z) and its
    derivative, Pmn'(z) of order m and degree n.  Returns two
    arrays of size (m+1,n+1) containing Pmn(z) and Pmn'(z) for
    all orders from 0..m and degrees from 0..n.

    z can be complex.

    Parameters
    ----------
    m : int
       |m| <= n; the order of the Legendre function
    n : int
       where `n` >= 0; the degree of the Legendre function.  Often
       called ``l`` (lower case L) in descriptions of the associated
       Legendre function
    z : float or complex
       input value

    Returns
    -------
    Pmn_z : (m+1, n+1) array
       Values for all orders 0..m and degrees 0..n
    Pmn_d_z : (m+1, n+1) array
       Derivatives for all orders 0..m and degrees 0..n       
    """
    if not isscalar(m) or (abs(m) > n):
        raise ValueError, "m must be <= n."
    if not isscalar(n) or (n < 0):
        raise ValueError, "n must be a non-negative integer."
    if not isscalar(z):
        raise ValueError, "z must be scalar."
    if (m < 0):
        mp = -m
        mf, nf = mgrid[0:mp + 1, 0:n + 1]
        sv = errprint(0)
        fixarr = where(mf > nf, 0.0,
                       (-1)**mf * gamma(nf - mf + 1) / gamma(nf + mf + 1))
        sv = errprint(sv)
    else:
        mp = m
    if iscomplex(z):
        p, pd = specfun.clpmn(mp, n, real(z), imag(z))
    else:
        p, pd = specfun.lpmn(mp, n, z)
    if (m < 0):
        p = p * fixarr
        pd = pd * fixarr
    return p, pd
Esempio n. 4
0
def lpmn(m,n,z):
    """Associated Legendre functions of the first kind, Pmn(z) and its
    derivative, Pmn'(z) of order m and degree n.  Returns two
    arrays of size (m+1,n+1) containing Pmn(z) and Pmn'(z) for
    all orders from 0..m and degrees from 0..n.

    z can be complex.

    Parameters
    ----------
    m : int
       |m| <= n; the order of the Legendre function
    n : int
       where `n` >= 0; the degree of the Legendre function.  Often
       called ``l`` (lower case L) in descriptions of the associated
       Legendre function
    z : float or complex
       input value

    Returns
    -------
    Pmn_z : (m+1, n+1) array
       Values for all orders 0..m and degrees 0..n
    Pmn_d_z : (m+1, n+1) array
       Derivatives for all orders 0..m and degrees 0..n
    """
    if not isscalar(m) or (abs(m)>n):
        raise ValueError("m must be <= n.")
    if not isscalar(n) or (n<0):
        raise ValueError("n must be a non-negative integer.")
    if not isscalar(z):
        raise ValueError("z must be scalar.")
    if (m < 0):
        mp = -m
        mf,nf = mgrid[0:mp+1,0:n+1]
        sv = errprint(0)
        fixarr = where(mf>nf,0.0,(-1)**mf * gamma(nf-mf+1) / gamma(nf+mf+1))
        sv = errprint(sv)
    else:
        mp = m
    if iscomplex(z):
        p,pd = specfun.clpmn(mp,n,real(z),imag(z))
    else:
        p,pd = specfun.lpmn(mp,n,z)
    if (m < 0):
        p = p * fixarr
        pd = pd * fixarr
    return p,pd