Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions common/autodiff_overloads.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,19 @@ pow(const Eigen::AutoDiffScalar<DerTypeA>& base,
typename internal::remove_all<DerTypeA>::type::PlainObject,
typename internal::remove_all<DerTypeB>::type::PlainObject>,
"The derivative types must match.");

internal::make_coherent(base.derivatives(), exponent.derivatives());
using DerType = typename internal::remove_all<DerTypeB>::type::PlainObject;

const auto& x = base.value();
const auto& xgrad = base.derivatives();
const DerType& xgrad = base.derivatives();
const auto& y = exponent.value();
const auto& ygrad = exponent.derivatives();
const DerType& ygrad = exponent.derivatives();

// Make the derivative sizes coherenent.
if (xgrad.size() == 0 && ygrad.size() > 0) {
return pow(MakeAutoDiffScalar(x, DerType::Zero(ygrad.size())), exponent);
} else if (xgrad.size() > 0 && ygrad.size() == 0) {
return pow(base, MakeAutoDiffScalar(y, DerType::Zero(xgrad.size())));
}

using std::log;
using std::pow;
Expand Down