diff --git a/CMakeLists.txt b/CMakeLists.txt index 358994779..29f3cc45c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ IF( POLICY CMP0054 ) ENDIF( POLICY CMP0054 ) # # cppad_version is used by version.sh to get the version number. -SET(cppad_version "20241111") +SET(cppad_version "20241112") SET(cppad_url "https://coin-or.github.io/CppAD" ) SET(cppad_description "Differentiation of C++ Algorithms" ) IF( NOT DEFINED CMAKE_BUILD_TYPE) diff --git a/include/cppad/core/rev_hes_sparsity.hpp b/include/cppad/core/rev_hes_sparsity.hpp index 0c11d57cc..42872d612 100644 --- a/include/cppad/core/rev_hes_sparsity.hpp +++ b/include/cppad/core/rev_hes_sparsity.hpp @@ -2,7 +2,7 @@ # define CPPAD_CORE_REV_HES_SPARSITY_HPP // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later // SPDX-FileCopyrightText: Bradley M. Bell -// SPDX-FileContributor: 2003-23 Bradley M. Bell +// SPDX-FileContributor: 2003-24 Bradley M. Bell // ---------------------------------------------------------------------------- /* {xrst_begin rev_hes_sparsity} @@ -106,7 +106,7 @@ Sparsity for Entire Hessian *************************** Suppose that :math:`R` is the :math:`n \times n` identity matrix. In this case, *pattern_out* is a sparsity pattern for -:math:`(s^\R{T} F) F^{(2)} ( x )`. +:math:`(s^\R{T} F)^{(2)} ( x )`. Example ******* diff --git a/test_more/general/vec_ad.cpp b/test_more/general/vec_ad.cpp index bfe4df40e..e56167ef4 100644 --- a/test_more/general/vec_ad.cpp +++ b/test_more/general/vec_ad.cpp @@ -494,7 +494,7 @@ bool jac_sparsity_test_function(CppAD::ADFun& fun) size_t nr = 5, nc = 5, nnz = 0; sparse_rc pattern_check(nr, nc, nnz); for(size_t i = 0; i < nr; ++i) - { // values in v depend on x_2 and x_3 + { // values in v depend on x_2 and x_3 pattern_check.push_back(i, 2); pattern_check.push_back(i, 3); if( dependency ) @@ -537,6 +537,63 @@ bool jac_sparsity_test_function(CppAD::ADFun& fun) return ok; } +bool hes_sparsity_test_function(CppAD::ADFun& fun) +{ // + // ok + bool ok = true; + // + // size_vector + typedef CppAD::vector size_vector; + // + // sparse_rc + typedef CppAD::sparse_rc sparse_rc; + // + // pattern_check + size_t nr = 5, nc = 5, nnz = 0; + sparse_rc pattern_check(nr, nc, nnz); + for(int r : {2, 3} ) + { for(int c : {2, 3} ) + pattern_check.push_back(size_t(r), size_t(c)); + } + // + // pattern_eye + nr = 5, nc = 5, nnz = 5; + sparse_rc pattern_eye(nr, nc, nnz); + for(size_t k = 0; k < nr; ++k) + pattern_eye.set(k, k, k); + // + // pattern_jac + sparse_rc pattern_jac; + bool dependency = false; + bool transpose = false; + bool internal_bool = false; + fun.for_jac_sparsity( + pattern_eye, transpose, dependency, internal_bool, pattern_jac + ); + // + // select_range + CPPAD_TESTVECTOR(bool) select_range(5); + for(size_t i = 0; i < 5; ++i) + select_range[i] = false; + // + // i + for(size_t i = 0; i < 5; ++i) + { // + // pattern_hes + sparse_rc pattern_hes; + select_range[i] = true; + fun.rev_hes_sparsity( + select_range, transpose, internal_bool, pattern_hes + ); + select_range[i] = false; + // + // ok + ok &= pattern_hes == pattern_check; + } + // + return ok; +} + } // END empty namespace bool VecAD(void) @@ -553,6 +610,7 @@ bool VecAD(void) ok &= forward_zero_test_function(fun, x); ok &= forward_one_test_function(fun, x); ok &= jac_sparsity_test_function(fun); + ok &= hes_sparsity_test_function(fun); // return ok; } diff --git a/user_guide.xrst b/user_guide.xrst index 8b78b13de..d0d95429d 100644 --- a/user_guide.xrst +++ b/user_guide.xrst @@ -13,7 +13,7 @@ {xrst_comment BEGIN: Before changing see new_release.sh and check_version.sh} -cppad-20241111: CppAD User's Manual +cppad-20241112: CppAD User's Manual ################################### {xrst_comment The scripts bin/check_version.sh and bin/new_release.sh edit version numbers in tables below.}