1 #ifndef STAN_MATH_PRIM_MAT_FUN_APPEND_ROW_HPP 2 #define STAN_MATH_PRIM_MAT_FUN_APPEND_ROW_HPP 33 template <
typename T1,
typename T2,
int R1,
int C1,
int R2,
int C2>
34 inline Eigen::Matrix<typename return_type<T1, T2>::type, Eigen::Dynamic,
37 const Eigen::Matrix<T2, R2, C2>& B) {
45 check_size_match(
"append_row",
"columns of A", Acols,
"columns of B", Bcols);
47 Matrix<typename return_type<T1, T2>::type, Dynamic, Dynamic> result(
48 Arows + Brows, Acols);
49 for (
int j = 0; j < Acols; j++) {
50 for (
int i = 0; i < Arows; i++)
51 result(i, j) = A(i, j);
52 for (
int i = Arows, k = 0; k < Brows; i++, k++)
53 result(i, j) = B(k, j);
73 template <
typename T1,
typename T2,
int R1,
int R2>
74 inline Eigen::Matrix<typename return_type<T1, T2>::type, Eigen::Dynamic, 1>
76 const Eigen::Matrix<T2, R2, 1>& B) {
82 Matrix<typename return_type<T1, T2>::type, 1, Dynamic> result(Asize + Bsize);
83 for (
int i = 0; i < Asize; i++)
85 for (
int i = 0, j = Asize; i < Bsize; i++, j++)
112 template <
typename T,
int R1,
int C1,
int R2,
int C2>
113 inline Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>
append_row(
114 const Eigen::Matrix<T, R1, C1>& A,
const Eigen::Matrix<T, R2, C2>& B) {
115 using Eigen::Dynamic;
121 Matrix<T, Dynamic, Dynamic> result(A.rows() + B.rows(), A.cols());
142 template <
typename T,
int R1,
int R2>
144 const Eigen::Matrix<T, R1, 1>& A,
const Eigen::Matrix<T, R2, 1>& B) {
145 using Eigen::Dynamic;
148 Matrix<T, Dynamic, 1> result(A.size() + B.size());
166 template <
typename T1,
typename T2,
int R,
int C>
167 inline Eigen::Matrix<typename return_type<T1, T2>::type, Eigen::Dynamic, 1>
169 using Eigen::Dynamic;
173 Matrix<return_type, Dynamic, 1> result(B.size() + 1);
174 result << A, B.template cast<return_type>();
191 template <
typename T1,
typename T2,
int R,
int C>
192 inline Eigen::Matrix<typename return_type<T1, T2>::type, Eigen::Dynamic, 1>
194 using Eigen::Dynamic;
198 Matrix<return_type, Dynamic, 1> result(A.size() + 1);
199 result << A.template cast<return_type>(), B;
Template metaprogram to calculate the base scalar return type resulting from promoting all the scalar...
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.
Eigen::Matrix< typename return_type< T1, T2 >::type, Eigen::Dynamic, Eigen::Dynamic > append_row(const Eigen::Matrix< T1, R1, C1 > &A, const Eigen::Matrix< T2, R2, C2 > &B)
Return the result of stacking the rows of the first argument matrix on top of the second argument mat...
boost::math::tools::promote_args< double, typename scalar_type< T >::type, typename return_type< Types_pack... >::type >::type type