-
-
Notifications
You must be signed in to change notification settings - Fork 232
Description
A short recap of slack discussion: currently, we have Expression <: Number
, however, if a generic function is defined on Real
, this won't "just work".
The simplest fix as proposed by @ChrisRackauckas is to move Expression <: Real
. However, this will fail if there are symbolic complex numbers (which is also crucial in Yao's case). In fact, I believe we will need some kind of domain inference/ types to represent domains instead of letting the IR expression to handle it.
My proposal is to separate the IR with domain types, which mean Expression
will not be subtype of Real
nor Number
, we will have a wrap type to help the dispatch, which can just be
struct SymReal <: Real
data
end
where data can be Expression
or Variable
or other things that is defined as real number or inferred as real number and same for complex number and other kind of numbers or even matrices, linear maps etc. I'm trying out this idea in my toy symbolic engine, I'll make that public soon.
This is actually a similar idea with Tracker
, the implementation of TrackedReal
looks like following:
struct TrackedReal{T} <: Real
tape::Tracked
data::T
end
Update: I implemented some of my ideas here Sym.jl