-
Notifications
You must be signed in to change notification settings - Fork 178
Make D(const) error #1279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make D(const) error #1279
Conversation
|
Since I also stumbled about this: does it even make sense to derive with respect to a constant? Shouldn't it be considered an error? See for example this answer for an arguments why those derivatives shouldn't exist. |
|
Yeah, it shouldn't be zero it should just be an error. We should add that error. |
This fixes an odd bug that can occur when a constant can match, like `Differential(2)(2x) == x`, when it should obviously be zero. This fixes Differential(number) == ZeroOperator which acts like a hard zero. You need ZeroOperator instead of 0 because otherwise you codegen to stuff like 0(2x) and get an error that 0 does not have a call, and `zero` the function does not do things like `zero * zero` appropriately, so constructing a simple operator that acts like a true zero is the simplest solution that enforces the safety.
Yes. An error would probably have helped me to find the reason for the failing MWE from PR #1511 earlier. |
|
If it makes sense to you I can add that check to PR #1511. |
0a2643a to
b964f70
Compare
|
I just rebased this PR to add an error for it. We could also error earlier, we might need to in some cases error in the derivative expansion. |
This fixes an odd bug that can occur when a constant can match, like
Differential(2)(2x) == x, when it should obviously be zero. This fixes Differential(number) == ZeroOperator which acts like a hard zero. You need ZeroOperator instead of 0 because otherwise you codegen to stuff like 0(2x) and get an error that 0 does not have a call, andzerothe function does not do things likezero * zeroappropriately, so constructing a simple operator that acts like a true zero is the simplest solution that enforces the safety.Edit: Differential(1) => error.