Skip to content

Commit 0bbdf26

Browse files
authored
sample on rectangles (#209)
* sample on rectangles * QuasiArrays v0.13 * Update ci.yml * Update Project.toml
1 parent d470905 commit 0bbdf26

File tree

5 files changed

+54
-11
lines changed

5 files changed

+54
-11
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
name: CI
22
on:
3-
- push
4-
- pull_request
3+
push:
4+
branches:
5+
- master
6+
paths-ignore:
7+
- 'LICENSE'
8+
- 'README.md'
9+
- '.github/workflows/TagBot.yml'
10+
pull_request:
11+
paths-ignore:
12+
- 'LICENSE'
13+
- 'README.md'
14+
- '.github/workflows/TagBot.yml'
515
jobs:
616
test:
717
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}

Project.toml

Lines changed: 15 additions & 6 deletions
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.9.3"
3+
version = "0.9.4"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
@@ -22,15 +22,20 @@ QuasiArrays = "c4ea9172-b204-11e9-377d-29865faadc5c"
2222
RecurrenceRelationships = "807425ed-42ea-44d6-a357-6771516d7b2c"
2323
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
2424
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
25-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
25+
26+
[weakdeps]
27+
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
28+
29+
[extensions]
30+
MultivariateOrthogonalPolynomialsStatsBaseExt = "StatsBase"
2631

2732
[compat]
2833
ArrayLayouts = "1.11"
2934
BandedMatrices = "1"
3035
BlockArrays = "1.0"
3136
BlockBandedMatrices = "0.13"
32-
ClassicalOrthogonalPolynomials = "0.15"
33-
ContinuumArrays = "0.19.5"
37+
ClassicalOrthogonalPolynomials = "0.15.8"
38+
ContinuumArrays = "0.20"
3439
DomainSets = "0.7"
3540
FastTransforms = "0.17"
3641
FillArrays = "1.0"
@@ -39,17 +44,21 @@ InfiniteArrays = "0.15"
3944
InfiniteLinearAlgebra = "0.9, 0.10"
4045
LazyArrays = "2.3.1"
4146
LazyBandedMatrices = "0.11.3"
42-
QuasiArrays = "0.12.2"
47+
QuasiArrays = "0.13"
48+
Random = "1"
4349
RecurrenceRelationships = "0.2"
4450
SpecialFunctions = "1, 2"
4551
StaticArrays = "1"
52+
StatsBase = "0.34"
4653
julia = "1.10"
4754

4855
[extras]
4956
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
5057
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
58+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
5159
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
60+
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
5261
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
5362

5463
[targets]
55-
test = ["Base64", "ForwardDiff", "RecipesBase", "Test"]
64+
test = ["Base64", "ForwardDiff", "Random", "RecipesBase", "StatsBase", "Test"]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module MultivariateOrthogonalPolynomialsStatsBaseExt
2+
using MultivariateOrthogonalPolynomials, StatsBase
3+
using MultivariateOrthogonalPolynomials.StaticArrays
4+
using MultivariateOrthogonalPolynomials.QuasiArrays
5+
using MultivariateOrthogonalPolynomials: ExpansionLayout, KronOPLayout
6+
import MultivariateOrthogonalPolynomials.QuasiArrays: sample_layout
7+
8+
function sample_layout(::ExpansionLayout{KronOPLayout{2}}, f::AbstractQuasiVector, n::Integer)
9+
F = reshape(f)
10+
x = sample(sum(F; dims=2), n)
11+
# x = sample(F[:,y]) # TODO: this should work
12+
y = [sample(F[x,:]) for x in x]
13+
map(SVector, x, y)
14+
end
15+
16+
sample_layout(lay::ExpansionLayout{KronOPLayout{2}}, f::AbstractQuasiVector) = only(sample_layout(lay, f, 1))
17+
18+
end

src/rect.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,4 @@ end
202202
function vec_layout(::KronExpansionLayout{OPLayout, OPLayout}, f)
203203
A,C,Bc = arguments(f)
204204
RectPolynomial(A, Bc') * DiagTrav(C)
205-
end
205+
end

test/test_rect.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
using MultivariateOrthogonalPolynomials, ClassicalOrthogonalPolynomials, StaticArrays, LinearAlgebra, BlockArrays, FillArrays, Base64, LazyBandedMatrices, ArrayLayouts, Test
1+
using MultivariateOrthogonalPolynomials, ClassicalOrthogonalPolynomials, StaticArrays, LinearAlgebra, BlockArrays, FillArrays, Base64, LazyBandedMatrices, ArrayLayouts, Random, StatsBase, Test
22
using ClassicalOrthogonalPolynomials: expand, coefficients, recurrencecoefficients
33
using MultivariateOrthogonalPolynomials: weaklaplacian, ClenshawKron
44
using ContinuumArrays: plotgridvalues, ExpansionLayout
55
using Base: oneto
66

7+
Random.seed!(3242)
8+
79
@testset "RectPolynomial" begin
810
@testset "Evaluation" begin
911
T = ChebyshevT()
@@ -161,7 +163,7 @@ using Base: oneto
161163
f = expand(P, splat((x,y) -> 1))
162164
@test diff(f,(1,0))[SVector(0.1,0.2)] == diff(f,(0,1))[SVector(0.1,0.2)] == 0.0
163165
f = expand(P, splat((x,y) -> x))
164-
@test diff(f,(1,0))[SVector(0.1,0.2)] == 1.0
166+
@test diff(f,(1,0))[SVector(0.1,0.2)] 1.0
165167
@test diff(f,(0,1))[SVector(0.1,0.2)] == 0.0
166168
f = expand(P, splat((x,y) -> cos(x*exp(y))))
167169
@test diff(f,(1,0))[SVector(0.1,0.2)] -sin(0.1*exp(0.2))*exp(0.2)
@@ -247,5 +249,9 @@ using Base: oneto
247249
F = reshape(f)
248250
@test sum(F; dims=1)[1,0.2] 2.346737615950585
249251
@test sum(F; dims=2)[0.1,1] 2.1748993079723618
252+
253+
x,y = coordinates(P)
254+
@test sample(f) isa SVector
255+
@test sum(sample(f, 100_000))/100_000 [sum(x .* f)/sum(f),sum(y .* f)/sum(f)] rtol=1E-1
250256
end
251257
end

0 commit comments

Comments
 (0)