1#ifndef STAN_MATH_REV_FUN_APPEND_ROW_HPP
2#define STAN_MATH_REV_FUN_APPEND_ROW_HPP
32template <
typename T1,
typename T2, require_any_var_matrix_t<T1, T2>* =
nullptr>
33inline auto append_row(
const T1& A,
const T2& B) {
36 if (!is_constant<T1>::value && !is_constant<T2>::value) {
37 arena_t<promote_scalar_t<var, T1>> arena_A = A;
38 arena_t<promote_scalar_t<var, T2>> arena_B = B;
41 [arena_A, arena_B](
auto& vi)
mutable {
42 arena_A.adj() += vi.adj().topRows(arena_A.rows());
43 arena_B.adj() += vi.adj().bottomRows(arena_B.rows());
45 }
else if (!is_constant<T1>::value) {
46 arena_t<promote_scalar_t<var, T1>> arena_A = A;
48 [arena_A](
auto& vi)
mutable {
50 += vi.adj().topRows(arena_A.rows());
53 arena_t<promote_scalar_t<var, T2>> arena_B = B;
55 [arena_B](
auto& vi)
mutable {
57 += vi.adj().bottomRows(arena_B.rows());
75template <
typename Scal,
typename ColVec,
76 require_stan_scalar_t<Scal>* =
nullptr,
77 require_t<is_eigen_col_vector<ColVec>>* =
nullptr>
83 [arena_A, arena_B](
auto& vi)
mutable {
84 arena_A.adj() += vi.adj().coeff(0);
85 arena_B.adj() += vi.adj().tail(arena_B.size());
91 [arena_A](
auto& vi)
mutable { arena_A.adj() += vi.adj().coeff(0); });
95 [arena_B](
auto& vi)
mutable {
96 arena_B.adj() += vi.adj().tail(arena_B.size());
114template <
typename ColVec,
typename Scal,
122 [arena_A, arena_B](
auto& vi)
mutable {
123 arena_A.adj() += vi.adj().head(arena_A.size());
125 += vi.adj().coeff(vi.adj().size() - 1);
130 [arena_A](
auto& vi)
mutable {
131 arena_A.adj() += vi.adj().head(arena_A.size());
136 [arena_B](
auto& vi)
mutable {
138 += vi.adj().coeff(vi.adj().size() - 1);
auto append_row(Ta &&a, Tb &&b)
Stack the rows of the first argument on top of the second argument.
require_t< is_stan_scalar< std::decay_t< T > > > require_stan_scalar_t
Require type satisfies is_stan_scalar.
var_value< plain_type_t< T > > make_callback_var(T &&value, F &&functor)
Creates a new var initialized with a callback_vari with a given value and reverse-pass callback funct...
T value_of(const fvar< T > &v)
Return the value of the specified variable.
void check_size_match(const char *function, const char *name_i, T_size1 i, const char *name_j, T_size2 j)
Check if the provided sizes match.
typename internal::arena_type_impl< std::decay_t< T > >::type arena_t
Determines a type that can be used in place of T that does any dynamic allocations on the AD stack.
std::enable_if_t< Check::value > require_t
If condition is true, template is enabled.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Metaprogramming struct to detect whether a given type is constant in the mathematical sense (not the ...