Stan  1.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
assign_to_var.hpp
Go to the documentation of this file.
1 #ifndef __STAN__AGRAD__REV__MATRIX__ASSIGN_TO_VAR_HPP__
2 #define __STAN__AGRAD__REV__MATRIX__ASSIGN_TO_VAR_HPP__
3 
4 #include <vector>
5 #include <boost/math/tools/promotion.hpp>
8 #include <stan/agrad/rev/var.hpp>
12 
13 namespace stan {
14  namespace agrad {
15 
16  // FIXME: double val?
17  inline void assign_to_var(stan::agrad::var& var, const double& val) {
18  var = val;
19  }
20  inline void assign_to_var(stan::agrad::var& var, const stan::agrad::var& val) {
21  var = val;
22  }
23  // FIXME: int val?
24  inline void assign_to_var(int& n_lhs, const int& n_rhs) {
25  n_lhs = n_rhs; // FIXME: no call -- just filler to instantiate
26  }
27  // FIXME: double val?
28  inline void assign_to_var(double& n_lhs, const double& n_rhs) {
29  n_lhs = n_rhs; // FIXME: no call -- just filler to instantiate
30  }
31 
32  template <typename LHS, typename RHS>
33  inline void assign_to_var(std::vector<LHS>& x, const std::vector<RHS>& y) {
34  stan::math::validate_matching_sizes(x,y,"assign_to_var");
35  for (size_t i = 0; i < x.size(); ++i)
36  assign_to_var(x[i],y[i]);
37  }
38  template <typename LHS, typename RHS, int R, int C>
39  inline void assign_to_var(Eigen::Matrix<LHS,R,C>& x,
40  const Eigen::Matrix<RHS,R,C>& y) {
41  stan::math::validate_matching_sizes(x,y,"assign_to_var");
42  for (size_type n = 0; n < x.cols(); ++n)
43  for (size_type m = 0; m < x.rows(); ++m)
44  assign_to_var(x(m,n),y(m,n));
45  }
46 
47  template <typename LHS, typename RHS, int R, int C>
48  inline void assign_to_var(Eigen::Block<LHS>& x,
49  const Eigen::Matrix<RHS,R,C>& y) {
50  stan::math::validate_matching_sizes(x,y,"assign_to_var");
51  for (size_type n = 0; n < y.cols(); ++n)
52  for (size_type m = 0; m < y.rows(); ++m)
53  assign_to_var(x(m,n),y(m,n));
54  }
55 
56  }
57 }
58 #endif

     [ Stan Home Page ] © 2011–2013, Stan Development Team.