Skip to content

generate c source code to compute Jacobian using parameters #191

Answered by bradbell
metab0t asked this question in Q&A
Discussion options

You must be logged in to vote

I think this is what you want, please check the results and see that it works for you.

#include <iostream>        // standard input/output
#include <cppad/cppad.hpp> // the CppAD package

// main program
int main(void)
{
   using CppAD::AD;
   using CppAD::ADFun;
   using CppAD::Independent;

   size_t n = 1;
   size_t m = 1;
   size_t k = 1;
   CPPAD_TESTVECTOR(AD<double>) ax(n), ay(m), ap(k);
   ap[0] = AD<double>(4.0);
   Independent(ax, ap);
   ay[0] = ap[0] * ax[0] * ax[0];
   ADFun<double> f(ax, ay);
   ADFun<AD<double>, double> af = f.base2ad();

   CPPAD_TESTVECTOR( AD<double> ) axp(n + k);
   Independent(axp);
   for(size_t j = 0; j < n; ++j)
      ax[j] = axp[j];
   for(size_t j…

Replies: 4 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@metab0t
Comment options

Comment options

You must be logged in to vote
3 replies
@metab0t
Comment options

@metab0t
Comment options

@a-jp
Comment options

Answer selected by metab0t
Comment options

You must be logged in to vote
1 reply
@a-jp
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants