build(CppAD): brought in CppAD for autodiff

we need an autodiff library at some point (or we need to roll our own but I do not think that makes sense). CppAD is well tested and header only and easy to include. It is also Liscene compatible with GPL v3.0. Here we bring it in as a dependency
This commit is contained in:
2025-06-19 14:51:02 -04:00
parent 76662db03e
commit 856ab51b4c
367 changed files with 108392 additions and 0 deletions

View File

@@ -0,0 +1,386 @@
# ifndef CPPAD_LOCAL_GRAPH_CPP_GRAPH_ITR_HPP
# define CPPAD_LOCAL_GRAPH_CPP_GRAPH_ITR_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.
---------------------------------------------------------------------------- */
# include <cppad/utility/vector.hpp>
# include <cppad/local/graph/cpp_graph_op.hpp>
// BEGIN_CPPAD_LOCAL_GRAPH_NAMESPACE
namespace CppAD { namespace local { namespace graph {
class cpp_graph_itr {
/*
$begin cpp_graph_itr_data$$
$spell
Iterator
$$
$section C++ AD Graph Iterator Private Member Data$$
$srccode%hpp% */
private:
// valuse set by constructor
const vector<graph_op_enum>* operator_vec_;
const vector<size_t>* operator_arg_;
//
// set by constructor and ++
size_t op_index_;
size_t first_arg_;
//
// set by get_value
size_t first_node_;
graph_op_enum op_enum_;
vector<size_t> str_index_;
size_t n_result_;
vector<size_t> arg_node_;
/* %$$
$end
------------------------------------------------------------------------------
$begin cpp_graph_itr_get_value$$
$spell
obj
op
arg
vec
enum
Iterator
itr
str
$$
$section C++ AD Graph Iterator get_value()$$
$head Syntax$$
$icode%itr%.get_value()%$$
$head op_index_$$
This input is the operator index for the value we are retrieving.
$head first_arg_$$
This input is the first argument index for the value we are retrieving.
$head first_node_$$
The input value of this argument does not matter.
It is set to the index in $code operator_arg_$$
of the first node argument for this operator.
$head op_enum_$$
The input value of this argument does not matter.
It is set to the $cref graph_op_enum$$ for the operator
$head str_index_$$
The input value of this argument does not matter.
Upon return its size is zero except for the special cases
listed below:
$subhead atom_graph_op$$
If $icode op_enum_$$ is $code atom_graph_op$$,
$code str_index_.size() == 1$$ and
$code str_index_[0]$$ is the index in
$cref/atomic_name_vec/cpp_ad_graph/atomic_name_vec/$$
for the function called by this operator.
$subhead discrete_graph_op$$
If $icode op_enum_$$ is $code discrete_graph_op$$,
$code str_index_.size() == 1$$ and
$code str_index_[0]$$ is the index in
$cref/discrete_name_vec/cpp_ad_graph/discrete_name_vec/$$
for the function called by this operator.
$subhead print_graph_op$$
If $icode op_enum_$$ is $code print_graph_op$$,
$code str_index_.size() == 2$$ and
$code str_index_[0]$$ ( $code str_index_[1]$$ )
is the index in
$cref/print_text_vec/cpp_ad_graph/print_text_vec/$$ for the
$cref/before/PrintFor/before/$$ ($cref/after/PrintFor/after/$$) text.
$head n_result_$$
The input value of this argument does not matter.
This is set to the number of result nodes for this operator.
$head arg_node_$$
The input value of this argument does not matter.
Upon return, its size is the number of arguments,
that are node indices, for this operator usage.
The value of the elements are the node indices.
$head Prototype$$
$srccode%hpp% */
void get_value(void)
/* %$$
$end
*/
{ // initialize output values
size_t invalid_index = std::numeric_limits<size_t>::max();
size_t n_arg = invalid_index;
first_node_ = invalid_index;
n_result_ = invalid_index;
str_index_.resize(0);
arg_node_.resize(0);
//
// op_enum
op_enum_ = (*operator_vec_)[op_index_];
//
// n_result_, n_arg, str_index_
switch( op_enum_ )
{
// unary operators
case abs_graph_op:
case acos_graph_op:
case acosh_graph_op:
case asin_graph_op:
case asinh_graph_op:
case atan_graph_op:
case atanh_graph_op:
case cos_graph_op:
case cosh_graph_op:
case erf_graph_op:
case erfc_graph_op:
case exp_graph_op:
case expm1_graph_op:
case log1p_graph_op:
case log_graph_op:
case sign_graph_op:
case sin_graph_op:
case sinh_graph_op:
case sqrt_graph_op:
case tan_graph_op:
case tanh_graph_op:
first_node_ = first_arg_;
n_result_ = 1;
n_arg = 1;
break;
// binary operators
case add_graph_op:
case azmul_graph_op:
case div_graph_op:
case mul_graph_op:
case pow_graph_op:
case sub_graph_op:
first_node_ = first_arg_;
n_result_ = 1;
n_arg = 2;
break;
// discrete_graph_op
case discrete_graph_op:
first_node_ = first_arg_ + 1;
str_index_.push_back( (*operator_arg_)[first_node_ - 1] );
n_result_ = 1;
n_arg = 1;
break;
// atom_graph_op
case atom_graph_op:
first_node_ = first_arg_ + 3;
str_index_.push_back( (*operator_arg_)[first_node_ - 3] );
n_result_ = (*operator_arg_)[first_node_ - 2];
n_arg = (*operator_arg_)[first_node_ - 1];
break;
// print_graph_op
case print_graph_op:
first_node_ = first_arg_ + 2;
str_index_.push_back( (*operator_arg_)[first_node_ - 2] );
str_index_.push_back( (*operator_arg_)[first_node_ - 1] );
n_result_ = 0;
n_arg = 2;
break;
// conditional expressions
case cexp_eq_graph_op:
case cexp_le_graph_op:
case cexp_lt_graph_op:
first_node_ = first_arg_;
n_result_ = 1;
n_arg = 4;
break;
// comparison operators
case comp_eq_graph_op:
case comp_le_graph_op:
case comp_lt_graph_op:
case comp_ne_graph_op:
first_node_ = first_arg_;
n_result_ = 0;
n_arg = 2;
break;
// sum_graph_op
case sum_graph_op:
first_node_ = first_arg_ + 1;
n_result_ = 1;
n_arg = (*operator_arg_)[first_node_ - 1];
break;
default:
CPPAD_ASSERT_UNKNOWN(false);
break;
}
// set arg_node
arg_node_.resize(n_arg);
for(size_t i = 0; i < n_arg; i++)
arg_node_[i] = (*operator_arg_)[first_node_ + i];
return;
}
/* %$$
$end
-------------------------------------------------------------------------------
$begin cpp_graph_itr_types$$
$spell
Iterator
$$
$section C++ AD Graph Iterator Types$$
$srccode%hpp% */
public:
typedef struct {
graph_op_enum op_enum;
const vector<size_t>* str_index_ptr;
size_t n_result;
const vector<size_t>* arg_node_ptr;
} value_type;
typedef std::input_iterator_tag iterator_category;
/* %$$
$end
------------------------------------------------------------------------------
$begin cpp_graph_itr_ctor$$
$spell
Iterator
itr
vec
arg
op
cpp
$$
$section C++ AD Graph Iterator Constructors$$
$head Syntax$$
$codei%cpp_graph_itr %default%
%$$
$codei%cpp_graph_itr %itr%(%operator_vec%, %operator_arg%, %op_index%
%$$
$head Prototype$$
$srcthisfile%
0%// BEGIN_CTOR%// END_CTOR%1
%$$
$head default$$
The result of the default constructor can only be used as a target
for the assignment operator.
$head operator_vec$$
Is the $cref/operator_vec/cpp_ad_graph/operator_vec/$$
for the $code cpp_graph$$ container that this iterator refers to.
$head operator_arg$$
Is the $cref/operator_arg/cpp_ad_graph/operator_vec/$$
for the $code cpp_graph$$ container that this iterator refers to.
$head op_index$$
This must be either zero (the $code begin()$$ for the container)
or equal to the size of $icode operator_vec$$
(the $code end()$$ for the container).
$end
*/
cpp_graph_itr(void)
: operator_vec_(nullptr), operator_arg_(nullptr)
{ }
// BEGIN_CTOR
cpp_graph_itr(
const vector<graph_op_enum>& operator_vec ,
const vector<size_t>& operator_arg ,
size_t op_index )
// END_CTOR
:
operator_vec_(&operator_vec) ,
operator_arg_(&operator_arg) ,
op_index_(op_index)
{ // end constructor
if( op_index == operator_vec.size() )
return;
//
// begin constructor
CPPAD_ASSERT_KNOWN( op_index == 0,
"cpp_graph_itr: constructor op_index not 0 or operator_vec.size()"
);
// start at the beginning of operator_vec
first_arg_ = 0;
//
// get the value, and first_node_, for this operator
get_value();
}
/* %$$
------------------------------------------------------------------------------
$begin cpp_graph_itr_input$$
$spell
Iterator
$$
$section C++ AD Graph Iterator Input Operations$$
$srccode%hpp% */
// itr == other
bool operator==(const cpp_graph_itr& other) const
{ return op_index_ == other.op_index_;
}
// itr != other
bool operator!=(const cpp_graph_itr& other) const
{ return op_index_ != other.op_index_;
}
// *itr
value_type operator*(void)
{ CPPAD_ASSERT_KNOWN( operator_vec_ != nullptr,
"cpp_graph_itr: attempt to dereference default iterator"
);
CPPAD_ASSERT_KNOWN( op_index_ < operator_vec_->size(),
"cpp_graph_itr: attempt to dereference past last element in graph"
);
value_type ret;
ret.op_enum = op_enum_;
ret.str_index_ptr = &str_index_;
ret.n_result = n_result_;
ret.arg_node_ptr = &arg_node_;
return ret;
}
// ++itr
cpp_graph_itr& operator++(void)
{ ++op_index_;
first_arg_ = first_node_ + arg_node_.size();
get_value();
return *this;
}
// itr++
cpp_graph_itr operator++(int)
{ cpp_graph_itr ret(*this);
++op_index_;
first_arg_ = first_node_ + arg_node_.size();
get_value();
return ret;
}
/* %$$
$end
*/
};
} } } // END_CPPAD_LOCAL_GRAPH_NAMESPACE
# endif

