Skip to content

Commit

Permalink
Merge pull request coin-or#88 from TimSiebert1/fix_tests
Browse files Browse the repository at this point in the history
Bugfix in uni5_for.c and in test
  • Loading branch information
awalther1 authored Dec 12, 2024
2 parents fdf625a + 3c1f1ed commit 76eb6a0
Show file tree
Hide file tree
Showing 3 changed files with 345 additions and 23 deletions.
26 changes: 15 additions & 11 deletions ADOL-C/boost-test/traceOperatorVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2507,11 +2507,11 @@ 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;
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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -2900,11 +2902,11 @@ 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;
bDerivative = -3.7;
a = std::fmin(2.5, 2.5);
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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -3163,13 +3166,14 @@ 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);
Expand Down
Loading

0 comments on commit 76eb6a0

Please sign in to comment.