|
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 |
2 | 2 | using ClassicalOrthogonalPolynomials: expand, coefficients, recurrencecoefficients |
3 | 3 | using MultivariateOrthogonalPolynomials: weaklaplacian, ClenshawKron |
4 | 4 | using ContinuumArrays: plotgridvalues, ExpansionLayout |
5 | 5 | using Base: oneto |
6 | 6 |
|
| 7 | +Random.seed!(3242) |
| 8 | + |
7 | 9 | @testset "RectPolynomial" begin |
8 | 10 | @testset "Evaluation" begin |
9 | 11 | T = ChebyshevT() |
@@ -161,7 +163,7 @@ using Base: oneto |
161 | 163 | f = expand(P, splat((x,y) -> 1)) |
162 | 164 | @test diff(f,(1,0))[SVector(0.1,0.2)] == diff(f,(0,1))[SVector(0.1,0.2)] == 0.0 |
163 | 165 | 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 |
165 | 167 | @test diff(f,(0,1))[SVector(0.1,0.2)] == 0.0 |
166 | 168 | f = expand(P, splat((x,y) -> cos(x*exp(y)))) |
167 | 169 | @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 |
247 | 249 | F = reshape(f) |
248 | 250 | @test sum(F; dims=1)[1,0.2] ≈ 2.346737615950585 |
249 | 251 | @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 |
250 | 256 | end |
251 | 257 | end |
0 commit comments