From f723c4ff2010d58063da39e1ff3b69889804053c Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Tue, 26 Nov 2024 21:33:15 +0100 Subject: [PATCH 01/10] fix typos --- ADOL-C/boost-test/traceOperatorVector.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ADOL-C/boost-test/traceOperatorVector.cpp b/ADOL-C/boost-test/traceOperatorVector.cpp index 799264ff..752d64ac 100644 --- a/ADOL-C/boost-test/traceOperatorVector.cpp +++ b/ADOL-C/boost-test/traceOperatorVector.cpp @@ -2507,7 +2507,7 @@ BOOST_AUTO_TEST_CASE(FmaxOperator_FOV_Forward_1) { xd[0][0] = 1.3; xd[0][1] = 3.7; xd[1][0] = -1.3; - xd[1][0] = -3.7; + xd[1][1] = -3.7; a = std::fmax(2.5, 2.5); aDerivative = 1.3; @@ -2900,7 +2900,7 @@ BOOST_AUTO_TEST_CASE(FminOperator_FOV_Forward_1) { xd[0][0] = 1.3; xd[0][1] = 3.7; xd[1][0] = -1.3; - xd[1][0] = -3.7; + xd[1][1] = -3.7; a = std::fmax(2.5, 2.5); aDerivative = -3.7; From 986e69728ea1309e298bbc70a03ba7c4876484df Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Tue, 26 Nov 2024 21:34:10 +0100 Subject: [PATCH 02/10] change max to min --- ADOL-C/boost-test/traceOperatorVector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ADOL-C/boost-test/traceOperatorVector.cpp b/ADOL-C/boost-test/traceOperatorVector.cpp index 752d64ac..b1c4ba1d 100644 --- a/ADOL-C/boost-test/traceOperatorVector.cpp +++ b/ADOL-C/boost-test/traceOperatorVector.cpp @@ -2902,7 +2902,7 @@ BOOST_AUTO_TEST_CASE(FminOperator_FOV_Forward_1) { xd[1][0] = -1.3; xd[1][1] = -3.7; - a = std::fmax(2.5, 2.5); + a = std::fmin(2.5, 2.5); aDerivative = -3.7; bDerivative = -3.7; From 228465fe1a23b3b8d39b25252916748925f30820 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Tue, 26 Nov 2024 21:42:35 +0100 Subject: [PATCH 03/10] fix first fmin test case --- ADOL-C/boost-test/traceOperatorVector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ADOL-C/boost-test/traceOperatorVector.cpp b/ADOL-C/boost-test/traceOperatorVector.cpp index b1c4ba1d..ff4c40a6 100644 --- a/ADOL-C/boost-test/traceOperatorVector.cpp +++ b/ADOL-C/boost-test/traceOperatorVector.cpp @@ -2903,7 +2903,7 @@ BOOST_AUTO_TEST_CASE(FminOperator_FOV_Forward_1) { xd[1][1] = -3.7; a = std::fmin(2.5, 2.5); - aDerivative = -3.7; + aDerivative = -1.3; bDerivative = -3.7; fov_forward(1, 1, 2, 2, x, xd, y, yd); From 220432aab86983f7df7db3a4f6302dd1617b16be Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Wed, 27 Nov 2024 12:26:29 +0100 Subject: [PATCH 04/10] bugfix: ptr was incremented if macro was not defined --- ADOL-C/src/uni5_for.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ADOL-C/src/uni5_for.c b/ADOL-C/src/uni5_for.c index 10c73200..34841355 100644 --- a/ADOL-C/src/uni5_for.c +++ b/ADOL-C/src/uni5_for.c @@ -4233,8 +4233,10 @@ int hov_forward( VEC_INC(Targ2, k - i) BREAK_FOR_I } - Targ1++; - Targ2++; + else{ + Targ1++; + Targ2++; + } } if (Targ == NULL) /* e.g. both are equal */ Targ = Targ1OP; From 8e1b0ba5611e8aabe78b99f3fcc768c0d69c7c3e Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Wed, 27 Nov 2024 12:28:49 +0100 Subject: [PATCH 05/10] bugfix: test derivative was not set properly --- ADOL-C/boost-test/traceOperatorVector.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/ADOL-C/boost-test/traceOperatorVector.cpp b/ADOL-C/boost-test/traceOperatorVector.cpp index ff4c40a6..8793285e 100644 --- a/ADOL-C/boost-test/traceOperatorVector.cpp +++ b/ADOL-C/boost-test/traceOperatorVector.cpp @@ -2510,8 +2510,8 @@ BOOST_AUTO_TEST_CASE(FmaxOperator_FOV_Forward_1) { xd[1][1] = -3.7; a = std::fmax(2.5, 2.5); - aDerivative = 1.3; - bDerivative = 1.3; + aDerivative = std::fmax(xd[0][0], xd[1][0]); + bDerivative = std::fmax(xd[0][1], xd[1][1]); fov_forward(1, 1, 2, 2, x, xd, y, yd); @@ -2729,6 +2729,7 @@ BOOST_AUTO_TEST_CASE(FmaxOperator_FOV_Forward_3) { trace_off(); double aDerivative = 1.; + double bDerivative = 1.; a = std::fmax(a, b); double *x = myalloc1(1); @@ -2770,13 +2771,14 @@ BOOST_AUTO_TEST_CASE(FmaxOperator_FOV_Forward_3) { } a = std::fmax(x[0], b); - aDerivative = 1.; + aDerivative = std::fmax(xd[0][0], 0.0); + bDerivative = std::fmax(xd[0][1], 0.0); fov_forward(1, 1, 1, 2, x, xd, y, yd); BOOST_TEST(*y == a, tt::tolerance(tol)); BOOST_TEST(yd[0][0] == aDerivative, tt::tolerance(tol)); - BOOST_TEST(yd[0][1] == aDerivative, tt::tolerance(tol)); + BOOST_TEST(yd[0][1] == bDerivative, tt::tolerance(tol)); myfree1(x); myfree2(xd); @@ -2903,8 +2905,8 @@ BOOST_AUTO_TEST_CASE(FminOperator_FOV_Forward_1) { xd[1][1] = -3.7; a = std::fmin(2.5, 2.5); - aDerivative = -1.3; - bDerivative = -3.7; + aDerivative = std::fmin(xd[0][0], xd[1][0]); + bDerivative = std::fmin(xd[0][1], xd[1][1]); fov_forward(1, 1, 2, 2, x, xd, y, yd); @@ -3122,6 +3124,7 @@ BOOST_AUTO_TEST_CASE(FminOperator_FOV_Forward_3) { trace_off(); double aDerivative = 0.; + double bDerivative = 0.; a = std::fmin(a, b); double *x = myalloc1(1); @@ -3163,13 +3166,15 @@ BOOST_AUTO_TEST_CASE(FminOperator_FOV_Forward_3) { } a = std::fmin(x[0], b); - aDerivative = 0.; + aDerivative = std::fmin(xd[0][0], 0.0); + bDerivative = std::fmin(xd[0][1], 0.0); + fov_forward(1, 1, 1, 2, x, xd, y, yd); BOOST_TEST(*y == a, tt::tolerance(tol)); BOOST_TEST(yd[0][0] == aDerivative, tt::tolerance(tol)); - BOOST_TEST(yd[0][1] == aDerivative, tt::tolerance(tol)); + BOOST_TEST(yd[0][1] == bDerivative, tt::tolerance(tol)); myfree1(x); myfree2(xd); From 751bbe974344fcf1fedb665ab3328a51c866cad7 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Wed, 27 Nov 2024 12:37:02 +0100 Subject: [PATCH 06/10] format --- ADOL-C/boost-test/traceOperatorVector.cpp | 1 - ADOL-C/src/uni5_for.c | 9 +++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/ADOL-C/boost-test/traceOperatorVector.cpp b/ADOL-C/boost-test/traceOperatorVector.cpp index 8793285e..f8720621 100644 --- a/ADOL-C/boost-test/traceOperatorVector.cpp +++ b/ADOL-C/boost-test/traceOperatorVector.cpp @@ -3169,7 +3169,6 @@ BOOST_AUTO_TEST_CASE(FminOperator_FOV_Forward_3) { aDerivative = std::fmin(xd[0][0], 0.0); bDerivative = std::fmin(xd[0][1], 0.0); - fov_forward(1, 1, 1, 2, x, xd, y, yd); BOOST_TEST(*y == a, tt::tolerance(tol)); diff --git a/ADOL-C/src/uni5_for.c b/ADOL-C/src/uni5_for.c index 34841355..a8699061 100644 --- a/ADOL-C/src/uni5_for.c +++ b/ADOL-C/src/uni5_for.c @@ -4215,10 +4215,8 @@ int hov_forward( FOR_0_LE_l_LT_p { Targ = Tqo; - if (Targ == - NULL) /* e.g. dp_T0[arg1] == - dp_T0[arg2] */ - { + /* e.g. dp_T0[arg1] == dp_T0[arg2] */ + if (Targ == NULL) { Targ1OP = Targ1; Targ2OP = Targ2; FOR_0_LE_i_LT_k { @@ -4232,8 +4230,7 @@ int hov_forward( VEC_INC(Targ1, k - i) VEC_INC(Targ2, k - i) BREAK_FOR_I - } - else{ + } else { Targ1++; Targ2++; } From 6c6cec3ea83f6bd39ab4bd9213e83ea1a9d08b23 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Mon, 9 Dec 2024 18:10:49 +0100 Subject: [PATCH 07/10] change name --- ADOL-C/boost-test/uni5_for.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ADOL-C/boost-test/uni5_for.cpp b/ADOL-C/boost-test/uni5_for.cpp index 593ec756..30f7ea56 100644 --- a/ADOL-C/boost-test/uni5_for.cpp +++ b/ADOL-C/boost-test/uni5_for.cpp @@ -18,7 +18,7 @@ namespace tt = boost::test_tools; BOOST_AUTO_TEST_SUITE(uni5_for) -BOOST_AUTO_TEST_CASE(ZOS_PL_FORWARD) { +BOOST_AUTO_TEST_CASE(Fmaxoperator_ZOS_PL_Forward) { enableMinMaxUsingAbs(); From cab78221965d4e78d7465abce165d3fef3fa755e Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Wed, 11 Dec 2024 10:41:10 +0100 Subject: [PATCH 08/10] add tests for hov_forward with max --- ADOL-C/boost-test/uni5_for.cpp | 162 ++++++++++++++++++++++++++++++++- 1 file changed, 161 insertions(+), 1 deletion(-) diff --git a/ADOL-C/boost-test/uni5_for.cpp b/ADOL-C/boost-test/uni5_for.cpp index 30f7ea56..9129fd74 100644 --- a/ADOL-C/boost-test/uni5_for.cpp +++ b/ADOL-C/boost-test/uni5_for.cpp @@ -27,7 +27,7 @@ BOOST_AUTO_TEST_CASE(Fmaxoperator_ZOS_PL_Forward) { const int dim_out = 1; const int dim_in = 3; - std::array in = {-2.0, 0.0, 1.5}; + std::array in{-2.0, 0.0, 1.5}; std::array indep; double out[] = {0.0}; @@ -82,4 +82,164 @@ BOOST_AUTO_TEST_CASE(Fmaxoperator_ZOS_PL_Forward) { removeTape(tag, ADOLC_REMOVE_COMPLETELY); } + +BOOST_AUTO_TEST_CASE(FmaxOperator_HOV_Forward) { + const int16_t tag = 0; + const size_t dim_out = 1; + const size_t dim_in = 2; + const size_t degree = 2; + const size_t num_dirs = 3; + std::vector in{4.0, 3.2}; + std::vector indep(dim_in); + std::vector out(dim_out); + + trace_on(tag); + std::for_each(in.begin(), in.end(), [&, i = 0](int value) mutable { + indep[i] <<= in[i]; + i++; + }); + + // max(x^2, y^3) + adouble dep = fmax(pow(indep[0], 2), pow(indep[1], 3)); + + dep >>= out[0]; + trace_off(); + + double ***X = myalloc3(dim_in, num_dirs, degree); + double ***Y = myalloc3(dim_out, num_dirs, degree); + + X[0][0][0] = 1.0; + X[1][0][0] = 1.9; + + X[0][1][0] = 2.0; + X[1][1][0] = 3.0; + + X[0][2][0] = 1.0; + X[1][2][0] = -1.0; + + X[0][0][1] = -1.0; + X[1][0][1] = 1.0; + + X[0][1][1] = -2.0; + X[1][1][1] = -3.0; + + X[0][2][1] = -1.0; + X[1][2][1] = 1.0; + + /**************************** + TEST A < B + *****************************/ + std::vector test_in{4.0, 3.2}; + // max(x^2, y^3) + double test_out = std::fmax(std::pow(test_in[0], 2), std::pow(test_in[1], 3)); + + hov_forward(tag, dim_out, dim_in, degree, num_dirs, test_in.data(), X, + out.data(), Y); + + BOOST_TEST(out[0] == test_out, tt::tolerance(tol)); + BOOST_TEST(Y[0][0][0] == 3 * std::pow(test_in[1], 2) * X[1][0][0], + tt::tolerance(tol)); + BOOST_TEST(Y[0][1][0] == 3 * std::pow(test_in[1], 2) * X[1][1][0], + tt::tolerance(tol)); + BOOST_TEST(Y[0][2][0] == 3 * std::pow(test_in[1], 2) * X[1][2][0], + tt::tolerance(tol)); + BOOST_TEST(Y[0][0][1] == + 1.0 / 2.0 * 6.0 * test_in[1] * X[1][0][0] * X[1][0][0] + + 3.0 * std::pow(test_in[1], 2.0) * X[1][0][1], + tt::tolerance(tol)); + BOOST_TEST(Y[0][1][1] == + 1.0 / 2.0 * 6.0 * test_in[1] * X[1][1][0] * X[1][1][0] + + 3.0 * std::pow(test_in[1], 2.0) * X[1][1][1], + tt::tolerance(tol)); + BOOST_TEST(Y[0][2][1] == + 1.0 / 2.0 * 6.0 * test_in[1] * X[1][2][0] * X[1][2][0] + + 3.0 * std::pow(test_in[1], 2.0) * X[1][2][1], + tt::tolerance(tol)); + + /************************** + TEST A > B + ***************************/ + + // test_in[0] = 4.0 + test_in[1] = 1.0; + // max(x^2, y^3) + test_out = std::fmax(std::pow(test_in[0], 2), std::pow(test_in[1], 3)); + hov_forward(tag, dim_out, dim_in, degree, num_dirs, test_in.data(), X, + out.data(), Y); + + BOOST_TEST(out[0] == test_out, tt::tolerance(tol)); + BOOST_TEST(Y[0][0][0] == 2 * test_in[0] * X[0][0][0], tt::tolerance(tol)); + BOOST_TEST(Y[0][1][0] == 2 * test_in[0] * X[0][1][0], tt::tolerance(tol)); + BOOST_TEST(Y[0][2][0] == 2 * test_in[0] * X[0][2][0], tt::tolerance(tol)); + BOOST_TEST(Y[0][0][1] == 1.0 / 2.0 * 2.0 * X[0][0][0] * X[0][0][0] + + 2.0 * test_in[0] * X[0][0][1], + tt::tolerance(tol)); + BOOST_TEST(Y[0][1][1] == 1.0 / 2.0 * 2.0 * X[0][1][0] * X[0][1][0] + + 2.0 * test_in[0] * X[0][1][1], + tt::tolerance(tol)); + BOOST_TEST(Y[0][2][1] == 1.0 / 2.0 * 2.0 * X[0][2][0] * X[0][2][0] + + 2.0 * test_in[0] * X[0][2][1], + tt::tolerance(tol)); + + /************************** + TEST A == B + ***************************/ + + test_in[0] = 1.0; + test_in[1] = 1.0; + + // max(x^2, y^3) + test_out = std::fmax(std::pow(test_in[0], 2), std::pow(test_in[1], 3)); + + // A < B + X[0][0][0] = 1.0; + X[1][0][0] = 1.9; + + // A > B + X[0][1][0] = 3.0; + X[1][1][0] = 2.0; + + // A == B + X[0][2][0] = 1.0; + X[1][2][0] = 1.0; + + X[0][0][1] = -1.0; + X[1][0][1] = 1.0; + + X[0][1][1] = -2.0; + X[1][1][1] = -3.0; + + // A < B + X[0][2][1] = 1.0; + X[1][2][1] = 2.0; + + hov_forward(tag, dim_out, dim_in, degree, num_dirs, test_in.data(), X, + out.data(), Y); + BOOST_TEST(out[0] == test_out, tt::tolerance(tol)); + + // A < B + BOOST_TEST(Y[0][0][0] == 3 * std::pow(test_in[1], 2) * X[1][0][0], + tt::tolerance(tol)); + BOOST_TEST(Y[0][0][1] == + 1.0 / 2.0 * 6.0 * test_in[1] * X[1][0][0] * X[1][0][0] + + 3.0 * std::pow(test_in[1], 2.0) * X[1][0][1], + tt::tolerance(tol)); + + // A < B + BOOST_TEST(Y[0][1][0] == 2 * test_in[0] * X[0][1][0], tt::tolerance(tol)); + BOOST_TEST(Y[0][1][1] == 1.0 / 2.0 * 2.0 * X[0][1][0] * X[0][1][0] + + 2.0 * test_in[0] * X[0][1][1], + tt::tolerance(tol)); + + // A == B, A < B + BOOST_TEST(Y[0][2][0] == 3 * std::pow(test_in[1], 2) * X[1][2][0], + tt::tolerance(tol)); + BOOST_TEST(Y[0][2][1] == + 1.0 / 2.0 * 6.0 * test_in[1] * X[1][2][0] * X[1][2][0] + + 3.0 * std::pow(test_in[1], 2.0) * X[1][2][1], + tt::tolerance(tol)); + + myfree3(X); + myfree3(Y); +} BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file From be7951bb5b460fdc8fb33dadd73c00a8692750f7 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Wed, 11 Dec 2024 10:51:22 +0100 Subject: [PATCH 09/10] add tests for hov_forward with min --- ADOL-C/boost-test/uni5_for.cpp | 161 +++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) diff --git a/ADOL-C/boost-test/uni5_for.cpp b/ADOL-C/boost-test/uni5_for.cpp index 9129fd74..1d98f63f 100644 --- a/ADOL-C/boost-test/uni5_for.cpp +++ b/ADOL-C/boost-test/uni5_for.cpp @@ -242,4 +242,165 @@ BOOST_AUTO_TEST_CASE(FmaxOperator_HOV_Forward) { myfree3(X); myfree3(Y); } + +BOOST_AUTO_TEST_CASE(FminOperator_HOV_Forward) { + const int16_t tag = 0; + const size_t dim_out = 1; + const size_t dim_in = 2; + const size_t degree = 2; + const size_t num_dirs = 3; + std::vector in{4.0, 3.2}; + std::vector indep(dim_in); + std::vector out(dim_out); + + trace_on(tag); + std::for_each(in.begin(), in.end(), [&, i = 0](int value) mutable { + indep[i] <<= in[i]; + i++; + }); + + // max(x^2, y^3) + adouble dep = fmin(-pow(indep[0], 2), -pow(indep[1], 3)); + + dep >>= out[0]; + trace_off(); + + double ***X = myalloc3(dim_in, num_dirs, degree); + double ***Y = myalloc3(dim_out, num_dirs, degree); + + X[0][0][0] = 1.0; + X[1][0][0] = 1.9; + + X[0][1][0] = 2.0; + X[1][1][0] = 3.0; + + X[0][2][0] = 1.0; + X[1][2][0] = -1.0; + + X[0][0][1] = -1.0; + X[1][0][1] = 1.0; + + X[0][1][1] = -2.0; + X[1][1][1] = -3.0; + + X[0][2][1] = -1.0; + X[1][2][1] = 1.0; + + /**************************** + TEST A < B + *****************************/ + std::vector test_in{4.0, 3.2}; + // max(x^2, y^3) + double test_out = + std::fmin(-std::pow(test_in[0], 2), -std::pow(test_in[1], 3)); + + hov_forward(tag, dim_out, dim_in, degree, num_dirs, test_in.data(), X, + out.data(), Y); + + BOOST_TEST(out[0] == test_out, tt::tolerance(tol)); + BOOST_TEST(Y[0][0][0] == -3 * std::pow(test_in[1], 2) * X[1][0][0], + tt::tolerance(tol)); + BOOST_TEST(Y[0][1][0] == -3 * std::pow(test_in[1], 2) * X[1][1][0], + tt::tolerance(tol)); + BOOST_TEST(Y[0][2][0] == -3 * std::pow(test_in[1], 2) * X[1][2][0], + tt::tolerance(tol)); + BOOST_TEST(Y[0][0][1] == + -1.0 / 2.0 * 6.0 * test_in[1] * X[1][0][0] * X[1][0][0] - + 3.0 * std::pow(test_in[1], 2.0) * X[1][0][1], + tt::tolerance(tol)); + BOOST_TEST(Y[0][1][1] == + -1.0 / 2.0 * 6.0 * test_in[1] * X[1][1][0] * X[1][1][0] - + 3.0 * std::pow(test_in[1], 2.0) * X[1][1][1], + tt::tolerance(tol)); + BOOST_TEST(Y[0][2][1] == + -1.0 / 2.0 * 6.0 * test_in[1] * X[1][2][0] * X[1][2][0] - + 3.0 * std::pow(test_in[1], 2.0) * X[1][2][1], + tt::tolerance(tol)); + + /************************** + TEST A > B + ***************************/ + + // test_in[0] = 4.0 + test_in[1] = 1.0; + // max(x^2, y^3) + test_out = std::fmin(-std::pow(test_in[0], 2), -std::pow(test_in[1], 3)); + hov_forward(tag, dim_out, dim_in, degree, num_dirs, test_in.data(), X, + out.data(), Y); + + BOOST_TEST(out[0] == test_out, tt::tolerance(tol)); + BOOST_TEST(Y[0][0][0] == -2 * test_in[0] * X[0][0][0], tt::tolerance(tol)); + BOOST_TEST(Y[0][1][0] == -2 * test_in[0] * X[0][1][0], tt::tolerance(tol)); + BOOST_TEST(Y[0][2][0] == -2 * test_in[0] * X[0][2][0], tt::tolerance(tol)); + BOOST_TEST(Y[0][0][1] == -1.0 / 2.0 * 2.0 * X[0][0][0] * X[0][0][0] - + 2.0 * test_in[0] * X[0][0][1], + tt::tolerance(tol)); + BOOST_TEST(Y[0][1][1] == -1.0 / 2.0 * 2.0 * X[0][1][0] * X[0][1][0] - + 2.0 * test_in[0] * X[0][1][1], + tt::tolerance(tol)); + BOOST_TEST(Y[0][2][1] == -1.0 / 2.0 * 2.0 * X[0][2][0] * X[0][2][0] - + 2.0 * test_in[0] * X[0][2][1], + tt::tolerance(tol)); + + /************************** + TEST A == B + ***************************/ + + test_in[0] = 1.0; + test_in[1] = 1.0; + + // max(x^2, y^3) + test_out = std::fmin(-std::pow(test_in[0], 2), -std::pow(test_in[1], 3)); + + // A < B + X[0][0][0] = 1.0; + X[1][0][0] = 1.9; + + // A > B + X[0][1][0] = 3.0; + X[1][1][0] = 2.0; + + // A == B + X[0][2][0] = 1.0; + X[1][2][0] = 1.0; + + X[0][0][1] = -1.0; + X[1][0][1] = 1.0; + + X[0][1][1] = -2.0; + X[1][1][1] = -3.0; + + // A < B + X[0][2][1] = 1.0; + X[1][2][1] = 2.0; + + hov_forward(tag, dim_out, dim_in, degree, num_dirs, test_in.data(), X, + out.data(), Y); + BOOST_TEST(out[0] == test_out, tt::tolerance(tol)); + + // A < B + BOOST_TEST(Y[0][0][0] == -3 * std::pow(test_in[1], 2) * X[1][0][0], + tt::tolerance(tol)); + BOOST_TEST(Y[0][0][1] == + -1.0 / 2.0 * 6.0 * test_in[1] * X[1][0][0] * X[1][0][0] - + 3.0 * std::pow(test_in[1], 2.0) * X[1][0][1], + tt::tolerance(tol)); + + // A < B + BOOST_TEST(Y[0][1][0] == -2 * test_in[0] * X[0][1][0], tt::tolerance(tol)); + BOOST_TEST(Y[0][1][1] == -1.0 / 2.0 * 2.0 * X[0][1][0] * X[0][1][0] - + 2.0 * test_in[0] * X[0][1][1], + tt::tolerance(tol)); + + // A == B, A < B + BOOST_TEST(Y[0][2][0] == -3 * std::pow(test_in[1], 2) * X[1][2][0], + tt::tolerance(tol)); + BOOST_TEST(Y[0][2][1] == + -1.0 / 2.0 * 6.0 * test_in[1] * X[1][2][0] * X[1][2][0] - + 3.0 * std::pow(test_in[1], 2.0) * X[1][2][1], + tt::tolerance(tol)); + + myfree3(X); + myfree3(Y); +} BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file From 3c1f1ed78be490cee4f2d09ec8879dc1ded89eb1 Mon Sep 17 00:00:00 2001 From: Tim Siebert Date: Thu, 12 Dec 2024 09:03:37 +0100 Subject: [PATCH 10/10] add disableminmaxusingabs --- ADOL-C/boost-test/uni5_for.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ADOL-C/boost-test/uni5_for.cpp b/ADOL-C/boost-test/uni5_for.cpp index 1d98f63f..e3e19b2d 100644 --- a/ADOL-C/boost-test/uni5_for.cpp +++ b/ADOL-C/boost-test/uni5_for.cpp @@ -19,9 +19,6 @@ namespace tt = boost::test_tools; BOOST_AUTO_TEST_SUITE(uni5_for) BOOST_AUTO_TEST_CASE(Fmaxoperator_ZOS_PL_Forward) { - - enableMinMaxUsingAbs(); - const int16_t tag = 1; const int dim_out = 1; @@ -31,6 +28,7 @@ BOOST_AUTO_TEST_CASE(Fmaxoperator_ZOS_PL_Forward) { std::array indep; double out[] = {0.0}; + enableMinMaxUsingAbs(); // ---------------------- trace on --------------------- // function is given by fabs(in_2 + fabs(in_1 + fabs(in_0))) trace_on(tag); @@ -48,7 +46,7 @@ BOOST_AUTO_TEST_CASE(Fmaxoperator_ZOS_PL_Forward) { dep >>= out[0]; trace_off(); - + disableMinMaxUsingAbs(); // ---------------------- trace off --------------------- // test outout