Skip to content

autodiff::fvar doesn't work with Eigen #424

@wgledbetter

Description

@wgledbetter

Currently, the templated copy constructor for autodiff::fvar interferes with Eigen's lazy evaluation, and, in my experience, produces two types of errors:

  1. Ambiguous operators
  • Example error: ambiguous overload for ‘operator*’ (operand types are ‘Eigen::Transpose<Eigen::Matrix<boost::math::differentiation::autodiff_v1::detail::fvar<double, 1>, 4, 1> >’ and ‘Eigen::Matrix<boost::math::differentiation::autodiff_v1::detail::fvar<double, 1>, 4, 1>’)
  1. Failed attempts to static_cast a matrix into an fvar
  • Example error: error: invalid ‘static_cast’ from type ‘const Eigen::CwiseUnaryOp<Eigen::internal::scalar_cast_op<double, boost::math::differentiation::autodiff_v1::detail::fvar<double, 1> >, const Eigen::Matrix<double, 4, 4> >’ to type ‘double’

A solution would be to only define the constructor for types that are convertible to the fvar's RealType. A colleague and I worked out a potential fix using SFINAE that I'm currently testing against the existing test_autodiff files. Tests 1-3 have succeeded with the existing travis configuration, but I'm having issues in test_autodiff_4 with boost::has_right_shift as called from boost::lexical_cast.

Is there any interest in merging a solution to this problem? I can post the work I've done so far.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions