@@ -67,8 +67,11 @@ polytype(x) = typeof(float(x*x))
67
67
Return an iterator that generates the values of the Legendre polynomials ``P_\\ ell(x)`` for the given `x`.
68
68
If `lmax` is specified then only the values of ``P_\\ ell(x)`` from `0` to `lmax` are returned.
69
69
70
+ !!! warn
71
+ `LegendrePolynomialIterator` will not be a part of the public API from the next minor release.
72
+
70
73
# Examples
71
- ``jldoctest
74
+ ``` jldoctest
72
75
julia> import LegendrePolynomials: LegendrePolynomialIterator
73
76
74
77
julia> iter = LegendrePolynomialIterator(0.5, 4);
@@ -84,15 +87,15 @@ julia> collect(iter)
84
87
julia> iter = LegendrePolynomialIterator(0.5);
85
88
86
89
julia> collect(Iterators.take(iter, 5)) # evaluete 5 elements (l = 0:4)
87
- 5-element Array {Float64,1 }:
90
+ 5-element Vector {Float64}:
88
91
1.0
89
92
0.5
90
93
-0.125
91
94
-0.4375
92
95
-0.2890625
93
96
94
97
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}:
96
99
-0.0605180259618612
97
100
0.02196749072249231
98
101
0.08178451892628381
@@ -104,6 +107,8 @@ struct LegendrePolynomialIterator{T, L <: Union{Integer, Nothing}, V}
104
107
x :: V
105
108
lmax :: L
106
109
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 )
107
112
checkdomain (x)
108
113
new {T,L,V} (x, lmax)
109
114
end
@@ -149,7 +154,7 @@ Base.copy(iter::LegendrePolynomialIterator) = typeof(iter)(iter.x, iter.lmax)
149
154
"""
150
155
Pl(x, l::Integer)
151
156
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`.
153
158
154
159
# Examples
155
160
```jldoctest
@@ -189,7 +194,7 @@ Base.@propagate_inbounds function _unsafePlm!(cache, x, l, m)
189
194
# handle m > 0
190
195
for mi in 1 : m
191
196
# We denote the terms as P_mi_li
192
-
197
+
193
198
# li == mi
194
199
P_mim1_mim1 = cache[1 ]
195
200
P_mi_mi = Plm_recursion_m (eltype (cache), mi, mi, P_mim1_mim1, x)
@@ -219,11 +224,13 @@ end
219
224
"""
220
225
Plm(x, l::Integer, m::Integer, [cache::AbstractVector])
221
226
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`
224
229
and may be overwritten during the computation.
225
230
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
227
234
Legendre polynomials.
228
235
229
236
# Examples
@@ -236,7 +243,7 @@ julia> Plm(0.5, 4, 0) == Pl(0.5, 4)
236
243
true
237
244
```
238
245
"""
239
- Base. @propagate_inbounds function Plm (x, l:: Integer , m:: Integer ,
246
+ Base. @propagate_inbounds function Plm (x, l:: Integer , m:: Integer ,
240
247
A = begin
241
248
_checkvalues_m (x, l, m)
242
249
# do not allocate A if the value is trivially zero
@@ -407,7 +414,10 @@ collectPl(x; lmax::Integer) = collect(LegendrePolynomialIterator(x, lmax))
407
414
"""
408
415
collectPlm(x; lmax::Integer, m::Integer)
409
416
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``.
411
421
412
422
The coefficient `m` must be greater than or equal to zero.
413
423
437
447
"""
438
448
collectPlm!(v::AbstractVector, x; lmax::Integer, m::Integer)
439
449
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``.
442
454
443
455
The coefficient `m` must be greater than or equal to zero.
444
456
@@ -461,12 +473,12 @@ function collectPlm!(v, x; lmax::Integer, m::Integer)
461
473
assertnonnegative (lmax)
462
474
m >= 0 || throw (ArgumentError (" coefficient m must be >= 0" ))
463
475
checklength (v, lmax + 1 )
464
-
476
+
465
477
# trivially zero for l < m
466
478
fill! ((@view v[(0 : m- 1 ) .+ firstindex (v)]), zero (eltype (v)))
467
479
# populate the other elements
468
480
@inbounds Plm (x, lmax, m, @view v[(m: lmax) .+ firstindex (v)])
469
-
481
+
470
482
v
471
483
end
472
484
@@ -512,7 +524,7 @@ At output, `v[l + firstindex(v)] == dnPl(x, l, n)` for `l = 0:lmax`.
512
524
513
525
# Examples
514
526
515
- ``jldoctest
527
+ ``` jldoctest
516
528
julia> v = zeros(4);
517
529
518
530
julia> collectdnPl!(v, 0.5, lmax = 3, n = 2)
0 commit comments