JuliaApproximation / PiecewiseOrthogonalPolynomials.jl

A Julia package for piecewise spectral methods such as p-FEM
MIT License
5 stars 1 forks source link

Bug in Derivative #15

Closed ioannisPApapadopoulos closed 1 year ago

ioannisPApapadopoulos commented 1 year ago

@dlfivefifty I think there is a bug in Derivative(x) * ContinuousPolynomial{1}(r). E.g.

n = 5; r = range(0, 1; length=n+1) # solve on unit interval with n cells

C¹ = ContinuousPolynomial{1}(r) # hat functions and (1-x^2) * P_k^(1,1)(x)
C⁰ = ContinuousPolynomial{0}(r)

x = axes(C,1)
D = C⁰ \ (Derivative(x) * C¹)

# D[1,1] should be -5 not -0.5

I think M = BlockVcat(Hcat(Ones{T}(N) / 2, -Ones{T}(N) / 2), H) in line 241 of PiecewiseOrthogonalPolynomials.jl should be

M = BlockVcat(Hcat(Ones{T}(N) * (N-1), -Ones{T}(N) * (N-1)), H)

ioannisPApapadopoulos commented 1 year ago

happy to make a PR if you agree

dlfivefifty commented 1 year ago

I have no clue but it should be easy to write unit tests so make your changes with unit tests that fail under the current implementation and I'll merge