|
From: | Brad Bell |
Subject: | Re: Algorithmic Differentiation in Octave |
Date: | Fri, 27 Jan 2017 13:47:49 -0700 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 |
On 01/27/2017 01:20 PM, Olaf Till wrote: ... snip ...
Still can't see it... Say we have matrices A:=[a11, a12; a21, a22] and B:=[b11, b12; b21, b22], both A and B somehow depending on a vector of a_double. If we overload matrix multiplication (normally done symply by typing A*B in Octave), to make it recordable, into scalar operations, we compute C:=A*B as c11=a11*b11+a12*b21, c12=a11*b12+a12*b22, c21=..., c22=... . We have to return the zero order result, so we concatenate c11, ..., c22 into a Matrix C e.g. with the Octave command C=[c11, c12; c21, c22], and let the overloaded method return C. Since all computed c.. should be of type a_vector, the operation should have been recorded by cppad. But if we run the record to get the derivatives, in which form will they be returned? cppad has only records for the four single values c11, ..., c22, it doesn't know that they belong together ... or what? If you correct the above, please be detailed, so that I can understand it although I'm not familiar with cppad. Olaf
There are two separate steps. One is the recording of function evaluation to create an AD function object. The second is using the function object to evaluate derivatives (of any order including order zero which is function values).
The function gets recorded by:1. first declaring the independent variables, say the vector ax. I use ax to denote the fact that its elements have type a_double. 2. Performing Operations to eventually get the vector of dependent varialbes ay.
3. Stopping the recording and declaring that the function maps ax -> ay.For example, suppose that we have overloaded matrix multiplication for a_double and we enter
ax = m_cppad.independent(x) A = [ ax(0), ax(1) ; ax(2), ax(3) ] B = A * A ay=m_cppad.vec_a_double(4) ay(0)=B(1,1) ay(1)=B(1,2) ay(2)=B(2,1) ay(3)=B(2,2) af = m_cppad.a_fun(ax, ay)Then the function mapping x to y (which uses matrix multiplication in its definition) would have been recorded in the function object af.
Does this help ?
[Prev in Thread] | Current Thread | [Next in Thread] |