/* Derivative of cosh is sinh. */
double aDerivative = std::sinh(a);
ad.setADValue(0, 1.);
ad = adtl::cosh(ad);
BOOST_TEST(ad.getADValue(0) == aDerivative, tt::tolerance(tol));
}
BOOST_AUTO_TEST_CASE(TanhOperatorPrimal)
{
double a = 4.;
adouble ad = a;
a = std::tanh(a);
ad = adtl::tanh(ad);
BOOST_TEST(ad.getValue() == a, tt::tolerance(tol));
}
BOOST_AUTO_TEST_CASE(TanhOperatorDerivative)
{
double a = 4.;
adouble ad = a;
a = std::tanh(a);
/* Derivative value 1./(cosh*cosh) = 1 - tanh*tanh. */
double aDerivative = 1 - a*a;
ad.setADValue(0, 1.);
ad = adtl::tanh(ad);
BOOST_TEST(ad.getADValue(0) == aDerivative, tt::tolerance(tol));
}
BOOST_AUTO_TEST_CASE(AsinOperatorPrimal)
{
double a = 0.9;
adouble ad = a;
a = std::asin(a);
ad = adtl::asin(ad);
BOOST_TEST(ad.getValue() == a, tt::tolerance(tol));
}
BOOST_AUTO_TEST_CASE(AsinOperatorDerivative)
{
double a = 0.9;
adouble ad = a;
/* Derivative value 1. / sqrt(1. - a*a). */
double aDerivative = 1. / (std::sqrt(1. - a*a));
ad.setADValue(0, 1.);
ad = adtl::asin(ad);
BOOST_TEST(ad.getADValue(0) == aDerivative, tt::tolerance(tol));
}
BOOST_AUTO_TEST_CASE(AcosOperatorPrimal)
{
double a = 0.8;
adouble ad = a;
a = std::acos(a);
ad = adtl::acos(ad);
BOOST_TEST(ad.getValue() == a, tt::tolerance(tol));
}
BOOST_AUTO_TEST_CASE(AcosOperatorDerivative)
{
double a = 0.8;
adouble ad = a;
/* Derivative value -1. / sqrt(1. - a*a). */
double aDerivative = -1. / (std::sqrt(1. - a*a));
ad.setADValue(0, 1.);
ad = adtl::acos(ad);
BOOST_TEST(ad.getADValue(0) == aDerivative, tt::tolerance(tol));
}
BOOST_AUTO_TEST_CASE(AtanOperatorPrimal)
{
double a = 9.8;
adouble ad = a;
a = std::atan(a);
ad = adtl::atan(ad);
BOOST_TEST(ad.getValue() == a, tt::tolerance(tol));
}
BOOST_AUTO_TEST_CASE(AtanOperatorDerivative)
{
double a = 9.8;
adouble ad = a;
/* Derivative value 1./(1. + a*a). */
double aDerivative = 1. / (1. + a*a);
ad.setADValue(0, 1.);
ad = adtl::atan(ad);
BOOST_TEST(ad.getADValue(0) == aDerivative, tt::tolerance(tol));
}
BOOST_AUTO_TEST_CASE(Log10OperatorPrimal)
{
double a = 12.3;
adouble ad = a;
a = std::log10(a);
ad = adtl::log10(ad);
BOOST_TEST(ad.getValue() == a, tt::tolerance(tol));
}
BOOST_AUTO_TEST_CASE(Log10OperatorDerivative)
{
double a = 12.3;
adouble ad = a;
/* Derivative value 1. / (log(10)*a), because log10(a) = log(a)/log(10). */
double aDerivative = 1. / (a * std::log(10));
ad.setADValue(0, 1.);
ad = adtl::log10(ad);
BOOST_TEST(ad.getADValue(0) == aDerivative, tt::tolerance(tol));
}
#if defined(ATRIG_ERF)
BOOST_AUTO_TEST_CASE(AsinhOperatorPrimal)
{
double a = 0.6;
adouble ad = a;
a = std::asinh(a);
ad = adtl::asinh(ad);
BOOST_TEST(ad.getValue() == a, tt::tolerance(tol));
}
BOOST_AUTO_TEST_CASE(AsinhOperatorDerivative)
{
double a = 0.6;
adouble ad = a;
double aDerivative = 1. / (std::sqrt(a*a + 1.));
ad.setADValue(0, 1.);
ad = adtl::asinh(ad);