jacobian :: (Traversable f, Functor g, Num a) => (forall s. Reifies s Tape => f (Reverse s a) -> g (Reverse s a)) -> f a -> g (f a)

 Thanks a lot for your help

Jonas BÉAL

On 17 August 2016 at 10:40, Jonas Béal <jonas.beal@novadiscovery.com> wrote:
Hello,

I have some questions about the Automatic Differentiation package in Haskell (https://hackage.haskell.org/package/ad-4.3.2.1/docs/Numeric-AD.html)
I need to compute the jacobian with that method and I have a type problem, here a simplified example in order to focus on the error:

According to documentation I need to write "jacobian function values". So I built the input function. Please notice this is important for me that my function may depend on an external parameter (named factor here)
testFunctionForJacobian :: Fractional a => a -> [a] -> [a]
testFunctionForJacobian factor inputs = [(sum inputs) * factor]

Then, using jacobian function of Numeric.AD in terminal, as a test, it works perfectly
>jacobian (testFunctionForJacobian 2) [1,2]
< [[2.0,2.0]]

No apparent type problem here 
> :t (testFunctionForJacobian 2)
(testFunctionForJacobian 2) :: Fractional a => [a] -> [a]

But, I would like to insert that in a bigger function computing the jacobian
testJacobian :: Fractional a => a -> [a] -> [[a]]
testJacobian factor inputs = jacobian (testFunctionForJacobian factor) inputs

This time it generates an error message about factor
Couldn't match expected type ‘Numeric.AD.Internal.Reverse.Reverse s a’ with actual type ‘a’
‘a’ is a rigid type variable bound by the type signature for
testJacobian :: Fractional a => a -> [a] -> [[a]] s a’

All in all, my type seems implicitly correct in the terminal example but I did not manage to write it explicitly in my function.

Here the jacobian function signature to help you answer me: 






--
Jonas Béal



--
Jonas Béal
R&D Scientist Intern
jonas.beal@novadiscovery.com
Novadiscovery
The Effect Model Co.
www.novadiscovery.com
+33 9 72 53 13 00
Bioparc Laënnec, 60 avenue Rockefeller, 69008 Lyon

This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice.