Skip to content

Commit

Permalink
master: valvector: combine split and join in split_join.hpp and finis…
Browse files Browse the repository at this point in the history
…h out AD version of reverse.
  • Loading branch information
bradbell committed Mar 2, 2024
1 parent f4cf34c commit 1733245
Show file tree
Hide file tree
Showing 9 changed files with 639 additions and 634 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 "20240301")
SET(cppad_version "20240302")
SET(cppad_url "https://coin-or.github.io/CppAD" )
SET(cppad_description "Differentiation of C++ Algorithms" )
IF( NOT DEFINED CMAKE_BUILD_TYPE)
Expand Down
5 changes: 5 additions & 0 deletions appendix/whats_new/2024.xrst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ Release Notes for 2024
mm-dd
*****

03-02
=====
Add the :ref:`valvector_ad_split-name` and :ref:`valvector_ad_join-name`
examples.

03-01
=====
Fix bug in the optimizer :ref:`optimize@options@val_graph` option.
Expand Down
15 changes: 14 additions & 1 deletion example/valvector/ad_join.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-FileCopyrightText: Bradley M. Bell <[email protected]>
// SPDX-FileContributor: 2024 Bradley M. Bell
// ---------------------------------------------------------------------------
# include <cppad/example/valvector/ad_join.hpp>
# include <cppad/example/valvector/split_join.hpp>
# include <cppad/cppad.hpp>
/*
{xrst_begin valvector_ad_join.cpp}
Expand Down Expand Up @@ -153,6 +153,19 @@ bool ad_join(void)
for(size_t j = 0; j < n; ++j)
ok &= dz[0][j] == 2.0 * x[j][0];
//
// h
CPPAD_TESTVECTOR( ad_valvector ) aw(m), adw(n);
aw[0] = valvector( 1.0 );
CppAD::Independent(ax);
af.Forward(0, ax);
adw = af.Reverse(1, aw);
CppAD::ADFun<valvector> h(ax, adw);
//
// ok
dw = h.Forward(0, x);
for(size_t j = 0; j < n; ++j)
ok &= dw[j][0] == 2.0 * x[j][0];
//
// ok
f.optimize();
z = f.Forward(0, x);
Expand Down
16 changes: 15 additions & 1 deletion example/valvector/ad_split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-FileCopyrightText: Bradley M. Bell <[email protected]>
// SPDX-FileContributor: 2024 Bradley M. Bell
// ---------------------------------------------------------------------------
# include <cppad/example/valvector/ad_split.hpp>
# include <cppad/example/valvector/split_join.hpp>
# include <cppad/cppad.hpp>
/*
{xrst_begin valvector_ad_split.cpp}
Expand Down Expand Up @@ -135,6 +135,20 @@ bool ad_split(void)
for(size_t i = 0; i < m; ++i)
ok &= dy[i][0] == 2.0 * x[0][i];
//
// h
CPPAD_TESTVECTOR( ad_valvector ) aw(m), adw(n);
for(size_t i = 0; i < m; ++i)
aw[i] = valvector( 1.0 );
CppAD::Independent(ax);
af.Forward(0, ax);
adw = af.Reverse(1, aw);
CppAD::ADFun<valvector> h(ax, adw);
//
// ok
dw = h.Forward(0, x);
for(size_t i = 0; i < m; ++i)
ok &= dw[0][i] == 2.0 * x[0][i];
//
// ok
f.optimize();
y = f.Forward(0, x);
Expand Down
315 changes: 0 additions & 315 deletions include/cppad/example/valvector/ad_join.hpp

This file was deleted.

Loading

0 comments on commit 1733245

Please sign in to comment.