# ifndef CPPAD_EXAMPLE_CODE_GEN_FUN_HPP # define CPPAD_EXAMPLE_CODE_GEN_FUN_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-20 Bradley M. Bell CppAD is distributed under the terms of the Eclipse Public License Version 2.0. This Source Code may also be made available under the following Secondary License when the conditions for such availability set forth in the Eclipse Public License, Version 2.0 are satisfied: GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ // BEGIN C++ # include class code_gen_fun { public: // type of evaluation for Jacobians (possibly Hessians in the future) enum evaluation_enum { none_enum, dense_enum, sparse_enum }; private: // dynamic_lib_ std::unique_ptr< CppAD::cg::DynamicLib > dynamic_lib_; // // model_ (contains a reference to dynamic_lib_) std::unique_ptr< CppAD::cg::GenericModel > model_; // public: // ----------------------------------------------------------------------- // constructors // ----------------------------------------------------------------------- // fun_name() code_gen_fun(void); // // fun_name( file_name ) code_gen_fun(const std::string& file_name); // // fun_name(file_name, cg_fun, eval_jac) code_gen_fun( const std::string& file_name , CppAD::ADFun< CppAD::cg::CG >& cg_fun , evaluation_enum eval_jac = none_enum ); // ----------------------------------------------------------------------- // operations // ----------------------------------------------------------------------- // swap(other_fun) void swap(code_gen_fun& other_fun); // // y = fun_name(x) CppAD::vector operator()(const CppAD::vector & x); // // J = fun_name.jacobian(x) CppAD::vector jacobian(const CppAD::vector & x); // // Jrcv = fun_name.sparse_jacobian(x) CppAD::sparse_rcv< CppAD::vector, CppAD::vector > sparse_jacobian(const CppAD::vector& x); }; // END C++ # endif