Automatic Differentiation
 
Loading...
Searching...
No Matches
assign.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_ASSIGN_HPP
2#define STAN_MATH_PRIM_FUN_ASSIGN_HPP
3
6#include <iostream>
7#include <sstream>
8#include <stdexcept>
9#include <string>
10#include <vector>
11
12namespace stan {
13namespace math {
14
21template <int N>
22inline void print_mat_size(std::ostream& o) {
23 if (N == Eigen::Dynamic) {
24 o << "dynamically sized";
25 } else {
26 o << N;
27 }
28}
29
44template <typename T_lhs, typename T_rhs,
46inline void assign(T_lhs& x, const T_rhs& y) {
47 x = y;
48}
49
65template <typename T_lhs, typename T_rhs,
67inline void assign(T_lhs&& x, const T_rhs& y) {
68 check_matching_dims("assign", "left-hand-side", x, "right-hand-side", y);
69 x = y.template cast<value_type_t<T_lhs>>();
70}
71
91template <typename T_lhs, typename T_rhs>
92inline void assign(std::vector<T_lhs>& x, const std::vector<T_rhs>& y) {
93 check_matching_sizes("assign", "left-hand side", x, "right-hand side", y);
94 for (size_t i = 0; i < x.size(); ++i) {
95 assign(x[i], y[i]);
96 }
97}
98
99} // namespace math
100} // namespace stan
101
102#endif
require_all_t< is_eigen< std::decay_t< Types > >... > require_all_eigen_t
Require all of the types satisfy is_eigen.
Definition is_eigen.hpp:65
require_all_t< is_stan_scalar< std::decay_t< Types > >... > require_all_stan_scalar_t
Require all of the types satisfy is_stan_scalar.
void assign(T_lhs &x, const T_rhs &y)
Copy the right-hand side's value to the left-hand side variable.
Definition assign.hpp:46
void check_matching_dims(const char *function, const char *name1, const T1 &y1, const char *name2, const T2 &y2)
Check if the two containers have the same dimensions.
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 print_mat_size(std::ostream &o)
Helper function to return the matrix size as either "dynamic" or "1".
Definition assign.hpp:22
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Definition fvar.hpp:9