Skip to content

Commit c512b22

Browse files
authored
derivative for normalized spaces (#171)
* derivative for normalized spaces * version bump to v0.6.14
1 parent a4729cc commit c512b22

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ApproxFunBase"
22
uuid = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"
3-
version = "0.6.13"
3+
version = "0.6.14"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
@@ -29,7 +29,7 @@ ToeplitzMatrices = "c751599d-da0a-543b-9d20-d0a503d91d24"
2929

3030
[compat]
3131
AbstractFFTs = "0.5, 1"
32-
ApproxFunOrthogonalPolynomials = "0.4"
32+
ApproxFunOrthogonalPolynomials = "0.4, 0.5"
3333
BandedMatrices = "0.16, 0.17"
3434
BlockArrays = "0.14, 0.15, 0.16"
3535
BlockBandedMatrices = "0.10, 0.11"

src/Operators/banded/CalculusOperator.jl

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ macro calculus_operator(Op)
5959
end
6060
end
6161

62-
$WrappOp(op::Operator,order) =
63-
$WrappOp{typeof(op),typeof(domainspace(op)),typeof(order),eltype(op)}(op,order)
62+
$WrappOp(op::Operator,d,order) =
63+
$WrappOp{typeof(op),typeof(d),typeof(order),eltype(op)}(op,order)
64+
$WrappOp(op::Operator,order) = $WrappOp(op, domainspace(op), order)
6465
$WrappOp(op::Operator) = $WrappOp(op,1)
6566

6667
function Base.convert(::Type{Operator{T}},D::$WrappOp) where T
@@ -181,16 +182,25 @@ function DefaultDerivative(sp::Space,k::Integer)
181182
# this is the normal default constructor
182183
csp=canonicalspace(sp)
183184
if conversion_type(csp,sp)==csp # Conversion(sp,csp) is not banded, or sp==csp
184-
error("Implement Derivative($(string(sp)),$k)")
185+
error("Implement Derivative(", sp, ",", k,")")
185186
end
186-
DerivativeWrapper(TimesOperator([Derivative(csp,k),Conversion(sp,csp)]),k)
187+
DerivativeWrapper(TimesOperator(Derivative(csp,k),Conversion(sp,csp)), sp, k)
187188
else
188-
D1=invfromcanonicalD(sp)*Derivative(setdomain(sp,canonicaldomain(sp)))
189-
D=DerivativeWrapper(SpaceOperator(D1,sp,setdomain(rangespace(D1),domain(sp))),1)
189+
csp = canonicalspace(sp)
190+
D1 = if csp == sp
191+
_Dsp = invfromcanonicalD(sp)*Derivative(setdomain(sp,canonicaldomain(sp)))
192+
rsp = rangespace(_Dsp)
193+
_Dsp
194+
else
195+
Dcsp = Derivative(csp)
196+
rsp = rangespace(Dcsp)
197+
Dcsp * Conversion(sp, csp)
198+
end
199+
D=DerivativeWrapper(SpaceOperator(D1,sp,setdomain(rsp,domain(sp))),1)
190200
if k==1
191201
D
192202
else
193-
DerivativeWrapper(TimesOperator(Derivative(rangespace(D),k-1),D),k)
203+
DerivativeWrapper(TimesOperator(Derivative(rangespace(D),k-1),D), sp, k)
194204
end
195205
end
196206
end

test/SpacesTest.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,16 @@ using StaticArrays
325325
@testset "Derivative" begin
326326
@test Derivative() == Derivative()
327327
for d in Any[(), (0..1,)]
328-
for ST in Any[Chebyshev, Legendre]
328+
for ST in Any[Chebyshev, Legendre,
329+
(x...) -> Jacobi(2,2,x...), (x...) -> Jacobi(1.5,2.5,x...)]
329330
S = ST(d...)
330-
@test Derivative(S) == Derivative(S)
331-
@test Derivative(S,2) == Derivative(S,2)
331+
@test Derivative(S) == Derivative(S,1)
332+
@test Derivative(S)^2 == Derivative(S,2)
333+
f = Fun(x->x^3, S)
334+
@test Derivative(S) * f Fun(x->3x^2, S)
335+
@test Derivative(S,2) * f Fun(x->6x, S)
336+
@test Derivative(S,3) * f Fun(x->6, S)
337+
@test Derivative(S,4) * f zeros(S)
332338
end
333339
end
334340
@test Derivative(Chebyshev()) != Derivative(Chebyshev(), 2)

0 commit comments

Comments
 (0)