Skip to content

Commit 1cfadc4

Browse files
authored
deprecate LegendrePolynomialIterator (#11)
1 parent b45b599 commit 1cfadc4

File tree

2 files changed

+28
-16
lines changed

2 files changed

+28
-16
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "LegendrePolynomials"
22
uuid = "3db4a2ba-fc88-11e8-3e01-49c72059a882"
3-
version = "0.3.4"
3+
version = "0.3.5"
44

55
[deps]
66
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"

src/LegendrePolynomials.jl

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,11 @@ polytype(x) = typeof(float(x*x))
6767
Return an iterator that generates the values of the Legendre polynomials ``P_\\ell(x)`` for the given `x`.
6868
If `lmax` is specified then only the values of ``P_\\ell(x)`` from `0` to `lmax` are returned.
6969
70+
!!! warn
71+
`LegendrePolynomialIterator` will not be a part of the public API from the next minor release.
72+
7073
# Examples
71-
``jldoctest
74+
```jldoctest
7275
julia> import LegendrePolynomials: LegendrePolynomialIterator
7376
7477
julia> iter = LegendrePolynomialIterator(0.5, 4);
@@ -84,15 +87,15 @@ julia> collect(iter)
8487
julia> iter = LegendrePolynomialIterator(0.5);
8588
8689
julia> collect(Iterators.take(iter, 5)) # evaluete 5 elements (l = 0:4)
87-
5-element Array{Float64,1}:
90+
5-element Vector{Float64}:
8891
1.0
8992
0.5
9093
-0.125
9194
-0.4375
9295
-0.2890625
9396
9497
julia> collect(Iterators.take(Iterators.drop(iter, 100), 5)) # evaluate Pl for l = 100:104
95-
5-element Array{Float64,1}:
98+
5-element Vector{Float64}:
9699
-0.0605180259618612
97100
0.02196749072249231
98101
0.08178451892628381
@@ -104,6 +107,8 @@ struct LegendrePolynomialIterator{T, L <: Union{Integer, Nothing}, V}
104107
x :: V
105108
lmax :: L
106109
function LegendrePolynomialIterator{T,L,V}(x::V, lmax::L) where {T, L <: Union{Integer, Nothing}, V}
110+
Base.depwarn("LegendrePolynomialIterator will not be a part of the public API"*
111+
" from the next minor release", :LegendrePolynomialIterator)
107112
checkdomain(x)
108113
new{T,L,V}(x, lmax)
109114
end
@@ -149,7 +154,7 @@ Base.copy(iter::LegendrePolynomialIterator) = typeof(iter)(iter.x, iter.lmax)
149154
"""
150155
Pl(x, l::Integer)
151156
152-
Compute the Legendre Polynomial ``P_\\ell(x)`` for the argument `x` and the degree `l`
157+
Compute the Legendre Polynomial ``P_\\ell(x)`` for the argument `x` and the degree `l`.
153158
154159
# Examples
155160
```jldoctest
@@ -189,7 +194,7 @@ Base.@propagate_inbounds function _unsafePlm!(cache, x, l, m)
189194
# handle m > 0
190195
for mi in 1:m
191196
# We denote the terms as P_mi_li
192-
197+
193198
# li == mi
194199
P_mim1_mim1 = cache[1]
195200
P_mi_mi = Plm_recursion_m(eltype(cache), mi, mi, P_mim1_mim1, x)
@@ -219,11 +224,13 @@ end
219224
"""
220225
Plm(x, l::Integer, m::Integer, [cache::AbstractVector])
221226
222-
Compute the associatedLegendre polynomial ``P_\\ell,m(x)``.
223-
Optionally a pre-allocated vector `cache` may be provided, which must have a minimum length of `l - m + 1`
227+
Compute the associatedLegendre polynomial ``P_\\ell^m(x)``.
228+
Optionally a pre-allocated vector `cache` may be provided, which must have a minimum length of `l - m + 1`
224229
and may be overwritten during the computation.
225230
226-
The coefficient `m` must be non-negative. For `m == 0` this function just returns
231+
The polynomials are defined to include the Condon-Shortley phase ``(-1)^m``.
232+
233+
The coefficient `m` must be non-negative. For `m == 0` this function just returns
227234
Legendre polynomials.
228235
229236
# Examples
@@ -236,7 +243,7 @@ julia> Plm(0.5, 4, 0) == Pl(0.5, 4)
236243
true
237244
```
238245
"""
239-
Base.@propagate_inbounds function Plm(x, l::Integer, m::Integer,
246+
Base.@propagate_inbounds function Plm(x, l::Integer, m::Integer,
240247
A = begin
241248
_checkvalues_m(x, l, m)
242249
# do not allocate A if the value is trivially zero
@@ -407,7 +414,10 @@ collectPl(x; lmax::Integer) = collect(LegendrePolynomialIterator(x, lmax))
407414
"""
408415
collectPlm(x; lmax::Integer, m::Integer)
409416
410-
Compute the associated Legendre Polynomial ``P_\\ell,m(x)`` for the argument `x` and all degrees `l = 0:lmax`.
417+
Compute the associated Legendre Polynomial ``P_\\ell^m(x)`` for the argument `x` and all degrees `l = 0:lmax`.
418+
The polynomials for `l < m` are defined to be zero.
419+
420+
The polynomials are defined to include the Condon-Shortley phase ``(-1)^m``.
411421
412422
The coefficient `m` must be greater than or equal to zero.
413423
@@ -437,8 +447,10 @@ end
437447
"""
438448
collectPlm!(v::AbstractVector, x; lmax::Integer, m::Integer)
439449
440-
Compute the associated Legendre Polynomial ``P_\\ell,m(x)`` for the argument `x` and all degrees `l = 0:lmax`,
441-
and store the result in `v`.
450+
Compute the associated Legendre Polynomial ``P_\\ell^m(x)`` for the argument `x` and all degrees `l = 0:lmax`,
451+
and store the result in `v`. The polynomials for `l < m` are defined to be zero.
452+
453+
The polynomials are defined to include the Condon-Shortley phase ``(-1)^m``.
442454
443455
The coefficient `m` must be greater than or equal to zero.
444456
@@ -461,12 +473,12 @@ function collectPlm!(v, x; lmax::Integer, m::Integer)
461473
assertnonnegative(lmax)
462474
m >= 0 || throw(ArgumentError("coefficient m must be >= 0"))
463475
checklength(v, lmax + 1)
464-
476+
465477
# trivially zero for l < m
466478
fill!((@view v[(0:m-1) .+ firstindex(v)]), zero(eltype(v)))
467479
# populate the other elements
468480
@inbounds Plm(x, lmax, m, @view v[(m:lmax) .+ firstindex(v)])
469-
481+
470482
v
471483
end
472484

@@ -512,7 +524,7 @@ At output, `v[l + firstindex(v)] == dnPl(x, l, n)` for `l = 0:lmax`.
512524
513525
# Examples
514526
515-
``jldoctest
527+
```jldoctest
516528
julia> v = zeros(4);
517529
518530
julia> collectdnPl!(v, 0.5, lmax = 3, n = 2)

0 commit comments

Comments
 (0)