Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix - pow(Eigen, Eigen) forcing Matrix return #2793

Merged
merged 4 commits into from
Jul 14, 2022
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
11 changes: 6 additions & 5 deletions stan/math/rev/fun/pow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,12 @@ template <typename Mat1, typename Mat2,
require_all_not_stan_scalar_t<Mat1, Mat2>* = nullptr>
inline auto pow(const Mat1& base, const Mat2& exponent) {
check_consistent_sizes("pow", "base", base, "exponent", exponent);

using val_type = decltype(as_array_or_scalar(value_of(base))
.pow(as_array_or_scalar(value_of(exponent)))
.matrix()
.eval());
using expr_type = decltype(as_array_or_scalar(value_of(base))
.pow(as_array_or_scalar(value_of(exponent))));
using val_type = std::conditional_t<
math::disjunction<is_eigen_array<Mat1>, is_eigen_array<Mat2>>::value,
decltype(std::declval<expr_type>().eval()),
decltype(std::declval<expr_type>().matrix().eval())>;
using ret_type = return_var_matrix_t<val_type, Mat1, Mat2>;
using base_t = decltype(as_array_or_scalar(base));
using exp_t = decltype(as_array_or_scalar(exponent));
Expand Down