Open dpsanders opened 4 months ago
Ah that's because
julia> zero(emptyinterval())
[0.0, 0.0]_com
I have an idea for how to make a default 0 value.
This version works:
function (piecewise::Piecewise)(X::Interval)
return reduce(hull, begin
val = intersect_interval(X, region)
isempty_interval(val) ? val : f(val)
end
for (region, f) ∈ piecewise.pieces)
end
H = Piecewise(-Inf..0 => zero, 0..Inf => one)
It would probably be worth having a PiecewiseConstant
too.
We also need to add the decoration of course.
This issue seems to supersede #653 and #654 no?
Also, with such a feature, implementing the Heaviside function would be even simpler than it already is so I am not sure it would warrant being defined inside the library.
Here's a possible implementation for piecewise functions:
Then Heaviside should be definable with
but that is not working for me right now 🤔 E.g. it gives
whereas it should give
[1, 1]
.