Skip to content

Commit 836436e

Browse files
committed
Add README
1 parent b70149b commit 836436e

File tree

4 files changed

+81
-5
lines changed

4 files changed

+81
-5
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
version:
23-
- '1.10'
23+
- 'lts'
24+
- '1'
2425
os:
2526
- ubuntu-latest
2627
- macOS-latest

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,76 @@
11
# RecurrenceRelationshipArrays.jl
22
A Julia package for caching solutions to recurrence relationships
3+
4+
5+
This package implements arrays associated with recurrence relationships
6+
as implemented in [RecurrenceRelationships.jl](https://github.com/JuliaApproximation/RecurrenceRelationships.jl).
7+
8+
# Matrix-valued Clenshaw
9+
10+
We can
11+
construct multiplication matrices associated with orthogonal polynomials using `Clenshaw`. The follow represents multiplication by $U_0(x) + 2U_1(x) + 3U_2(x)$ acting on a Chebyshev-U expansion:
12+
```julia
13+
julia> using RecurrenceRelationshipArrays, FillArrays, InfiniteArrays
14+
15+
julia> X = SymTridiagonal(Fill(0.0,∞), Fill(1/2,∞)) # Jacobi matrix associated with Chebyshev U
16+
ℵ₀×ℵ₀ SymTridiagonal{Float64, Fill{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}} with indices OneToInf()×OneToInf():
17+
0.0 0.5
18+
0.5 0.0 0.5
19+
0.5 0.0 0.5
20+
0.5 0.0 0.5
21+
0.5 0.0 0.5
22+
0.5 0.0 0.5
23+
0.5 0.0 0.5
24+
25+
26+
julia> rec_U = Fill(2,∞), Zeros{Int}(∞), Ones{Int}(∞); # recurrence coefficients for Chebyshev U
27+
28+
julia> Clenshaw([1,2,3], rec_U..., X)
29+
ℵ₀×ℵ₀ Clenshaw{Float64} with 3 degree polynomial:
30+
1.0 2.0 3.0
31+
2.0 4.0 2.0 3.0
32+
3.0 2.0 4.0 2.0 3.0
33+
3.0 2.0 4.0 2.0 3.0
34+
3.0 2.0 4.0 2.0 3.0
35+
3.0 2.0 4.0 2.0 3.0
36+
3.0 2.0 4.0 2.0
37+
38+
```
39+
40+
41+
# Minimal solutions to 3-term recurrences
42+
43+
The type `RecurrenceArray` allows us to represent a minimal solution
44+
of a recurrence relationship, i.e., the Stieltjes transform of the orthogonal polynomials.
45+
This automatically combines forward and backward recurrence, and so will also will work on the support of the measure. Here is a simple example:
46+
```julia
47+
julia> z = 1.0001; # point close to the support
48+
49+
julia> ξ = inv(z + sign(z)sqrt(z^2-1)); # exact formula for Stieltjes transform of sqrt(1-x^2). The next term is ξ^2.
50+
51+
julia> r = RecurrenceArray(z, rec_U, [ξ,ξ^2])
52+
ℵ₀-element RecurrenceArray{Float64, 1, Float64, Fill{Int64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, Zeros{Int64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, Ones{Int64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}} with indices OneToInf():
53+
0.9859575108273005
54+
0.9721122131567664
55+
0.9584613379288637
56+
0.9450021549685467
57+
0.9317319724392233
58+
0.9186481363043878
59+
0.9057480297968131
60+
61+
62+
julia> z = [0.1+0im, 1.0001, 10.0]; # can evaluate at multiple points
63+
64+
julia> ξ = @. inv(z + sign(z)sqrt(z^2-1));
65+
66+
julia> RecurrenceArray(z, rec_U, [ξ'; ξ'.^2])
67+
ℵ₀×3 RecurrenceArray{ComplexF64, 2, Vector{ComplexF64}, Fill{Int64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, Zeros{Int64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, Ones{Int64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}} with indices OneToInf()×Base.OneTo(3):
68+
0.1+0.994987im 0.985958+0.0im 0.0501256+0.0im
69+
-0.98+0.198997im 0.972112+0.0im 0.00251258+0.0im
70+
-0.296-0.955188im 0.958461+0.0im 0.000125945-0.0im
71+
0.9208-0.390035im 0.945002+0.0im 6.31305e-6-0.0im
72+
0.48016+0.877181im 0.931732+0.0im 3.16446e-7+0.0im
73+
-0.824768+0.565471im 0.918648+0.0im 1.5862e-8-0.0im
74+
-0.645114-0.764087im 0.905748+0.0im 7.95095e-10-0.0im
75+
76+
```

src/RecurrenceRelationshipArrays.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
module RecurrenceRelationshipArrays
22
using LinearAlgebra, InfiniteArrays, LazyArrays, FillArrays, ArrayLayouts, BandedMatrices
3-
import LazyArrays: AbstractCachedArray, LazyArrayStyle, AbstractPaddedLayout, resizedata!, zero!
3+
import LazyArrays: AbstractCachedArray, LazyArrayStyle, AbstractPaddedLayout, resizedata!, zero!, paddeddata
44
import Base: axes, size, getindex, broadcasted, copy, view, +, -, Slice, tail
55
import FillArrays: AbstractFill, getindex_value
66
import BandedMatrices: AbstractBandedMatrix, bandwidths, _BandedMatrix
77
import InfiniteArrays: OneToInf, AbstractInfUnitRange
8-
import ArrayLayouts: MatMulVecAdd, sublayout, MemoryLayout, sub_materialize, transposelayout, materialize!
9-
import RecurrenceRelationships: forwardrecurrence_next, forwardrecurrence_partial!, check_clenshaw_recurrences
8+
import ArrayLayouts: MatMulVecAdd, sublayout, MemoryLayout, sub_materialize, transposelayout, materialize!, _fill_lmul!
9+
import RecurrenceRelationships: forwardrecurrence_next, forwardrecurrence_partial!, check_clenshaw_recurrences, clenshaw
1010
export RecurrenceArray, Clenshaw
1111

1212
const LazyArraysBandedMatricesExt = Base.get_extension(LazyArrays, :LazyArraysBandedMatricesExt)
1313
const AbstractLazyBandedLayout = LazyArraysBandedMatricesExt.AbstractLazyBandedLayout
14+
const LazyBandedLayout = LazyArraysBandedMatricesExt.LazyBandedLayout
1415

1516
include("clenshaw.jl")
1617
include("recurrence.jl")

src/clenshaw.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function getindex(S::Symmetric{T,<:Clenshaw}, kr::AbstractUnitRange, jr::Abstrac
204204
return Symmetric(getindex(S.data,1:m,1:m),Symbol(S.uplo))[kr,jr]
205205
end
206206

207-
transposelayout(M::ClenshawLayout) = LazyBandedMatrices.LazyBandedLayout()
207+
transposelayout(M::ClenshawLayout) = LazyBandedLayout()
208208
# TODO: generalise for layout, use Base.PermutedDimsArray
209209
Base.permutedims(M::Clenshaw{<:Number}) = transpose(M)
210210

0 commit comments

Comments
 (0)