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 T_lhs,
typename T_rhs>
47 inline void assign(T_lhs& x,
const T_rhs& y) {
71 template <
typename T_lhs,
typename T_rhs,
int R1,
int C1,
int R2,
int C2>
72 inline void assign(Eigen::Matrix<T_lhs, R1, C1>& x,
73 const Eigen::Matrix<T_rhs, R2, C2>& y) {
75 ss <<
"shapes must match, but found" 76 <<
" left-hand side rows=";
77 print_mat_size<R1>(ss);
78 ss <<
"; left-hand side cols=";
79 print_mat_size<C1>(ss);
80 ss <<
"; right-hand side rows=";
81 print_mat_size<R2>(ss);
82 ss <<
"; right-hand side cols=";
83 print_mat_size<C2>(ss);
84 std::string ss_str(ss.str());
106 template <
typename T_lhs,
typename T_rhs,
int R,
int C>
107 inline void assign(Eigen::Matrix<T_lhs, R, C>& x,
108 const Eigen::Matrix<T_rhs, R, C>& y) {
110 for (
int i = 0; i < x.size(); ++i)
137 template <
typename T_lhs,
typename T,
int R,
int C>
138 inline void assign(Eigen::Block<T_lhs> x,
const Eigen::Matrix<T, R, C>& y) {
140 "right-hand side rows", y.rows());
142 "right-hand side cols", y.cols());
143 for (
int n = 0; n < y.cols(); ++n)
144 for (
int m = 0; m < y.rows(); ++m)
167 template <
typename T_lhs,
typename T_rhs>
168 inline void assign(std::vector<T_lhs>& x,
const std::vector<T_rhs>& y) {
170 for (
size_t i = 0; i < x.size(); ++i)
void print_mat_size(std::ostream &o)
Helper function to return the matrix size as either "dynamic" or "1".
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.
void check_matching_dims(const char *function, const char *name1, const matrix_cl &y1, const char *name2, const matrix_cl &y2)
Check if two matrix_cls have the same dimensions.
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.
void check_matching_sizes(const char *function, const char *name1, const T_y1 &y1, const char *name2, const T_y2 &y2)
Check if two structures at the same size.
void assign(T_lhs &x, const T_rhs &y)
Copy the right-hand side's value to the left-hand side variable.