Skip to content

Commit b079800

Browse files
authored
sum for RectPolynomial (#191)
* sum for RectPolynomial * Update ci.yml * Update multivariatelanczos.jl
1 parent a2bcf53 commit b079800

File tree

5 files changed

+49
-2
lines changed

5 files changed

+49
-2
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
version:
13-
- '1.10'
13+
- 'lts'
14+
- '1'
1415
os:
1516
- ubuntu-latest
1617
- windows-latest

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "MultivariateOrthogonalPolynomials"
22
uuid = "4f6956fd-4f93-5457-9149-7bfc4b2ce06d"
3-
version = "0.7.1"
3+
version = "0.7.2"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

examples/multivariatelanczos.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using MultivariateOrthogonalPolynomials, ClassicalOrthogonalPolynomials, Test
2+
3+
P = Legendre()
4+
= RectPolynomial(P,P)
5+
p₀ = expand(P², 𝐱 -> 1)
6+
𝐱 = axes(P²,1)
7+
x,y = first.(𝐱),last.(𝐱)
8+
w =/\ (x-y).^2
9+
10+
w .* p₀
11+
12+
13+
sum(p₀)
14+
using LazyBandedMatrices
15+
KronTrav(sum(P;dims=1), sum(P;dims=1))
16+
17+
T = ChebyshevT()
18+
U = ChebyshevU()
19+
KronTrav(sum(T;dims=1), sum(Jacobi(1,1);dims=1))
20+
21+
22+
23+
x = axes(P,1)
24+
X = zeros(∞,∞); X[1,1] = 1;
25+
p₀ = P*X*P'
26+
@test sum(p₀) == 4
27+
28+
sum(x.^2 .* p₀)
29+
30+
P\F/P'

src/rect.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,11 @@ function transform_ldiv(K::KronPolynomial{d,V,<:Fill{<:Legendre}}, f::Union{Abst
163163
dat = (T \ f).array
164164
DiagTrav(pad(FastTransforms.th_cheb2leg(paddeddata(dat)), axes(dat)...))
165165
end
166+
167+
168+
## sum
169+
170+
function Base._sum(P::RectPolynomial, dims)
171+
@assert dims == 1
172+
KronTrav(sum.(P.args; dims=1)...)
173+
end

test/test_rect.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,12 @@ using ContinuumArrays: plotgridvalues
138138
@test x == SVector.(ChebyshevGrid{2}(40), ChebyshevGrid{2}(40)')
139139
@test F == ones(40,40)
140140
end
141+
142+
@testset "plot" begin
143+
P = RectPolynomial(Legendre(),Legendre())
144+
p₀ = expand(P, 𝐱 -> 1)
145+
@test sum(p₀) 4.0
146+
f = expand(P, splat((x,y) -> exp(cos(x^2*y))))
147+
@test sum(f) 10.546408460894801 # empirical
148+
end
141149
end

0 commit comments

Comments
 (0)