Skip to content

Commit f9bab60

Browse files
authored
Backport: Implement calculus operations for ConstantSpace (#597)
1 parent c398dc9 commit f9bab60

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Spaces/ConstantSpace.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ choosedomainspace(M::ConcreteMultiplication{D,UnsetSpace},sp::Space) where {D<:C
254254
Base.isfinite(f::Fun{CS}) where {CS<:ConstantSpace} = isfinite(Number(f))
255255

256256

257+
## Calculus
257258

258-
259-
260-
259+
integrate(f::Fun{<:ConstantSpace{<:IntervalOrSegment}}) = Number(f) * Fun(domain(f))
260+
differentiate(f::Fun{<:ConstantSpace{<:IntervalOrSegment}}) = zero(f)

test/SpacesTest.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ using LinearAlgebra
309309
@test g > f
310310
@test g >= f
311311
@test 1 < f < 3
312+
@test differentiate(f) == Fun(0, ConstantSpace(0..1))
312313

313314
@test maxspace(ConstantSpace(Point(1)), ConstantSpace(Point(2))) == ConstantSpace(Point(1) Point(2))
314315
@test maxspace(ConstantSpace(Point(1)), ConstantSpace(AnyDomain())) == ConstantSpace(Point(1))

0 commit comments

Comments
 (0)