View File

@@ -0,0 +1,23 @@
/* --------------------------------------------------------------------------
CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-19 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 cpp_graph_itr$$
$spell
Iterator
$$
$section C++ AD Graph Iterator Class$$
$childtable%
include/cppad/local/graph/cpp_graph_itr.hpp
%$$
$end

View File

@@ -0,0 +1,94 @@
# ifndef CPPAD_LOCAL_GRAPH_CPP_GRAPH_OP_HPP
# define CPPAD_LOCAL_GRAPH_CPP_GRAPH_OP_HPP
/* --------------------------------------------------------------------------
CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-19 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.
-------------------------------------------------------------------------- */
# include <cstddef>
# include <string>
# include <map>
# include <cppad/utility/vector.hpp>
# include <cppad/configure.hpp>
# include <cppad/core/graph/graph_op_enum.hpp>
namespace CppAD { namespace local { namespace graph {
/*
$begin cpp_graph_op$$
$spell
vec
asinh
acosh
atanh
erf
erfc
expm
namespace
enum
struct
op
arg
CppAD
addr_t
$$
$section C++ AD Graph Operators$$
$head Namespace$$
All of these definitions
are in the $code CppAD::local::graph$$ namespace.
$head CppAD::graph$$
$srccode%hpp% */
using namespace CppAD::graph;
/* %$$
$head addr_t$$
$srccode%hpp% */
typedef CPPAD_TAPE_ADDR_TYPE addr_t;
/* %$$
$head op_name2enum$$
This is a mapping from the operator name to its enum value.
The name is the operator enum without the $code _operator$$ at the end.
$srccode%hpp% */
extern std::map< std::string, graph_op_enum > op_name2enum;
/* %$$
$head op_enum2fixed_n_arg$$
This is the number of arguments for the operators that have
a fixed number of arguments and one result.
For other operators, this value is zero.
$srccode%hpp% */
extern size_t op_enum2fixed_n_arg[];
/* %$$
$head op_enum2name$$
This is mapping from operator enum value to its name.
In the $code local::graph$$ namespace:
$srccode%hpp% */
extern const char* op_enum2name[];
/* %$$
$head set_operator_info$$
This routine sets the values in
$code op_enum2fixed_n_arg$$,
$code op_enum2name$$, and
$code op_name2enum$$.
$srccode%hpp% */
extern void set_operator_info(void);
/* %$$
$end
*/
} } } // END_CPPAD_LOCAL_GRAPH_NAMESPACE
# endif

View File

@@ -0,0 +1,28 @@
-----------------------------------------------------------------------------
CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-19 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 dev_graph$$
$spell
Json
$$
$section Developer AD Graph Documentation$$
$childtable%
include/cppad/local/graph/cpp_graph_itr.omh%
include/cppad/local/graph/cpp_graph_op.hpp%
include/cppad/local/graph/json_lexer.omh%
include/cppad/local/graph/json_parser.hpp%
include/cppad/local/graph/json_writer.hpp
%$$
$end

View File

@@ -0,0 +1,389 @@
# ifndef CPPAD_LOCAL_GRAPH_JSON_LEXER_HPP
# define CPPAD_LOCAL_GRAPH_JSON_LEXER_HPP
/* --------------------------------------------------------------------------
CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-19 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.
-------------------------------------------------------------------------- */
# include <string>
# include <cppad/core/cppad_assert.hpp>
// BEGIN_NAMESPACE_CPPAD_LOCAL_GRAPH
namespace CppAD { namespace local { namespace graph {
// ===========================================================================
class json_lexer {
// ===========================================================================
/*
-------------------------------------------------------------------------------
$begin json_lexer_member_data$$
$spell
json
lexer
$$
$section json lexer: Private Data$$
$head graph_$$
The $cref json_ad_graph$$.
$head index_$$
is the index in the graph for the current character.
If a token is returned, this corresponds to the last character
it the token.
$head line_number_$$
line number in the graph for the current character
$head char_number_$$
character number in the graph for the current character
$head token_$$
used to return tokens.
$head function_name_$$
is the function name for this graph.
This is initialized as empty,
should be set as soon as it is parsed,
and is used for error reporting.
$head token$$
returns current value of $code token_$$.
$head line_number$$
returns current value of $code line_number_$$
(which corresponds to last character in the token).
$head char_number$$
returns current value of $code char_number_$$.
(which corresponds to last character in the token).
$head set_function_name$$
sets the value of $code function_name_$$.
$head Source Code$$
$srccode%hpp% */
private:
const std::string& json_;
size_t index_;
size_t line_number_;
size_t char_number_;
std::string token_;
std::string function_name_;
public:
const std::string& token(void) const;
size_t line_number(void) const;
size_t char_number(void) const;
void set_function_name(const std::string& function_name);
/* %$$
$end
-------------------------------------------------------------------------------
$begin json_lexer_report_error$$
$spell
json
lexer
CppAD
$$
$section json lexer: Report an Error$$
$head Syntax$$
$codei%
%json_lexer%.report_error(%expected%, %found%)
%$$
$head json_lexer$$
is a $code local::graph::json_lexer$$ object.
$head expected$$
is the token that is expected.
$head found$$
is the token or text that was found.
$head Report$$
The current CppAD $cref ErrorHandler$$ is used to report
an error parsing this Json AD graph.
$head Prototype$$
$srccode%hpp% */
public:
void report_error(const std::string& expected, const std::string& found);
/* %$$
$end
-------------------------------------------------------------------------------
$begin json_lexer_next_index$$
$spell
json
lexer
$$
$section json lexer: Advance Index by One$$
$head Syntax$$
$codei%
%json_lexer%.next_index()
%$$
$head json_lexer$$
is a $code local::graph::json_lexer$$ object.
$head index_$$
The input value of $code index_$$ is increased by one.
It is an error to call this routine when the input value
of $code index_$$ is greater than or equal $code json_.size()$$.
$head line_number_$$
If the previous character, before the call, was a new line,
$code line_number_$$ is increased by one.
$head char_number_$$
If the previous character, before the call, was a new line,
$code char_number$$ is set to one.
Otherwise, $code char_number_$$ is increased by one.
$head Prototype$$
$srccode%hpp% */
private:
void next_index(void);
/* %$$
$end
-------------------------------------------------------------------------------
$begin json_lexer_skip_white_space$$
$spell
json
lexer
$$
$section json lexer: Skip White Space That Separates Tokens$$
$head Syntax$$
$codei%
%json_lexer%.skip_white_space()
%$$
$head json_lexer$$
is a json lexer object.
$head Discussion$$
This member functions is used to increase $code index_$$ until either
a non-white space character is found or $code index_$$ is equal
to $code json_.size()$$.
$head Prototype$$
$srccode%hpp% */
private:
void skip_white_space(void);
/* %$$
$end
-------------------------------------------------------------------------------
$begin json_lexer_constructor$$
$spell
json
lexer
enum
op
arg
$$
$section json lexer: Constructor$$
$head Syntax$$
$codei%
local::graph::lexer %json_lexer%(%json%)
%$$
$head json$$
The argument $icode json$$ is an $cref json_ad_graph$$
and it is assumed that $icode json$$ does not change
for as long as $icode json_lexer$$ exists.
$head Initialization$$
The current token, index, line number, and character number
are set to the first non white space character in $code json_$$.
If this is not a left brace character $code '{'$$,
the error is reported and the constructor does not return.
$head Side Effect$$
If $code local::graph::op_name2enum.size() == 0$$,
the routine $cref/set_operator_info/cpp_graph_op/set_operator_info/$$
is called to initialize
$code op_enum2fixed_n_arg$$,
$code op_enum2name$$, and
$code op_name2enum$$.
This initialization cannot be done in
$cref/parallel mode/ta_in_parallel/$$.
$head Prototype$$
$srccode%hpp% */
public:
json_lexer(const std::string& json);
/* %$$
$end
-------------------------------------------------------------------------------
$begin json_lexer_check_next_char$$
$spell
json
lexer
ch
$$
$section Get and Check Next Single Character Token$$
$head Syntax$$
$codei%
%json_lexer%.check_next_char(%ch%)
%$$
$head index_$$
The search for the character starts
at one greater than the input value for $code index_$$ and skips white space.
$head ch$$
Is a non white space
single character token that is expected.
If this character is not found,
the error is reported and this function does not return.
In the special case where $icode ch$$ is $code '\0'$$,
any non-white space character will be accepted
(but there must be such a character).
$head token_$$
If this routine returns, $code token_$$ has size one
and contains the character that is found.
$head Prototype$$
$srccode%hpp% */
public:
void check_next_char(char ch);
/* %$$
$end
-------------------------------------------------------------------------------
$begin json_lexer_check_next_string$$
$spell
json
lexer
$$
$section Get and Check Next Single Character Token$$
$head Syntax$$
$codei%
%json_lexer%.check_next_string(%expected%)
%$$
$head index_$$
The search for the string starts
at one greater than the input value for $code index_$$ and skips white space.
$head expected$$
Is the value (not including double quotes) for the string that is expected.
If this string is not found, the error is reported
and this function does not return.
In the special case where $icode expected$$ is empty,
any string will be accepted.
$head token_$$
If this routine returns,
$icode token_$$ is the string that was found.
$head Prototype$$
$srccode%hpp% */
public:
void check_next_string(const std::string& expected);
/* %$$
$end
-------------------------------------------------------------------------------
$begin json_lexer_next_non_neg_int$$
$spell
json
lexer
neg
$$
$section Get Next Non-Negative Integer$$
$head Syntax$$
$codei%
%json_lexer%.next_non_neg_int()
%value% = %json_lexer%.token2size_t()
%$$
$head index_$$
The search for the non-negative integer starts
at one greater than the input value for $code index_$$ and skips white space.
$head token_$$
is set to the non-negative integer.
If the next token is not a non-negative integer,
the error is reported and this function does not return.
$head value$$
If the current token is a non-negative integer,
$icode value$$ is the corresponding value.
$head Prototype$$
$srccode%hpp% */
public:
void next_non_neg_int(void);
size_t token2size_t(void) const;
/* %$$
$end
-------------------------------------------------------------------------------
$begin json_lexer_next_float$$
$spell
json
lexer
$$
$section Get Next Floating Point Number$$
$head Syntax$$
$codei%
%ok% = %json_lexer%.next_float()
%value% = %json_lexer%.token2double()
%$$
$head index_$$
The search for the floating point number starts
at one greater than the input value for $code index_$$ and skips white space.
$head token_$$
is set to the floating point number.
If the next token is not a floating point number,
the error is reported and this function does not return.
$head value$$
If the current token is a floating point number,
$icode value$$ is the corresponding value.
$head Prototype$$
$srccode%hpp% */
public:
void next_float(void);
double token2double(void) const;
/* %$$
$end
*/
// ==========================================================================
}; // end class lexer
// ==========================================================================
} } } // END_NAMESPACE_CPPAD_LOCAL_GRAPH
# endif

