1 #ifndef STAN_MATH_FWD_MAT_FUN_TO_FVAR_HPP 2 #define STAN_MATH_FWD_MAT_FUN_TO_FVAR_HPP 12 template <
int R,
int C,
typename T>
13 inline Eigen::Matrix<T, R, C>
to_fvar(
const Eigen::Matrix<T, R, C>& m) {
17 template <
int R,
int C>
18 inline Eigen::Matrix<fvar<double>, R, C>
to_fvar(
19 const Eigen::Matrix<double, R, C>& m) {
20 Eigen::Matrix<fvar<double>, R, C> m_fd(m.rows(), m.cols());
21 for (
int i = 0; i < m.size(); ++i)
26 template <
typename T,
int R,
int C>
27 inline Eigen::Matrix<fvar<T>, R, C>
to_fvar(
28 const Eigen::Matrix<T, R, C>& val,
const Eigen::Matrix<T, R, C>& deriv) {
30 Eigen::Matrix<fvar<T>, R, C> ret(val.rows(), val.cols());
31 for (
int i = 0; i < val.rows(); i++) {
32 for (
int j = 0; j < val.cols(); j++) {
33 ret(i, j).val_ = val(i, j);
34 ret(i, j).d_ = deriv(i, j);
std::vector< fvar< T > > to_fvar(const std::vector< T > &v)
void check_matching_dims(const char *function, const char *name1, const matrix_cl &y1, const char *name2, const matrix_cl &y2)
Check if two matrix_cls have the same dimensions.