Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "MultivariateOrthogonalPolynomials"
uuid = "4f6956fd-4f93-5457-9149-7bfc4b2ce06d"
version = "0.9.1"
version = "0.9.2"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
6 changes: 3 additions & 3 deletions src/rect.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ function jacobimatrix(::Val{2}, P::RectPolynomial)
KronTrav(Y, Eye{eltype(Y)}(∞))
end
function diff(P::KronPolynomial{N}, order::NTuple{N,Int}; dims...) where N
diffs = diff.(P.args, order)
RectPolynomial(basis.(diffs)...) * KronTrav(coefficients.(diffs)...)
diffs = map(diff, P.args, order)
RectPolynomial(map(basis, diffs)...) * KronTrav(reverse(map(coefficients, diffs))...)
end


Expand Down Expand Up @@ -164,7 +164,7 @@ end

## sum

function Base._sum(P::RectPolynomial, dims)
function Base._sum(P::RectPolynomial, dims::Int)
@assert dims == 1
KronTrav(sum.(P.args; dims=1)...)
end
Expand Down
15 changes: 15 additions & 0 deletions test/test_rect.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,21 @@ using Base: oneto
@test sum(f) ≈ 10.546408460894801 # empirical
end

@testset "diff" begin
P = RectPolynomial(Legendre(),Legendre())
f = expand(P, splat((x,y) -> 1))
@test diff(f,(1,0))[SVector(0.1,0.2)] == diff(f,(0,1))[SVector(0.1,0.2)] == 0.0
f = expand(P, splat((x,y) -> x))
@test diff(f,(1,0))[SVector(0.1,0.2)] == 1.0
@test diff(f,(0,1))[SVector(0.1,0.2)] == 0.0
f = expand(P, splat((x,y) -> cos(x*exp(y))))
@test diff(f,(1,0))[SVector(0.1,0.2)] ≈ -sin(0.1*exp(0.2))*exp(0.2)
@test diff(f,(0,1))[SVector(0.1,0.2)] ≈ -0.1*sin(0.1*exp(0.2))*exp(0.2)
@test diff(f,(2,0))[SVector(0.1,0.2)] ≈ -cos(0.1*exp(0.2))*exp(0.4)
@test diff(f,(1,1))[SVector(0.1,0.2)] ≈ -sin(0.1*exp(0.2))*exp(0.2) - 0.1*cos(0.1*exp(0.2))*exp(0.4)
@test diff(f,(0,2))[SVector(0.1,0.2)] ≈ -0.1*sin(0.1*exp(0.2))*exp(0.2) - 0.1^2*cos(0.1*exp(0.2))*exp(0.4)
end

@testset "KronTrav bug" begin
W = Weighted(Ultraspherical(3/2))
D² = diff(W)'diff(W)
Expand Down
Loading