Changeset 763 for trunk/ADOLC/doc/adolcmanual.tex
 Timestamp:
 Dec 18, 2018 11:29:51 AM (3 months ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/ADOLC/doc/adolcmanual.tex
r762 r763 2925 2925 In the former case one may want to differentiate the parts in 2926 2926 question with a different AD tool or provide hand written derivatives. 2927 To integrate these2928 2927 In practice, however, sophisticated projects usually evolve over a long period of time. 2929 2928 Within this process, a heterogeneous code base for the project … … 2933 2932 Hence, different \mbox{ADtools} may be combined with handderived 2934 2933 codes based on the same or different programming languages. 2935 ADOLC supports such settings bythe concept of externally2934 ADOLC supports such settings by the concept of externally 2936 2935 differentiated functions, that is, a function 2937 2936 not differentiated by ADOLC itself. The required derivatives … … 2939 2938 2940 2939 For this purpose, it is required that the externally differentiated 2941 function (for example named {\sf\em euler\_step} ) has the following signature .2940 function (for example named {\sf\em euler\_step} ) has the following signature 2942 2941 \smallskip 2943 2942 2944 2943 \noindent 2945 \hspace*{2cm}{\sf int euler\_step(int n, double *x, int m, double *y);} 2944 \hspace*{2cm}{\sf int euler\_step(int n, double *x, int m, double *y);} . 2946 2945 \medskip 2947 2946 2948 2947 \noindent 2949 Note that the formal para emters in the signature have {\sf double} type, that is,2948 Note that the formal paramters in the signature have {\sf double} type, that is, 2950 2949 they are not active as in the original program before the ADOLC type change. 2951 2950 The externally differentiated function has to 2952 be {\em registered}\footnote{we record the function pointer} using an \mbox{ADOLC} method as follows .2951 be {\em registered}\footnote{we record the function pointer} using an \mbox{ADOLC} method as follows 2953 2952 \smallskip 2954 2953 2955 2954 \noindent 2956 \hspace*{2cm}{\sf ext\_diff\_fct *edf = reg\_ext\_fct(euler\_step);} .2955 \hspace*{2cm}{\sf ext\_diff\_fct *edf = reg\_ext\_fct(euler\_step);} . 2957 2956 \smallskip 2958 2957 2959 2958 \noindent 2960 2959 This returns a pointer to an {\sf ext\_diff\_fct} instance specific to the registered function. 2961 Then, the user has to supply the function pointers for the call 2960 Then, the user has to supply the function pointers for the callback methods (for example here 2962 2961 {\sf zos\_for\_euler\_step} and {\sf fos\_rev\_euler\_step}) the user implemented 2963 to compute the derivatives as follows .2962 to compute the derivatives as follows: 2964 2963 \begin{tabbing} 2965 2964 \hspace*{2cm}\= {\sf edf$>$zos\_forward = {\em zos\_for\_euler\_step};}\\ … … 2977 2976 To facilitate the switch between active and passive versions of the parameters {\sf x} and {\sf y} 2978 2977 one has to provide (allocate) both variants. I.e. if the call to {\sf euler\_step} was originally 2978 \smallskip 2979 2979 2980 \noindent 2980 2981 \hspace*{2cm}{\sf rc=euler\_step(n, sOld, m, sNew);} 2981 2982 \medskip 2983 2984 \noindent 2982 2985 then the ADOLC typechange for the calling context will turn {\sf sOld} and {\sf sNew} in {\sf adouble} pointers. 2983 2986 To trigger the appropriate action for the derivative computation (i.e. creating an external differentiation entry on the trace) 2984 2987 the original call to the externally differentiated function 2985 2988 must be substituted by 2986 \ medskip2989 \smallskip 2987 2990 2988 2991 \noindent 2989 \hspace*{2cm}{\sf rc=call\_ext\_fct(edf, n, sOldPassive, sOld, m, sNewPassive, sNew);} 2992 \hspace*{2cm}{\sf rc=call\_ext\_fct(edf, n, sOldPassive, sOld, m, sNewPassive, sNew);} . 2990 2993 \medskip 2991 2994 … … 2996 2999 example \verb=ext_diff_func= contained in 2997 3000 \verb=examples/additional_examples/ext_diff_func=. 2998 There, the external differentiated function is also a C code, but the2999 handling as external differentiated function s also a decrease ofthe3001 There, the external differentiated function is also a C code, but the 3002 handling as external differentiated function decreases the 3000 3003 overall required tape size. 3001 3004
Note: See TracChangeset
for help on using the changeset viewer.