Skip to content

Commit

Permalink
LazyBandedMatrices v0.9 (#28)
Browse files Browse the repository at this point in the history
* LazyBandedMatrices v0.9

* ContinuumArrays v0.15, improvements to stieltjes

* add tests
  • Loading branch information
dlfivefifty authored Aug 22, 2023
1 parent 3332893 commit 7565674
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SingularIntegrals"
uuid = "d7440221-8b5e-42fc-909c-0567823f424a"
authors = ["Sheehan Olver <[email protected]>"]
version = "0.2"
version = "0.2.1"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand All @@ -22,13 +22,13 @@ SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
ArrayLayouts = "1.0.11"
BandedMatrices = "0.17.17"
ClassicalOrthogonalPolynomials = "0.11"
ContinuumArrays = "0.14"
ContinuumArrays = "0.14, 0.15"
FastTransforms = "0.15"
FillArrays = "1"
HypergeometricFunctions = "0.3.4"
InfiniteArrays = "0.12.11, 0.13"
LazyArrays = "1"
LazyBandedMatrices = "0.8.5"
LazyBandedMatrices = "0.8.5, 0.9"
QuasiArrays = "0.11"
SpecialFunctions = "1, 2"
julia = "1.9"
Expand Down
30 changes: 18 additions & 12 deletions src/stieltjes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,20 @@ end
computes inv.(y - x') * P understood in a principle value sense.
"""
stieltjes(P, y...) = stieltjes_layout(MemoryLayout(P), P, y...)
function stieltjes_layout(lay, P, y)
stieltjes_layout(lay, P, y) = stieltjes_size(size(P), P, y)
function stieltjes_size(sz, P, y)
axes(P,1) == y && return stieltjes(P)
error("Not implemented")
end

stieltjes_size(::Tuple{Any}, P, zs::AbstractVector) = [stieltjes(P, z) for z in zs]

function stieltjes_layout(LAY::ApplyLayout{typeof(*)}, V::AbstractQuasiVecOrMat, y...)
a = arguments(LAY, V)
*(stieltjes(a[1], y...), tail(a)...)
end

stieltjes_layout(::ExpansionLayout, A, dims...) = stieltjes_layout(ApplyLayout{typeof(*)}(), A, dims...)
stieltjes_layout(::ExpansionLayout, A, y...) = stieltjes_layout(ApplyLayout{typeof(*)}(), A, y...)


"""
Expand Down Expand Up @@ -179,8 +182,7 @@ end

@simplify function *(S::StieltjesPoints, w::Weight)
zs = S.args[1].args[1] # vector of points to eval at
x = axes(w,1)
[inv.(z .- x') * w for z in zs]
stieltjes(w, zs)
end

function stieltjes(wP::Weighted, z::Number)
Expand All @@ -196,6 +198,17 @@ function stieltjes(wP::Weighted, z::Number)
transpose(RecurrenceArray(z, (A,B,C), [r1,r2]))
end

function stieltjes(wP::Weighted, z::AbstractVector)
T = promote_type(eltype(z), eltype(wP))
P = wP.P
A,B,C = recurrencecoefficients(P)
w = orthogonalityweight(P)
data = Matrix{T}(undef, 2, length(z))
data[1,:] .= stieltjes(w, z) .* _p0(P)
data[2,:] .= (A[1] .* z .+ B[1]) .* data[1,:] .- (A[1]sum(w)*_p0(P))
transpose(RecurrenceArray(z, (A,B,C), data))
end

sqrtx2(z::Number) = sqrt(z-1)*sqrt(z+1)
sqrtx2(x::Real) = sign(x)*sqrt(x^2-1)

Expand All @@ -204,14 +217,7 @@ stieltjes(P::Legendre, z...) = stieltjes(Weighted(P), z...)

@simplify function *(S::StieltjesPoints, wP::Weighted)
z = S.args[1].args[1] # vector of points to eval at
T = promote_type(eltype(S), eltype(wP))
P = wP.P
A,B,C = recurrencecoefficients(P)
w = orthogonalityweight(P)
data = Matrix{T}(undef, 2, length(z))
data[1,:] .= (S * w) .* _p0(P)
data[2,:] .= (A[1] .* z .+ B[1]) .* data[1,:] .- (A[1]sum(w)*_p0(P))
transpose(RecurrenceArray(z, (A,B,C), data))
stieltjes(wP, z)
end

@simplify function *(S::StieltjesPoints, P::Legendre)
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ include("test_recurrence.jl")
@test sum(w) == 1
end

include("test_hilbert.jl")
include("test_stieltjes.jl")
include("test_logkernel.jl")
include("test_power.jl")
include("test_piecewise.jl")
7 changes: 5 additions & 2 deletions test/test_hilbert.jl → test/test_stieltjes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,14 @@ end
@test inv.(z .- x') * f [2.8826861116458593, 1.6307809018753612]
end

@testset "StieltjesPoints Legendre" begin
@testset "StieltjesPoints" begin
z = [2.,3.]
P = Legendre()
x = axes(P,1)
@test (inv.(z .- x') * P)[:,1:5] [(inv.(2 .- x')*P)[1:5]'; (inv.(3 .- x')*P)[1:5]']
S = inv.(z .- x')
@test (S * P)[:,1:5] [(inv.(2 .- x')*P)[1:5]'; (inv.(3 .- x')*P)[1:5]']

@test S * JacobiWeight(0.1,0.2) == stieltjes.(Ref(JacobiWeight(0.1,0.2)), z)
end
end

Expand Down

0 comments on commit 7565674

Please sign in to comment.