1 #ifndef STAN_MATH_PRIM_MAT_FUN_ASSIGN_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_ASSIGN_HPP
26 if (n == Eigen::Dynamic)
27 o <<
"dynamically sized";
46 template <
typename LHS,
typename RHS>
72 template <
typename LHS,
typename RHS,
int R1,
int C1,
int R2,
int C2>
74 assign(Eigen::Matrix<LHS, R1, C1>& x,
75 const Eigen::Matrix<RHS, R2, C2>& y) {
77 ss <<
"shapes must match, but found"
78 <<
" left-hand side rows=";
80 ss <<
"; left-hand side cols=";
82 ss <<
"; right-hand side rows=";
84 ss <<
"; right-hand side cols=";
86 std::string ss_str(ss.str());
88 "",
"", ss_str.c_str());
108 template <
typename LHS,
typename RHS,
int R,
int C>
111 const Eigen::Matrix<RHS, R, C>& y) {
114 "right-hand-side", y);
115 for (
int i = 0; i < x.size(); ++i)
137 template <
typename LHS,
typename RHS,
int R,
int C>
140 const Eigen::Matrix<RHS, R, C>& y) {
142 "left-hand side rows", x.rows(),
143 "right-hand side rows", y.rows());
145 "left-hand side cols", x.cols(),
146 "right-hand side cols", y.cols());
147 for (
int n = 0; n < y.cols(); ++n)
148 for (
int m = 0; m < y.rows(); ++m)
171 template <
typename LHS,
typename RHS>
173 assign(std::vector<LHS>& x,
const std::vector<RHS>& y) {
176 "right-hand side", y);
177 for (
size_t i = 0; i < x.size(); ++i)
bool check_matching_dims(const char *function, const char *name1, const Eigen::Matrix< T1, R1, C1 > &y1, const char *name2, const Eigen::Matrix< T2, R2, C2 > &y2)
Return true if the two matrices are of the same size.
void invalid_argument(const char *function, const char *name, const T &y, const char *msg1, const char *msg2)
Throw an invalid_argument exception with a consistently formatted message.
bool check_size_match(const char *function, const char *name_i, T_size1 i, const char *name_j, T_size2 j)
Return true if the provided sizes match.
bool check_matching_sizes(const char *function, const char *name1, const T_y1 &y1, const char *name2, const T_y2 &y2)
Return true if two structures at the same size.
void assign(LHS &lhs, const RHS &rhs)
Copy the right-hand side's value to the left-hand side variable.
void print_mat_size(int n, std::ostream &o)
Helper function to return the matrix size as either "dynamic" or "1".