Automatic Differentiation
 
Loading...
Searching...
No Matches
read_fvar.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_FWD_FUN_READ_FVAR_HPP
2#define STAN_MATH_FWD_FUN_READ_FVAR_HPP
3
5
6namespace stan {
7namespace math {
8
13template <typename EigFvar, typename EigOut>
15 const EigFvar& var_mat;
16 EigOut& val_mat;
17
18 public:
19 read_fvar_functor(const EigFvar& arg1, EigOut& arg2)
20 : var_mat(arg1), val_mat(arg2) {}
21
22 inline decltype(auto) operator()(Eigen::Index row, Eigen::Index col) const {
23 val_mat.coeffRef(row, col) = var_mat.coeffRef(row, col).val_;
24 return var_mat.coeffRef(row, col).d_;
25 }
26
27 inline decltype(auto) operator()(Eigen::Index index) const {
28 val_mat.coeffRef(index) = var_mat.coeffRef(index).val_;
29 return var_mat.coeffRef(index).d_;
30 }
31};
32
43template <typename EigFvar, typename EigOut>
44inline void read_fvar(const EigFvar& FvarMat, EigOut& ValMat, EigOut& DMat) {
45 DMat = EigOut::NullaryExpr(
46 FvarMat.rows(), FvarMat.cols(),
48}
49
50} // namespace math
51} // namespace stan
52#endif
read_fvar_functor(const EigFvar &arg1, EigOut &arg2)
Definition read_fvar.hpp:19
Functor for extracting the values and tangents from a matrix of fvar.
Definition read_fvar.hpp:14
auto col(T_x &&x, size_t j)
Return the specified column of the specified kernel generator expression using start-at-1 indexing.
Definition col.hpp:23
auto row(T_x &&x, size_t j)
Return the specified row of the specified kernel generator expression using start-at-1 indexing.
Definition row.hpp:23
void read_fvar(const EigFvar &FvarMat, EigOut &ValMat, EigOut &DMat)
Function applying the read_fvar_functor to extract the values and tangets of a given fvar matrix into...
Definition read_fvar.hpp:44
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...