Automatic Differentiation
 
Loading...
Searching...
No Matches
to_var.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_FUN_TO_VAR_HPP
2#define STAN_MATH_REV_FUN_TO_VAR_HPP
3
9#include <vector>
10
11namespace stan {
12namespace math {
13
22inline var to_var(double x) { return var(x); }
23
30inline var& to_var(var& x) { return x; }
31
38inline const var& to_var(const var& x) { return x; }
39
48inline std::vector<var> to_var(const std::vector<double>& v) {
49 std::vector<var> var_vector(v.size());
50 for (size_t n = 0; n < v.size(); n++) {
51 var_vector[n] = v[n];
52 }
53 return var_vector;
54}
55
64inline const std::vector<var>& to_var(const std::vector<var>& v) { return v; }
65
74inline std::vector<var>& to_var(std::vector<var>& v) { return v; }
75
84inline matrix_v to_var(const matrix_d& m) {
85 matrix_v m_v = m;
86 return m_v;
87}
88
95inline matrix_v& to_var(matrix_v& m) { return m; }
96
103inline const matrix_v& to_var(const matrix_v& m) { return m; }
104
114inline vector_v to_var(const vector_d& v) {
115 vector_v v_v = v;
116 return v_v;
117}
118
125inline const vector_v& to_var(const vector_v& v) { return v; }
126
133inline vector_v& to_var(vector_v& v) { return v; }
134
145 row_vector_v rv_v = rv;
146 return rv_v;
147}
148
155inline const row_vector_v& to_var(const row_vector_v& rv) { return rv; }
156
163inline row_vector_v& to_var(row_vector_v& rv) { return rv; }
164
165} // namespace math
166} // namespace stan
167#endif
var to_var(double x)
Converts argument to an automatic differentiation variable.
Definition to_var.hpp:22
Eigen::Matrix< var, Eigen::Dynamic, Eigen::Dynamic > matrix_v
The type of a matrix holding var values.
Definition typedefs.hpp:18
Eigen::Matrix< var, 1, Eigen::Dynamic > row_vector_v
The type of a row vector holding var values.
Definition typedefs.hpp:30
Eigen::Matrix< double, Eigen::Dynamic, 1 > vector_d
Type for (column) vector of double values.
Definition typedefs.hpp:24
Eigen::Matrix< var, Eigen::Dynamic, 1 > vector_v
The type of a (column) vector holding var values.
Definition typedefs.hpp:24
Eigen::Matrix< double, 1, Eigen::Dynamic > row_vector_d
Type for (row) vector of double values.
Definition typedefs.hpp:29
var_value< double > var
Definition var.hpp:1187
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > matrix_d
Type for matrix of double values.
Definition typedefs.hpp:19
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...