Skip to content

Eigen elementwise functions with autodiff variables #1783

Description

@andrjohns

Description

Now that Eigen's SIMD-vectorised elementwise functions have been introduced for containers of doubles (in #1471 and #1727), they should also be added for containers of fvar<T> and var.

Example

A quick example for using exp with fvar<T>:

template <typename Container,
          require_container_st<is_container, is_fvar, Container>...>
inline auto exp(const Container& x) {
  return apply_vector_unary<Container>::apply(
      x, [](const auto& v) {
        auto exp_val = exp(v.val());
        return to_fvar(exp_val,exp_val.cwiseProduct(v.d()));
});
}

Current Version:

v3.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions