Stan
1.3
probability, sampling & optimization
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerator
Friends
Macros
Pages
src
stan
agrad
rev
matrix
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>
5
#include <
stan/math/matrix/Eigen.hpp
>
6
#include <
stan/math/matrix/typedefs.hpp
>
7
#include <
stan/agrad/rev/var.hpp
>
8
#include <
stan/agrad/rev/matrix/typedefs.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
}
43
inline
matrix_v
to_var
(
const
stan::math::matrix_d
& m) {
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
}
70
inline
vector_v
to_var
(
const
stan::math::vector_d
& v) {
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
}
97
inline
row_vector_v
to_var
(
const
stan::math::row_vector_d
& rv) {
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.