1 #ifndef STAN_MATH_PRIM_MAT_FUN_APPEND_COL_HPP 2 #define STAN_MATH_PRIM_MAT_FUN_APPEND_COL_HPP 35 template <
typename T1,
typename T2,
int R1,
int C1,
int R2,
int C2>
36 inline Eigen::Matrix<typename return_type<T1, T2>::type, Eigen::Dynamic,
39 const Eigen::Matrix<T2, R2, C2>& B) {
49 Matrix<typename return_type<T1, T2>::type, Dynamic, Dynamic> result(
50 Arows, Acols + Bcols);
51 for (
int j = 0; j < Acols; j++)
52 for (
int i = 0; i < Arows; i++)
53 result(i, j) = A(i, j);
55 for (
int j = Acols, k = 0; k < Bcols; j++, k++)
56 for (
int i = 0; i < Arows; i++)
57 result(i, j) = B(i, k);
78 template <
typename T1,
typename T2,
int C1,
int C2>
79 inline Eigen::Matrix<typename return_type<T1, T2>::type, 1, Eigen::Dynamic>
81 const Eigen::Matrix<T2, 1, C2>& B) {
87 Matrix<typename return_type<T1, T2>::type, 1, Dynamic> result(Asize + Bsize);
88 for (
int i = 0; i < Asize; i++)
90 for (
int i = 0, j = Asize; i < Bsize; i++, j++)
119 template <
typename T,
int R1,
int C1,
int R2,
int C2>
120 inline Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>
append_col(
121 const Eigen::Matrix<T, R1, C1>& A,
const Eigen::Matrix<T, R2, C2>& B) {
122 using Eigen::Dynamic;
125 check_size_match(
"append_col",
"rows of A", A.rows(),
"rows of B", B.rows());
127 Matrix<T, Dynamic, Dynamic> result(A.rows(), A.cols() + B.cols());
148 template <
typename T,
int C1,
int C2>
150 const Eigen::Matrix<T, 1, C1>& A,
const Eigen::Matrix<T, 1, C2>& B) {
151 using Eigen::Dynamic;
154 Matrix<T, 1, Dynamic> result(A.size() + B.size());
173 template <
typename T1,
typename T2,
int R,
int C>
174 inline Eigen::Matrix<typename return_type<T1, T2>::type, 1, Eigen::Dynamic>
176 using Eigen::Dynamic;
180 Matrix<return_type, 1, Dynamic> result(B.size() + 1);
181 result << A, B.template cast<return_type>();
199 template <
typename T1,
typename T2,
int R,
int C>
200 inline Eigen::Matrix<typename return_type<T1, T2>::type, 1, Eigen::Dynamic>
202 using Eigen::Dynamic;
206 Matrix<return_type, 1, Dynamic> result(A.size() + 1);
207 result << A.template cast<return_type>(), B;
Eigen::Matrix< typename return_type< T1, T2 >::type, Eigen::Dynamic, Eigen::Dynamic > append_col(const Eigen::Matrix< T1, R1, C1 > &A, const Eigen::Matrix< T2, R2, C2 > &B)
Return the result of appending the second argument matrix after the first argument matrix...
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.
boost::math::tools::promote_args< double, typename scalar_type< T >::type, typename return_type< Types_pack... >::type >::type type