-
Notifications
You must be signed in to change notification settings - Fork 89
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
Non-associative number types #594
Comments
Would a trait system identifying numerical types as being commutative/associative/etc. be tractable to solve this? |
To elaborate: I'm not familiar with just how many rules require commutativity/associativity, but the properties are inferrable at the type level. Checks like Depending on how many rules require these properties, it might start to built up a large amount of boilerplate. Is there a technical reason to avoid asserting the presence of properties? |
Asserting the behavour is less useful than dispatching on the behavour. |
And asserting the properties is better than just assuming everything is commutative, because at least an error is thrown instead of derivatives being silently wrong.
#540 should give a sense for how many rules assume commutativity. And most rules with a product assume associativity, so such an assertion would basically ensure that no ChainRules-compatible AD can handle such number types, even as a collection of real numbers, without the package reimplementing a lot of our rules. Which would be unfortunate. |
I was recently reminded that some number types are not even associative under multiplication, e.g.
Quaternions.Octonion
. So fixes like #504, #540, which would support numbers that don't commute under multiplication, like quaternions, would still do the wrong thing for octonions. On the other hand, there are number types likeUnitful.Quantity
, which areNumber
s, for which we want our rules to work.So I see 2 ways forward:
The text was updated successfully, but these errors were encountered: