Stan  1.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
to_var.hpp
Go to the documentation of this file.
1 #ifndef __STAN__AGRAD__REV__MATRIX__TO_VAR_HPP__
2 #define __STAN__AGRAD__REV__MATRIX__TO_VAR_HPP__
3 
4 #include <vector>
7 #include <stan/agrad/rev/var.hpp>
9 
10 namespace stan {
11  namespace agrad {
12 
21  inline var to_var(const double& x) {
22  return var(x);
23  }
32  inline var to_var(const var& x) {
33  return x;
34  }
44  matrix_v m_v(m.rows(), m.cols());
45  for (int j = 0; j < m.cols(); ++j)
46  for (int i = 0; i < m.rows(); ++i)
47  m_v(i,j) = m(i,j);
48  return m_v;
49  }
58  inline matrix_v to_var(const matrix_v& m) {
59  return m;
60  }
71  vector_v v_v(v.size());
72  for (int i = 0; i < v.size(); ++i)
73  v_v[i] = v[i];
74  return v_v;
75  }
85  inline vector_v to_var(const vector_v& v) {
86  return v;
87  }
98  row_vector_v rv_v(rv.size());
99  for (int i = 0; i < rv.size(); ++i)
100  rv_v[i] = rv[i];
101  return rv_v;
102  }
112  inline row_vector_v to_var(const row_vector_v& rv) {
113  return rv;
114  }
115 
116  }
117 }
118 #endif

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