-
Notifications
You must be signed in to change notification settings - Fork 73
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
du failing on simple function #38
Comments
(I understand that |
Prelude Numeric.AD> :t du
du
:: (Num a, Functor f) =>
(forall s.
f (AD s (Numeric.AD.Internal.Forward.Forward a))
-> AD s (Numeric.AD.Internal.Forward.Forward a))
-> f (a, a) -> a if your function had the type foo :: Num a => [a]-> a
foo [x,y]= x*y then everything works fine Prelude Numeric.AD> let foo [x,y]= x*y
Prelude Numeric.AD> du foo [(1,0),(2,8)]
8 |
Are you suggesting that perhaps every value thats not wrapped in a Functor should be considered to be implicitly lifted into the identity functor? Thats what it sounds like, But in that case |
I guess that's one way to think about it. In more mathematical terms, the "tangent space" is always a vector space. I directional derivative maps a point on the input tangent space to the output tangent space. Which is clean and unified. Having the tangent spaces come in different "shapes" with different derivative-taking operators to deal with them depending on shape is sort of annoying. And worse, we could have something like
which makes complete sense to take a directional derivative of, but which doesn't fit into any of our cases. |
false, it fits in that regime like so Prelude Numeric.AD> :t duF
duF
:: (Num a, Functor g, Functor f) =>
(forall s.
f (AD s (Numeric.AD.Internal.Forward.Forward a))
-> g (AD s (Numeric.AD.Internal.Forward.Forward a)))
-> f (a, a) -> g a just writing down the defn for duF for now
this |
Or maybe I'm not understanding what you mean by directional derivative! |
what would a direction derive look like in that context/example? I'm imagining it being semantically equivalent to a big flattened version of a list |
I frankly don't see a plausible way to do unify these things. Yes, types get in the way some times, and in this case they force a distinction. You could argue that To go far enough to get you what you want we have to throw out the entire numeric tower, because That isn't happening, not with keeping any users. |
The only way this is going to change is if we adopt something like #2, which would have pretty far reaching consequences on the API. I'll leave this issue open as a sort of adjunct / example for that one. |
We could use fancy types, let the type constraint (Naturally this would need an API, the obvious one would be |
Losing access to AD over arbitrary Num types isn't really an option. A number of the users of this library use it at some pretty exotic types! You can avoid the base case issue by doing what we do with the The problem is I don't think the technique you propose and having the rank-2 guard against infinitesimal confusion can't work together. There isn't a regular 'place' in the type for the region/infinitesimal parameter, as it is changing position all over the place moving under more functors layers, etc. |
Wouldn't that "brand" type go in the constraint but not the instance, so it could be the same in the various constraints on the LHS of the instance declaration. (With the appropriate extension enabled.) |
The "brand" can't float in the constraint without actually showing up in a type somewhere. You could almost kind of fake it with implicit parameters, but then they'd yield totally bogus results when it comes to 'diff of diff', rather than just making you insert autos to get it to compile. |
The directional derivative operator
du
doesn't seem to handle the simplest case.The text was updated successfully, but these errors were encountered: