23#include <unordered_map>
38template <base::concepts::real_scalar Scalar>
69 return iter->second.diff;
98 const auto [iter, inserted] =
103 ++iter->second.ref_count;
124 --child_info.ref_count;
125 if (child_info.ref_count == 0) {
Definition of assertion macros.
#define NUM_COLLECT_ASSERT(CONDITION)
Macro to check whether a condition is satisfied.
class to save information of child nodes.
auto node() const noexcept -> const node_ptr< scalar_type > &
Get the child node.
auto sensitivity() const noexcept -> const scalar_type &
Get the partial differential coefficient of the parent node by the child node.
Class to compute differential coefficients for nodes in backward-mode automatic differentiation kubot...
void list_nodes(const node_ptr< scalar_type > &top_node)
List nodes.
void compute(const node_ptr< scalar_type > &top_node)
Compute differential coefficients.
std::unordered_map< node_ptr< scalar_type >, node_info > info_dict_
Dictionary of information of nodes.
Scalar scalar_type
Type of scalars.
node_differentiator()=default
Constructor.
auto coeff(const node_ptr< scalar_type > &node) const -> scalar_type
Get the differential coefficient of a node.
std::queue< node_ptr< scalar_type > > node_queue_
Queue of remaining nodes.
void compute_coeffs(const node_ptr< scalar_type > &top_node)
Compute the differential coefficients using the information generated by list_nodes function.
Class of nodes in graphs of automatic differentiation.
auto children() const noexcept -> const std::vector< child_node< scalar_type > > &
Get the child nodes.
Definition of index_type type.
Namespace of graphs in backward-mode automatic differentiation.
std::shared_ptr< const node< Scalar > > node_ptr
Type of pointers of nodes.
std::ptrdiff_t index_type
Type of indices in this library.
Definition of node class.
Definition of real_scalar concept.
Struct to save internal information of nodes.
index_type ref_count
Number of remaining references.
scalar_type diff
Differential coefficient.