API Reference
Functions
AssociatedLegendrePolynomials.legendre
— Functionp = legendre(norm::AbstractLegendreNorm, l::DimOrInd, m::DimOrInd, x)
Computes the associated Legendre polynomials $N_ℓ^m P_ℓ^m(x)$ of degree(s) l
and order(s) m
at x
for the normalization scheme norm
.
- If
l
andm
are integers, returns a single value. - If
l
is a range0:lmax
andm
an integer, returns the vector of values for orderm
and all degrees0 ≤ l ≤ lmax
. - If
l
is a range0:lmax
andm
is a range0:mmax
, returns the matrix of values for all degrees0 ≤ l ≤ lmax
and orders0 ≤ m ≤ mmax
.
Note that in both the second and third cases, the ranges must have a first index of 0.
AssociatedLegendrePolynomials.legendre!
— Functionlegendre!(norm::AbstractLegendreNorm, Λ, l::Integer, m::Integer, x)
Fills the array Λ
with the Legendre polynomial values $N_ℓ^m P_ℓ^m(x)$ up to/of degree(s) l
and order(s) m
for the normalization scheme norm
. Λ
must be an array with between 0 and 2 more dimensions than x
, with the leading dimensions having the same shape as x
.
- If
ndims(Λ) == ndims(x)
, thenΛ
is filled with the polynomial values atx
for degreel
and orderm
. - If
ndims(Λ) == ndims(x) + 1
, thenl
is interpreted aslmax
, andΛ
filled with polynomial values for all degrees0 ≤ l ≤ lmax
of orderm
. - If
ndims(Λ) == ndims(x) + 2
, thenl
is interpreted aslmax
andm
asmmax
, andΛ
is filled with polynomial values for all degrees0 ≤ l ≤ lmax
and orders0 ≤ m ≤ min(mmax, l)
.
AssociatedLegendrePolynomials.Nlm
— FunctionN = Nlm([T=Float64], l, m)
Computes the normalization constant
\[ N_\ell^m \equiv \sqrt{\frac{2\ell+1}{4\pi} \frac{(\ell-m)!}{(\ell+m)!}}\]
which defines the Spherical Harmonic normalized functions $\lambda_\ell^m(x)$ in terms of the standard unit normalized $P_\ell^m(x)$
\[ \lambda_\ell^m(x) \equiv N_\ell^m P_\ell^m(x)\]
using numbers of type T
.
Normalizations
AssociatedLegendrePolynomials.AbstractLegendreNorm
— Typeabstract type AbstractLegendreNorm end
Abstract trait supertype for normalization conditions of the associated Legendre functions.
AssociatedLegendrePolynomials.LegendreUnitNorm
— Typestruct LegendreUnitNorm <: AbstractLegendreNorm end
Trait type denoting the unnormalized associated Legendre functions $P_\ell^m(x)$ which solve the colatitude $\theta$ part of Laplace's equation in spherical coordinates where $x=\cos(\theta)$. The degree $\ell=0$, order $m=0$ constant function is normalized to be unity:
\[ P_0^0(x) = 1\]
AssociatedLegendrePolynomials.LegendreFourPiNorm
— Typestruct LegendreFourPiNorm <: AbstractLegendreNorm end
Trait type denoting the $4\pi$ (geodesy) normalization of the associated Legendre functions $F_\ell^m(x)$. The orthonormal normalization is defined such that
\[ \int_{-1}^{1} \left[ F_\ell^m(x) \right]^2 \,dx = 2\]
The normalization factor with respect to the standard (unnormalized) Legendre functions $P_\ell^m(x)$ (LegendreUnitNorm
) is given by
\[ F_\ell^m(x) \equiv \sqrt{2\pi(2\ell+1) \frac{(\ell-m)!}{(\ell+m)!}} P_\ell^m(x)\]
AssociatedLegendrePolynomials.LegendreOrthoNorm
— Typestruct LegendreOrthoNorm <: AbstractLegendreNorm end
Trait type denoting the orthonormal (full) normalization of the associated Legendre functions $O_\ell^m(x)$. The orthonormal normalization is defined such that
\[ \int_{-1}^{1} \left[ O_\ell^m(x) \right]^2 \,dx = 1\]
The normalization factor with respect to the standard (unnormalized) Legendre functions $P_\ell^m(x)$ (LegendreUnitNorm
) is given by
\[ O_\ell^m(x) \equiv \sqrt{\frac{2\ell+1}{2} \frac{(\ell-m)!}{(\ell+m)!}} P_\ell^m(x)\]
AssociatedLegendrePolynomials.LegendreSphereNorm
— Typestruct LegendreSphereNorm <: AbstractLegendreNorm end
Trait type denoting the spherical-harmonic normalization of the associated Legendre functions $\lambda_\ell^m(x)$. The spherical-harmonic normalization is defined such that
\[ \int_{-1}^{1} \left[ \lambda_\ell^m(x) \right]^2 \,dx = \frac{1}{2\pi}\]
The normalization factor with respect to the standard (unnormalized) Legendre functions $P_\ell^m(x)$ (LegendreUnitNorm
) is given by
\[ \lambda_\ell^m(x) \equiv \sqrt{\frac{2\ell+1}{4\pi} \frac{(\ell-m)!}{(\ell+m)!}} P_\ell^m(x)\]
AssociatedLegendrePolynomials.LegendreNormCoeff
— Typestruct LegendreNormCoeff{N<:AbstractLegendreNorm,T<:Real} <: AbstractLegendreNorm
Precomputed recursion relation coefficients for the normalization N
and value type T
.
Example
julia> LegendreNormCoeff{LegendreSphereNorm,Float64}(1)
LegendreNormCoeff{LegendreSphereNorm,Float64} for lmax = 1, mmax = 1 with coefficients:
μ: [0.0, 1.22474]
ν: [1.73205, 2.23607]
α: [0.0 0.0; 1.73205 0.0]
β: [0.0 0.0; -0.0 0.0]
Aliases
The following functors are constant aliases to the underlying normalization types which have been made callable via an appropriate call overload.
AssociatedLegendrePolynomials.Plm
— Constantp = Plm(l, m, x)
Computes the associated Legendre polynomials using unit normalization; equivalent to p = legendre(LegendreUnitNorm(), l, m, x)
.
AssociatedLegendrePolynomials.λlm
— Constantλ = λlm(l, m, x)
Computes the associated Legendre polynomials using spherical-harmonic normalization; equivalent to λ = legendre(LegendreSphereNorm(), l, m, x)
.
AssociatedLegendrePolynomials.Plm!
— ConstantPlm!(P, l, m, x)
Fills the array P
with the unit-normalized associated Legendre polynomial values $P_ℓ^m(x)$; equivalent to legendre!(LegendreUnitNorm(), P, l, m, x)
.
AssociatedLegendrePolynomials.λlm!
— Constantλlm!(Λ, l, m, x)
Fills the array Λ
with the spherical-harmonic normalized associated Legendre polynomial values $λ_ℓ^m(x)$; equivalent to legendre!(LegendreSphereNorm(), P, l, m, x)
.
There are also aliases for pre-computed coefficients of the provided normalizations.
AssociatedLegendrePolynomials.LegendreUnitCoeff
— TypeLegendreUnitCoeff{T}
Precomputed recursion relation coefficients for the standard unit normalization. Alias for LegendreNormCoeff{LegendreUnitNorm,T}
.
AssociatedLegendrePolynomials.LegendreFourPiCoeff
— TypeLegendreFourPiCoeff{T}
Table type of precomputed recursion relation coefficients for the $4\pi$ spherical harmonic normalization. Alias for LegendreNormCoeff{LegendreFourPiNorm,T}
.
AssociatedLegendrePolynomials.LegendreOrthoCoeff
— TypeLegendreOrthoCoeff{T}
Table type of precomputed recursion relation coefficients for the orthonormal normalization. Alias for LegendreNormCoeff{LegendreOrthoNorm,T}
.
AssociatedLegendrePolynomials.LegendreSphereCoeff
— TypeLegendreSphereCoeff{T}
Table type of precomputed recursion relation coefficients for the spherical harmonic normalization. Alias for LegendreNormCoeff{LegendreSphereNorm,T}
.
Normalization Interface
The following functions are unexported but considered a public API for interacting with and defining additional normalizations.
AssociatedLegendrePolynomials.initcond
— Functioninitcond(::N, ::Type{T}) where {N<:AbstractLegendreNorm, T}
Returns the initial condition $P_0^0(x)$ for the associated Legendre recursions based on the normalization choice N
for numeric type T
.
AssociatedLegendrePolynomials.coeff_μ
— Functioncoeff_μ(norm::N, ::Type{T}, l::Integer) where {N<:AbstractLegendreNorm, T}
Returns the coefficient $\mu_\ell$ for the single-term recursion relation
\[ P_\ell^\ell(x) = -\mu_\ell \sqrt{1-x^2} P_{\ell-1}^{\ell-1}(x)\]
where $\mu_\ell$ is appropriate for the choice of normalization N
.
AssociatedLegendrePolynomials.coeff_ν
— Functioncoeff_ν(norm::N, ::Type{T}, l::Integer) where {N<:AbstractLegendreNorm, T}
Returns the coefficient $\nu_\ell$ for the single-term recursion relation
\[ P_\ell^{\ell-1}(x) = \nu_\ell x P_{\ell-1}^{\ell-1}(x)\]
where $\nu_\ell$ is appropriate for the choice of normalization N
.
AssociatedLegendrePolynomials.coeff_α
— Functioncoeff_α(norm::N, ::Type{T}, l::Integer, m::Integer) where {N<:AbstractLegendreNorm, T}
Returns the coefficient $\alpha_\ell^m$ for the two-term recursion relation
\[ P_\ell^m(x) = \alpha_\ell^m x P_{\ell-1}^m(x) - \beta_\ell^m P_{\ell-2}^m(x)\]
where $\alpha_\ell^m$ is appropriate for the choice of normalization N
.
AssociatedLegendrePolynomials.coeff_β
— Functioncoeff_β(norm::N, ::Type{T}, l::Integer, m::Integer) where {N<:AbstractLegendreNorm, T}
Returns the coefficient $\beta_\ell^m$ for the two-term recursion relation
\[ P_\ell^m(x) = \alpha_\ell^m x P_{\ell-1}^m(x) - \beta_\ell^m P_{\ell-2}^m(x)\]
where $\beta_\ell^m$ is appropriate for the choice of normalization N
.
AssociatedLegendrePolynomials.boundscheck_hook
— Functionboundscheck_hook(norm::AbstractLegendreNorm, lmax, mmax)
A bounds-checking hook executed at the beginning of each legendre!
call to permit a normalization norm
to validate that the given maximum $(\ell,m)$ will be within the ability to satisfy. The default case always returns nothing
. A custom normalization should throw an error if lmax
or mmax
is out of bounds or return nothing
otherwise.
For example, the precomputed coefficients of LegendreNormCoeff
are limited to a given domain at time of construction and cannot be used to calculate terms to arbitrary orders/degrees.