Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/feature/reverse-mod…
Browse files Browse the repository at this point in the history
…e-move-semantics' into feature/reverse-mode-move-semantics
  • Loading branch information
SteveBronder committed Aug 2, 2023
2 parents e5e226b + 3f07884 commit d66673b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
3 changes: 1 addition & 2 deletions stan/math/prim/prob/normal_lpdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ namespace math {
template <bool propto, typename T_y, typename T_loc, typename T_scale,
require_all_not_nonscalar_prim_or_rev_kernel_expression_t<
T_y, T_loc, T_scale>* = nullptr>
inline return_type_t<T_y, T_loc, T_scale> normal_lpdf(T_y&& y,
T_loc&& mu,
inline return_type_t<T_y, T_loc, T_scale> normal_lpdf(T_y&& y, T_loc&& mu,
T_scale&& sigma) {
using T_partials_return = partials_return_t<T_y, T_loc, T_scale>;
using T_y_ref = ref_type_if_t<!is_constant<T_y>::value, T_y>;
Expand Down
17 changes: 11 additions & 6 deletions stan/math/rev/core/arena_matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,14 @@ class arena_matrix : public Eigen::Map<MatrixType> {
}

/**
* Constructs `arena_matrix` from an expression, then send it to either the object stack or memory arena.
* @tparam T A type that inherits from Eigen::DenseBase that is not an `arena_matrix`.
* Constructs `arena_matrix` from an expression, then send it to either the
* object stack or memory arena.
* @tparam T A type that inherits from Eigen::DenseBase that is not an
* `arena_matrix`.
* @param other expression
* @note When T is both an rvalue and a plain type, the expression is moved to the object stack. However
* when T is an lvalue, or an rvalue that is not a plain type, the expression is copied to the memory arena.
* @note When T is both an rvalue and a plain type, the expression is moved to
* the object stack. However when T is an lvalue, or an rvalue that is not a
* plain type, the expression is copied to the memory arena.
*/
template <typename T, require_eigen_t<T>* = nullptr,
require_not_arena_matrix_t<T>* = nullptr>
Expand All @@ -87,9 +90,11 @@ class arena_matrix : public Eigen::Map<MatrixType> {
using base_map_t =
typename stan::math::arena_matrix<MatrixType>::Base::Map;
using T_t = std::decay_t<T>;
if (std::is_rvalue_reference<decltype(x)>::value && is_plain_type<T_t>::value) {
if (std::is_rvalue_reference<decltype(x)>::value
&& is_plain_type<T_t>::value) {
// Note: plain_type_t here does nothing since T_t is plain type
auto other = make_chainable_ptr(plain_type_t<MatrixType>(std::move(x)));
auto other
= make_chainable_ptr(plain_type_t<MatrixType>(std::move(x)));
return base_map_t(
&(other->coeffRef(0)),
(RowsAtCompileTime == 1 && T_t::ColsAtCompileTime == 1)
Expand Down

0 comments on commit d66673b

Please sign in to comment.