Conversation
|
This is quite an odd construction, but it makes sense to me. It seems like it should address the current issues with building piecewise functions, and allow users to plug up holes in functions that might otherwise be problematic. It seems like it might be worth making utility functions using these operators ( Overall, I like this and think it solves the problem. |
e804922 to
6dc5ea7
Compare
|
@Wulfsta Now that this is merged, adding helper functions to |
|
I am on vacation at the moment, but would be happy to add this when I am back. It will probably be a week or so until I am able to work on this. Edit: Got bored, wrote code. |
|
@mkeeter I was just thinking about an edge case; what happens if both |
|
Aha! I think this can be avoided entirely with |
Isn't returning e.g. phrasing it as a conditional I would expect this to return |
|
Continuing in #64. |
This implements an `if_nonzero_else` helper function as implied in #58.
This PR adds
AND,OR, andNOTopcodes.These operations are designed for basically one purpose: making conditionals of the form
(cond && a) || (!cond && b). As such, they have the following semantics:a && b ⇒ if a == 0.0 { a } else { b }a || b ⇒ if a != 0.0 { a } else { b }The operators are also designed to work well with tape simplification (through the
TracingEvaluator): ifcondis unambiguously0.0or unambiguously non-zero, then the conditional statement can be collapsed into eitheraorb.(marked as a Draft because I still need to turn the crank on JIT implementations)