Conversation
|
One option for It adds some allocations, but isn't too costly performance wise. |
|
Add a specialized |
|
That is here, it is when a BooleanAtom is part of an expression (like Basic(2)+True) that |
|
Oops, I hadn't pushed all the changes I had locally. What is there now is one way that booleans could be handled. |
src/numerics.jl
Outdated
| m = CMapBasicBasic() | ||
| m[True] = ONE; m[False] = ZERO |
There was a problem hiding this comment.
Can we make this map a global variable instead of creating it every time?
There was a problem hiding this comment.
I need your help with that. I was trying, but kept getting segfaults. The construction of Basic objects is a bit different than that of CMapBasicBasic, so I was having issue initializing the map in __init__.
One thing about what I have here that bothers me is I'd like to cheaply test if an expression has a BooleanAtom and then try to evaluate that expression after substitution with evalf, but it seemed easier to do the substitution and then compare the result to the original. I wasn't sure if substituting in a map with no matches would always return the original expression, as the test has that assumption.
There was a problem hiding this comment.
I just checked in what I thought I'd tried earlier and it seems to not cause an issue. I'll add a direct test to be sure.
In #260 a promote rule for
trueorfalseis setup. Currently this would promotetrueto a symbolic1andfalseto a symbolic0asBool <: Integer. This provides an alternatative by promoting to a symbolicTrueand symbolicFalse.I don't know which is a better choice, this is just meant to provide an option.
If this option is better, it might be nice to have some means to convert
TrueorFalseto 1 or 0 with theNfunction.