Skip to content

Commit

Permalink
Set active variables
Browse files Browse the repository at this point in the history
  • Loading branch information
wgledbetter committed Aug 31, 2020
1 parent 22851b3 commit 22fc7a3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
32 changes: 17 additions & 15 deletions include/boost/math/differentiation/autodiff_eigen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,23 @@ BOOST_AUTODIFF_EIGEN_SCALAR_TRAITS(unsigned int);
BOOST_AUTODIFF_EIGEN_SCALAR_TRAITS(long);
BOOST_AUTODIFF_EIGEN_SCALAR_TRAITS(unsigned long);

template <typename RealType, size_t Order, typename RealType2, size_t Order2,
typename BinaryOp>
struct ScalarBinaryOpTraits<
boost::math::differentiation::autodiff_v1::detail::template fvar<RealType,
Order>,
boost::math::differentiation::autodiff_v1::detail::template fvar<RealType2,
Order2>,
BinaryOp> {
typedef ScalarBinaryOpTraits<RealType, RealType2, BinaryOp>::ReturnType
RealReturn;
const size_t ReturnOrder = (Order > Order2) ? Order : Order2;
typedef boost::math::differentiation::autodiff_v1::detail::template fvar<
RealReturn, ReturnOrder>
ReturnType;
};
// template <typename RealType, size_t Order, typename RealType2, size_t Order2,
// typename BinaryOp>
// struct ScalarBinaryOpTraits<
// boost::math::differentiation::autodiff_v1::detail::template
// fvar<RealType,
// Order>,
// boost::math::differentiation::autodiff_v1::detail::template
// fvar<RealType2,
// Order2>,
// BinaryOp> {
// typedef ScalarBinaryOpTraits<RealType, RealType2, BinaryOp>::ReturnType
// RealReturn;
// const size_t ReturnOrder = (Order > Order2) ? Order : Order2;
// typedef boost::math::differentiation::autodiff_v1::detail::template fvar<
// RealReturn, ReturnOrder>
// ReturnType;
// };
} // namespace Eigen

#endif // BOOST_MATH_DIFFERENTIATION_AUTODIFF_EIGEN_HPP
14 changes: 7 additions & 7 deletions test/test_autodiff_9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(eigen_general, T, all_float_types) {

typedef typename fvar<T, n> fTn;
Eigen::Matrix<fTn, dim, 1> x;
x[0] = -1;
x[1] = 0;
x[2] = 1;
x[3] = 5;
x[0] = make_fvar<T, n>(-1);
x[1] = make_fvar<T, n>(0);
x[2] = make_fvar<T, n>(1);
x[3] = make_fvar<T, n>(5);

Eigen::Matrix<fTn, dim, 1> y1, y2, y3, y4, y5;
y1 = sin(x);
Expand Down Expand Up @@ -132,7 +132,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(eigen_scalar, T, all_float_types) {
constexpr size_t n = 4;

typedef typename fvar<T, n> fTn;
fTn x = 4;
fTn x = make_fvar<T, n>(4);
Eigen::Matrix<fTn, dim, 1> X;
Eigen::Matrix<fTn, dim, 1> Z;
Eigen::Matrix<fTn, dim, dim> I = Eigen::Matrix<fTn, dim, dim>::Identity();
Expand Down Expand Up @@ -171,7 +171,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(eigen_vector, T, all_float_types) {
constexpr size_t n = 4;

typedef typename fvar<T, n> fTn;
fTn x = 5;
fTn x = make_fvar<T, n>(5);
T xD0 = x.derivative(0);
Eigen::Matrix<fTn, dim, 1> X;
X[0] = 1;
Expand Down Expand Up @@ -231,7 +231,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(eigen_determinant, T, all_float_types) {
constexpr size_t n = 1;

typedef typename fvar<T, n> fTn;
fTn x = 3;
fTn x = make_fvar<T, n>(3);
T xD0 = x.derivative(0);
Eigen::Matrix<fTn, dim, dim> M = 10 * Eigen::Matrix<fTn, dim, dim>::Random();
M(0, 3) = x;
Expand Down

0 comments on commit 22fc7a3

Please sign in to comment.