View File

@@ -0,0 +1,24 @@
-----------------------------------------------------------------------------
CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-19 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 json_lexer$$
$spell
Json
$$
$section Lexical Analysis Class for a Json AD Graph$$.
$childtable%
include/cppad/local/graph/json_lexer.hpp
%$$
$end

View File

@@ -0,0 +1,55 @@
# ifndef CPPAD_LOCAL_GRAPH_JSON_PARSER_HPP
# define CPPAD_LOCAL_GRAPH_JSON_PARSER_HPP
/* --------------------------------------------------------------------------
CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-19 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.
-------------------------------------------------------------------------- */
# include <string>
# include <cppad/utility/vector.hpp>
# include <cppad/local/graph/cpp_graph_op.hpp>
# include <cppad/core/graph/cpp_graph.hpp>
/*
$begin json_parser$$
$spell
Json
CppAD
obj
$$
$section Json AD Graph Parser$$
$head Syntax$$
$codei%json_parser(%json%, %graph_obj%)%$$
$head json$$
The $cref json_ad_graph$$.
$head graph_obj$$
This is a $code cpp_graph$$ object.
The input value of the object does not matter.
Upon return it is a $cref cpp_ad_graph$$ representation of this function.
$head Prototype$$
$srccode%hpp% */
namespace CppAD { namespace local { namespace graph {
void json_parser(
const std::string& json ,
cpp_graph& graph_obj
);
} } }
/* %$$
$end
*/
# endif

View File

@@ -0,0 +1,54 @@
# ifndef CPPAD_LOCAL_GRAPH_JSON_WRITER_HPP
# define CPPAD_LOCAL_GRAPH_JSON_WRITER_HPP
/* --------------------------------------------------------------------------
CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-19 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.
-------------------------------------------------------------------------- */
# include <string>
# include <cppad/utility/vector.hpp>
# include <cppad/local/graph/cpp_graph_op.hpp>
# include <cppad/utility/to_string.hpp>
/*
$begin json_writer$$
$spell
Json
CppAD
obj
$$
$section Json AD Graph Writer$$
$head Syntax$$
$codei%json_writer( %json%, %graph_obj% )%$$
$head json$$
The input value of $icode json$$ does not matter,
upon return it a $cref/json/json_ad_graph/$$ representation of the AD graph.
$head graph_obj$$
This is a $code cpp_graph$$ object.
$head Prototype$$
$srccode%hpp% */
namespace CppAD { namespace local { namespace graph {
void json_writer(
std::string& json ,
const cpp_graph& graph_obj
);
} } }
/* %$$
$end
*/
# endif