All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
to_var.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_REV_MAT_FUN_TO_VAR_HPP
#define STAN_MATH_REV_MAT_FUN_TO_VAR_HPP
#include <stan/math/prim/mat/fun/Eigen.hpp>
#include <stan/math/prim/mat/fun/typedefs.hpp>
#include <stan/math/rev/core.hpp>
#include <stan/math/rev/mat/fun/typedefs.hpp>
#include <vector>
namespace stan {
namespace math {
inline var to_var(const double& x) {
return var(x);
}
inline var to_var(const var& x) {
return x;
}
inline matrix_v to_var(const stan::math::matrix_d& m) {
matrix_v m_v(m.rows(), m.cols());
for (int j = 0; j < m.cols(); ++j)
for (int i = 0; i < m.rows(); ++i)
m_v(i, j) = m(i, j);
return m_v;
}
inline matrix_v to_var(const matrix_v& m) {
return m;
}
inline vector_v to_var(const stan::math::vector_d& v) {
vector_v v_v(v.size());
for (int i = 0; i < v.size(); ++i)
v_v[i] = v[i];
return v_v;
}
inline vector_v to_var(const vector_v& v) {
return v;
}
inline row_vector_v to_var(const stan::math::row_vector_d& rv) {
row_vector_v rv_v(rv.size());
for (int i = 0; i < rv.size(); ++i)
rv_v[i] = rv[i];
return rv_v;
}
inline row_vector_v to_var(const row_vector_v& rv) {
return rv;
}
}
}
#endif
core.hpp
stan::math::vector_v
Eigen::Matrix< var, Eigen::Dynamic, 1 > vector_v
The type of a (column) vector holding stan::math::var values.
Definition: typedefs.hpp:29
stan::math::vector_d
Eigen::Matrix< double, Eigen::Dynamic, 1 > vector_d
Type for (column) vector of double values.
Definition: typedefs.hpp:30
stan::math::row_vector_d
Eigen::Matrix< double, 1, Eigen::Dynamic > row_vector_d
Type for (row) vector of double values.
Definition: typedefs.hpp:37
stan::math::var
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:32
stan::math::matrix_v
Eigen::Matrix< var, Eigen::Dynamic, Eigen::Dynamic > matrix_v
The type of a matrix holding stan::math::var values.
Definition: typedefs.hpp:21
stan::math::to_var
var to_var(const double &x)
Converts argument to an automatic differentiation variable.
Definition: to_var.hpp:21
typedefs.hpp
Eigen.hpp
stan::math::matrix_d
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > matrix_d
Type for matrix of double values.
Definition: typedefs.hpp:23
stan::math::row_vector_v
Eigen::Matrix< var, 1, Eigen::Dynamic > row_vector_v
The type of a row vector holding stan::math::var values.
Definition: typedefs.hpp:37
typedefs.hpp

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