Skip to content

Commit ddb00f2

Browse files
authored
update doscstrings to v1.6 format (#8)
* update doscstrings to v1.6 format * update Documenter to v0.27
1 parent 4eb557c commit ddb00f2

File tree

5 files changed

+39
-39
lines changed

5 files changed

+39
-39
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
- uses: actions/checkout@v2
6060
- uses: julia-actions/setup-julia@v1
6161
with:
62-
version: '1'
62+
version: '1.6'
6363
- run: |
6464
julia --project=docs -e '
6565
using Pkg

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ HyperDualNumbers = "50ceba7f-c3ee-5a84-a6e8-3ad40456ec97"
44
LegendrePolynomials = "3db4a2ba-fc88-11e8-3e01-49c72059a882"
55

66
[compat]
7-
Documenter = "0.26"
7+
Documenter = "0.27"
88
HyperDualNumbers = "4"

docs/src/derivatives.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22

33
## Analytical recursive approach
44

5-
The Bonnet's recursion formula
5+
The Bonnet's recursion formula
66

77
```math
88
P_\ell(x) = \left((2\ell-1) x P_{\ell-1}(x) - (\ell-1)P_{\ell - 2}(x)\right)/\ell
99
```
1010

11-
may be differentiated an arbitrary number of times analytically to obtain recursion relations for higher derivatives:
11+
may be differentiated an arbitrary number of times analytically to obtain recursion relations for higher derivatives:
1212

1313
```math
14-
\frac{d^n P_\ell(x)}{dx^n} = \frac{(2\ell-1)}{\ell} \left(x \frac{d^n P_{\ell-1}(x)}{dx^n} +
14+
\frac{d^n P_\ell(x)}{dx^n} = \frac{(2\ell-1)}{\ell} \left(x \frac{d^n P_{\ell-1}(x)}{dx^n} +
1515
n \frac{d^{(n-1)} P_{\ell-1}(x)}{dx^{(n-1)}} \right) - \frac{(\ell-1)}{\ell} \frac{d^n P_{\ell-2}(x)}{dx^n}
1616
```
1717

1818
This provides a simultaneous recursion relation in ``\ell`` as well as ``n``, solving which we may obtain derivatives up to any order. This is the approach used in this package to compute the derivatives of Legendre polynomials.
1919

2020
## Automatic diferentiation
2121

22-
The Julia automatic differentiation framework may be used to compute the derivatives of Legendre polynomials alongside their values. Since the defintions of the polynomials are completely general, they may be called with dual or hyperdual numbers as arguments to evaluate derivarives in one go.
22+
The Julia automatic differentiation framework may be used to compute the derivatives of Legendre polynomials alongside their values. Since the defintions of the polynomials are completely general, they may be called with dual or hyperdual numbers as arguments to evaluate derivarives in one go.
2323
We demonstrate one example of this using the package [`HyperDualNumbers.jl`](https://github.com/JuliaDiff/HyperDualNumbers.jl) v4:
2424

2525
```@meta
@@ -43,21 +43,21 @@ julia> p = Pl(xh, 3)
4343
-0.4375 + 0.375ε₁ + 0.375ε₂ + 7.5ε₁ε₂
4444
```
4545

46-
The Legendre polynomial ``P_\ell(x)`` may be obtained using
46+
The Legendre polynomial ``P_\ell(x)`` may be obtained using
4747

4848
```jldoctest hyperdual
4949
julia> realpart(p)
5050
-0.4375
5151
```
5252

53-
The first derivative ``dP_\ell(x)/dx`` may be obtained as
53+
The first derivative ``dP_\ell(x)/dx`` may be obtained as
5454

5555
```jldoctest hyperdual
5656
julia> ε₁part(p)
5757
0.375
5858
```
5959

60-
The second derivative ``d^2P_\ell(x)/dx^2`` may be obtained using
60+
The second derivative ``d^2P_\ell(x)/dx^2`` may be obtained using
6161

6262
```jldoctest hyperdual
6363
julia> ε₁ε₂part(p)
@@ -68,7 +68,7 @@ Something similar may also be evaluated for all `l` iteratively. For example, th
6868

6969
```jldoctest hyperdual
7070
julia> collectPl(xh, lmax=4)
71-
5-element OffsetArray(::Array{Hyper{Float64},1}, 0:4) with eltype Hyper{Float64} with indices 0:4:
71+
5-element OffsetArray(::Vector{Hyper{Float64}}, 0:4) with eltype Hyper{Float64} with indices 0:4:
7272
1.0 + 0.0ε₁ + 0.0ε₂ + 0.0ε₁ε₂
7373
0.5 + 1.0ε₁ + 1.0ε₂ + 0.0ε₁ε₂
7474
-0.125 + 1.5ε₁ + 1.5ε₂ + 3.0ε₁ε₂
@@ -80,15 +80,15 @@ We may extract the first derivatives by broadcasting the function `ε₁part` on
8080

8181
```jldoctest hyperdual
8282
julia> ε₁part.(collectPl(xh, lmax=4))
83-
5-element OffsetArray(::Array{Float64,1}, 0:4) with eltype Float64 with indices 0:4:
83+
5-element OffsetArray(::Vector{Float64}, 0:4) with eltype Float64 with indices 0:4:
8484
0.0
8585
1.0
8686
1.5
8787
0.375
8888
-1.5625
8989
```
9090

91-
Similarly the function `ε₁ε₂part` may be used to obtain the second derivatives.
91+
Similarly the function `ε₁ε₂part` may be used to obtain the second derivatives.
9292

9393
Several convenience functions to compute the derivatives of Legendre polynomials were available in `LegendrePolynomials` v0.2, but have been removed in v0.3. The users are encouraged to implement convenience functions to extract the derivatives as necessary. As an exmaple, we may compute the polynomials and their first and second derivatives together as
9494

@@ -104,4 +104,4 @@ Pl_dPl_d2Pl (generic function with 1 method)
104104
105105
julia> Pl_dPl_d2Pl(0.5, lmax = 3)
106106
([1.0, 0.5, -0.125, -0.4375], [0.0, 1.0, 1.5, 0.375], [0.0, 0.0, 3.0, 7.5])
107-
```
107+
```

docs/src/index.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ Compute [Legendre polynomials](https://en.wikipedia.org/wiki/Legendre_polynomial
1313
P_\ell(x) = \left((2\ell-1) x P_{\ell-1}(x) - (\ell-1)P_{\ell - 2}(x)\right)/\ell
1414
```
1515

16-
Currently this package evaluates the standard polynomials that satisfy ``P_\ell(1) = 1`` and ``P_0(x) = 1``. These are normalized as
16+
Currently this package evaluates the standard polynomials that satisfy ``P_\ell(1) = 1`` and ``P_0(x) = 1``. These are normalized as
1717

1818
```math
1919
\int_{-1}^1 P_m(x) P_n(x) dx = \frac{2}{2n+1} \delta_{mn}.
2020
```
2121

22-
There are four main functions:
22+
There are four main functions:
2323

2424
* [`Pl(x,l)`](@ref Pl): this evaluates the Legendre polynomial for a given degree `l` at the argument `x`. The argument needs to satisfy `-1 <= x <= 1`.
2525
* [`collectPl(x; lmax)`](@ref collectPl): this evaluates all the polynomials for `l` lying in `0:lmax` at the argument `x`. As before the argument needs to lie in the domain of validity. Functionally this is equivalent to `Pl.(x, 0:lmax)`, except `collectPl` evaluates the result in one pass, and is therefore faster. There is also the in-place version [`collectPl!`](@ref) that uses a pre-allocated array.
@@ -46,7 +46,7 @@ Evaluate all the polynomials for `l` in `0:lmax` as `collectPl(x; lmax)`
4646

4747
```jldoctest
4848
julia> collectPl(0.5, lmax = 3)
49-
4-element OffsetArray(::Array{Float64,1}, 0:3) with eltype Float64 with indices 0:3:
49+
4-element OffsetArray(::Vector{Float64}, 0:3) with eltype Float64 with indices 0:3:
5050
1.0
5151
0.5
5252
-0.125
@@ -57,7 +57,7 @@ Evaluate all the `n`th derivatives as `collectdnPl(x; lmax, n)`:
5757

5858
```jldoctest
5959
julia> collectdnPl(0.5, lmax = 5, n = 3)
60-
6-element OffsetArray(::Array{Float64,1}, 0:5) with eltype Float64 with indices 0:5:
60+
6-element OffsetArray(::Vector{Float64}, 0:5) with eltype Float64 with indices 0:5:
6161
0.0
6262
0.0
6363
0.0
@@ -82,10 +82,10 @@ julia> Pl(big(1)/3, 5)
8282
0.3333333333333333333333333333333333333333333333333333333333333333333333333333305
8383
```
8484

85-
The precision of the latter may be altered using `setprecision`, as
85+
The precision of the latter may be altered using `setprecision`, as
8686

8787
```jldoctest
88-
julia> setprecision(300) do
88+
julia> setprecision(300) do
8989
Pl(big(1)/3, 5)
9090
end
9191
0.33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333317

src/LegendrePolynomials.jl

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ julia> import LegendrePolynomials: LegendrePolynomialIterator
5959
julia> iter = LegendrePolynomialIterator(0.5, 4);
6060
6161
julia> collect(iter)
62-
5-element OffsetArray(::Array{Float64,1}, 0:4) with eltype Float64 with indices 0:4:
62+
5-element OffsetArray(::Vector{Float64}, 0:4) with eltype Float64 with indices 0:4:
6363
1.0
6464
0.5
6565
-0.125
@@ -69,15 +69,15 @@ julia> collect(iter)
6969
julia> iter = LegendrePolynomialIterator(0.5);
7070
7171
julia> collect(Iterators.take(iter, 5)) # evaluete 5 elements (l = 0:4)
72-
5-element Array{Float64,1}:
72+
5-element Vector{Float64}:
7373
1.0
7474
0.5
7575
-0.125
7676
-0.4375
7777
-0.2890625
7878
7979
julia> collect(Iterators.take(Iterators.drop(iter, 100), 5)) # evaluate Pl for l = 100:104
80-
5-element Array{Float64,1}:
80+
5-element Vector{Float64}:
8181
-0.0605180259618612
8282
0.02196749072249231
8383
0.08178451892628381
@@ -90,7 +90,7 @@ struct LegendrePolynomialIterator{T, L <: Union{Integer, Nothing}, V}
9090
lmax :: L
9191
function LegendrePolynomialIterator{T,L,V}(x::V, lmax::L) where {T, L <: Union{Integer, Nothing}, V}
9292
checkdomain(x)
93-
new{T,L,V}(x, lmax)
93+
new{T,L,V}(x, lmax)
9494
end
9595
end
9696
LegendrePolynomialIterator(x) = LegendrePolynomialIterator{polytype(x), Nothing, typeof(x)}(x, nothing)
@@ -202,10 +202,10 @@ end
202202
dnPl(x, l::Integer, n::Integer, [cache::AbstractVector])
203203
204204
Compute the ``n``-th derivative ``d^n P_\\ell(x)/dx^n`` of the Legendre polynomial ``P_\\ell(x)``.
205-
Optionally a pre-allocated vector `cache` may be provided, which must have a minimum length of `l - n + 1`
205+
Optionally a pre-allocated vector `cache` may be provided, which must have a minimum length of `l - n + 1`
206206
and may be overwritten during the computation.
207207
208-
The order of the derivative `n` must be non-negative. For `n == 0` this function just returns
208+
The order of the derivative `n` must be non-negative. For `n == 0` this function just returns
209209
Legendre polynomials.
210210
211211
# Examples
@@ -218,7 +218,7 @@ julia> dnPl(0.5, 4, 0) == Pl(0.5, 4) # zero-th order derivative == Pl(x)
218218
true
219219
```
220220
"""
221-
Base.@propagate_inbounds function dnPl(x, l::Integer, n::Integer,
221+
Base.@propagate_inbounds function dnPl(x, l::Integer, n::Integer,
222222
A = begin
223223
_checkvalues(x, l, n)
224224
# do not allocate A if the value is trivially zero
@@ -245,7 +245,7 @@ end
245245
"""
246246
collectPl!(v::AbstractVector, x; [lmax::Integer = length(v) - 1])
247247
248-
Compute the Legendre Polynomials ``P_\\ell(x)`` for the argument `x` and all degrees `l` in `0:lmax`,
248+
Compute the Legendre Polynomials ``P_\\ell(x)`` for the argument `x` and all degrees `l` in `0:lmax`,
249249
and store them in `v`.
250250
251251
At output `v[firstindex(v) + l] == Pl(x,l)`.
@@ -255,7 +255,7 @@ At output `v[firstindex(v) + l] == Pl(x,l)`.
255255
julia> v = zeros(4);
256256
257257
julia> collectPl!(v, 0.5)
258-
4-element Array{Float64,1}:
258+
4-element Vector{Float64}:
259259
1.0
260260
0.5
261261
-0.125
@@ -264,7 +264,7 @@ julia> collectPl!(v, 0.5)
264264
julia> v = zeros(0:4);
265265
266266
julia> collectPl!(v, 0.5, lmax = 3) # only l from 0 to 3 are populated
267-
5-element OffsetArray(::Array{Float64,1}, 0:4) with eltype Float64 with indices 0:4:
267+
5-element OffsetArray(::Vector{Float64}, 0:4) with eltype Float64 with indices 0:4:
268268
1.0
269269
0.5
270270
-0.125
@@ -276,7 +276,7 @@ function collectPl!(v::AbstractVector, x; lmax::Integer = length(v) - 1)
276276
checklength(v, lmax + 1)
277277

278278
iter = LegendrePolynomialIterator(x, lmax)
279-
279+
280280
for (l, Pl) in pairs(iter)
281281
v[l + firstindex(v)] = Pl
282282
end
@@ -293,7 +293,7 @@ Return `P` with indices `0:lmax`, where `P[l] == Pl(x,l)`
293293
# Examples
294294
```jldoctest
295295
julia> collectPl(0.5, lmax = 4)
296-
5-element OffsetArray(::Array{Float64,1}, 0:4) with eltype Float64 with indices 0:4:
296+
5-element OffsetArray(::Vector{Float64}, 0:4) with eltype Float64 with indices 0:4:
297297
1.0
298298
0.5
299299
-0.125
@@ -306,7 +306,7 @@ collectPl(x; lmax::Integer) = collect(LegendrePolynomialIterator(x, lmax))
306306
"""
307307
collectdnPl(x; n::Integer, lmax::Integer)
308308
309-
Compute the ``n``-th derivative of a Legendre Polynomial ``P_\\ell(x)`` for the argument `x` and all degrees `l = 0:lmax`.
309+
Compute the ``n``-th derivative of a Legendre Polynomial ``P_\\ell(x)`` for the argument `x` and all degrees `l = 0:lmax`.
310310
311311
The order of the derivative `n` must be greater than or equal to zero.
312312
@@ -316,7 +316,7 @@ Returns `v` with indices `0:lmax`, where `v[l] == dnPl(x, l, n)`.
316316
317317
```jldoctest
318318
julia> collectdnPl(0.5, lmax = 3, n = 2)
319-
4-element OffsetArray(::Array{Float64,1}, 0:3) with eltype Float64 with indices 0:3:
319+
4-element OffsetArray(::Vector{Float64}, 0:3) with eltype Float64 with indices 0:3:
320320
0.0
321321
0.0
322322
3.0
@@ -336,8 +336,8 @@ end
336336
"""
337337
collectdnPl!(v::AbstractVector, x; lmax::Integer, n::Integer)
338338
339-
Compute the ``n``-th derivative of a Legendre Polynomial ``P_\\ell(x)`` for the argument `x` and all degrees `l = 0:lmax`,
340-
and store the result in `v`.
339+
Compute the ``n``-th derivative of a Legendre Polynomial ``P_\\ell(x)`` for the argument `x` and all degrees `l = 0:lmax`,
340+
and store the result in `v`.
341341
342342
The order of the derivative `n` must be greater than or equal to zero.
343343
@@ -349,7 +349,7 @@ At output, `v[l + firstindex(v)] == dnPl(x, l, n)` for `l = 0:lmax`.
349349
julia> v = zeros(4);
350350
351351
julia> collectdnPl!(v, 0.5, lmax = 3, n = 2)
352-
4-element Array{Float64,1}:
352+
4-element Vector{Float64}:
353353
0.0
354354
0.0
355355
3.0
@@ -360,13 +360,13 @@ function collectdnPl!(v, x; lmax::Integer, n::Integer)
360360
assertnonnegative(lmax)
361361
n >= 0 || throw(ArgumentError("order of derivative n must be >= 0"))
362362
checklength(v, lmax + 1)
363-
363+
364364
# trivially zero for l < n
365365
fill!((@view v[(0:n-1) .+ firstindex(v)]), zero(eltype(v)))
366366
# populate the other elements
367367
@inbounds dnPl(x, lmax, n, @view v[(n:lmax) .+ firstindex(v)])
368-
368+
369369
v
370370
end
371371

372-
end
372+
end

0 commit comments

Comments
 (0)