Skip to content

Commit

Permalink
close issue #30
Browse files Browse the repository at this point in the history
  • Loading branch information
jverzani committed Nov 7, 2020
1 parent 38ff561 commit 95e94b0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/predicates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ To negate a predicate, `!` is used.
"""
mutable struct Pred <: Predicate
f::Function
f
op
val
end
Expand All @@ -46,25 +46,25 @@ preds = [(:Lt, :≪, :<), # \ll
for (fn, uop, op) in preds
fnname = string(fn)
@eval begin
($fn)(f::Function, x::Real) = Pred(f, $op, x)
($uop)(f::Function, x::Real) = ($fn)(f, x)
($fn)(f::Function, g::Function) = $(fn)((x,y) -> f(x,y) - g(x,y), 0)
($uop)(f::Function, g::Function) = ($fn)(f, g)
($fn)(f, x::Real) = Pred(f, $op, x)
($uop)(f, x::Real) = ($fn)(f, x)
($fn)(f, g) = $(fn)((x,y) -> f(x,y) - g(x,y), 0)
($uop)(f, g) = ($fn)(f, g)
end
eval(Expr(:export, fn))
eval(Expr(:export, uop))
end

Neq(f::Function, x::Real) = Pred(f, !== , x)
Neq(f::Function, g::Function) = Neq((x,y) -> f(x,y) - g(x,y), 0)
Neq(f, x::Real) = Pred(f, !== , x)
Neq(f, g) = Neq((x,y) -> f(x,y) - g(x,y), 0)

(x::Real, y::Real) = (x != y)
(f::Function, x::Real) = Neq(f, x)
(f::Function, g::Function) = Neq(f, g)
(f, x::Real) = Neq(f, x)
(f, g) = Neq(f, g)

(x::Real, y::Real) = (x != y)
(f::Function, x::Real) = Neq(f, x)
(f::Function, g::Function) = Neq(f, g)
(f, x::Real) = Neq(f, x)
(f, g) = Neq(f, g)



Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ ImplicitEquations.GRAPH(Neq(f, g), -5, 5, -5, 5, 2^4, 2^4)

ImplicitEquations.GRAPH(Eq(f, g), -5, 5, -5, 5, 2^4, 2^4)
ImplicitEquations.GRAPH(f g, -5, 5, -5, 5, 2^4, 2^4)


# Issue #30: relax assumptions in predicates
struct F end
(::F)(x,y) = x^2 + y^2
ImplicitEquations.GRAPH(f 0, -5, 5, -5, 5, 2^4, 2^4)

0 comments on commit 95e94b0

Please sign in to comment.