Support adding and subtracting Constant
#657
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Now that we have
UnitSum<...>in place, it has become straightforwardto get the labels we want.
The trickiest bit here is when the constant fully cancels additively.
Recall that we are grouping inputs according to the unscaled units
(roughly corresponding to "actual unit symbols"). When every unscaled
unit additively cancels individually, the result is zero. When we end
up with multiple unscaled units which nevertheless cancel together, we
represent that as-is, and don't try to cancel it, because this is also
how we handle input units in multiplication and division. But the
result is still not-a-unit! And we have the static assert from the
parent.
From an external user's point of view, we simply recommend that they
not try to form any
Constantthat additively cancels, regardless ofwhether it produces
Zeroor a compiler error. This is a weird thingto do that probably doesn't have any actual use cases. We already don't
support all combinations of inputs, and don't plan to, and this feels
like a safe "starter policy" at the very least.
Fixes #607.