diff --git a/doc/advanced_tutorials.rst b/doc/advanced_tutorials.rst index ad1d9a419..02833671f 100644 --- a/doc/advanced_tutorials.rst +++ b/doc/advanced_tutorials.rst @@ -5,7 +5,7 @@ Advanced tutorials .. important:: - More :ref:`tutorials ` and :ref:`examples ` are available in the documentation + More tutorials and examples are available in the documentation of heyoka's `Python bindings `__. In this section we will show some of heyoka's more advanced functionalities, diff --git a/doc/basic_tutorials.rst b/doc/basic_tutorials.rst index 5c69e1a2f..951a8d6ef 100644 --- a/doc/basic_tutorials.rst +++ b/doc/basic_tutorials.rst @@ -5,7 +5,7 @@ Basic tutorials .. important:: - More :ref:`tutorials ` and :ref:`examples ` are available in the documentation + More tutorials and examples are available in the documentation of heyoka's `Python bindings `__. The code snippets in these tutorials assume the inclusion of the diff --git a/doc/changelog.rst b/doc/changelog.rst index 7c605e168..9a8e42762 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -21,6 +21,9 @@ New Changes ~~~~~~~ +- Substantial speedups in the computation of first-order derivatives + with respect to many variables/parameters + (`#358 `__). - Substantial performance improvements in the computation of derivative tensors of large expressions with a high degree of internal redundancy diff --git a/src/expression_diff.cpp b/src/expression_diff.cpp index 8c95ddc9f..80d3cfa3e 100644 --- a/src/expression_diff.cpp +++ b/src/expression_diff.cpp @@ -797,7 +797,10 @@ void diff_tensors_reverse_impl( // Helpers to ease the access to the active member of the local_diff variant. // NOTE: if used incorrectly, these will throw at runtime. - auto local_dmap = [&local_diff]() -> diff_map_t & { return std::get(local_diff); }; + // NOTE: currently local_dmap is never used because the heuristic + // for deciding between forward and reverse mode prevents reverse mode + // from being used for order > 1. + auto local_dmap = [&local_diff]() -> diff_map_t & { return std::get(local_diff); }; // LCOV_EXCL_LINE auto local_dvec = [&local_diff]() -> diff_vec_t & { return std::get(local_diff); }; // Cache the number of diff arguments. @@ -959,6 +962,7 @@ void diff_tensors_reverse_impl( local_dvec().emplace_back(tmp_v_idx, std::move(cur_der)); } else { + // LCOV_EXCL_START // Check if we already computed this derivative. if (const auto it = local_dmap().find(tmp_v_idx); it == local_dmap().end()) { // The derivative is new. If the diff argument is present in the @@ -973,6 +977,7 @@ void diff_tensors_reverse_impl( [[maybe_unused]] const auto [_, flag] = local_dmap().try_emplace(tmp_v_idx, std::move(cur_der)); assert(flag); } + // LCOV_EXCL_STOP } }