Stan Math Library  2.20.0
reverse mode automatic differentiation
to_fvar.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_FWD_ARR_FUN_TO_FVAR_HPP
2 #define STAN_MATH_FWD_ARR_FUN_TO_FVAR_HPP
3 
4 #include <stan/math/fwd/core.hpp>
6 #include <vector>
7 
8 namespace stan {
9 namespace math {
10 
11 template <typename T>
12 inline std::vector<fvar<T> > to_fvar(const std::vector<T>& v) {
13  std::vector<fvar<T> > x(v.size());
14  for (size_t i = 0; i < v.size(); ++i)
15  x[i] = T(v[i]);
16  return x;
17 }
18 
19 template <typename T>
20 inline std::vector<fvar<T> > to_fvar(const std::vector<T>& v,
21  const std::vector<T>& d) {
22  std::vector<fvar<T> > x(v.size());
23  for (size_t i = 0; i < v.size(); ++i)
24  x[i] = fvar<T>(v[i], d[i]);
25  return x;
26 }
27 
28 template <typename T>
29 inline std::vector<fvar<T> > to_fvar(const std::vector<fvar<T> >& v) {
30  return v;
31 }
32 
33 } // namespace math
34 } // namespace stan
35 #endif
std::vector< fvar< T > > to_fvar(const std::vector< T > &v)
Definition: to_fvar.hpp:12
This template class represents scalars used in forward-mode automatic differentiation, which consist of values and directional derivatives of the specified template type.
Definition: fvar.hpp:41

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