1#ifndef STAN_MATH_PRIM_FUN_VALUE_OF_HPP
2#define STAN_MATH_PRIM_FUN_VALUE_OF_HPP
20template <
typename T, require_st_arithmetic<T>* =
nullptr>
22 return std::forward<T>(x);
25template <
typename T, require_complex_t<T>* =
nullptr,
26 require_t<std::is_arithmetic<
27 typename std::decay_t<T>::value_type>>* =
nullptr>
29 return std::forward<T>(x);
48template <
typename T, require_std_vector_t<T>* =
nullptr,
49 require_not_st_arithmetic<T>* =
nullptr>
53 out.reserve(x.size());
54 for (
auto&& x_elem : x) {
70template <
typename EigMat, require_eigen_dense_base_t<EigMat>* =
nullptr,
71 require_not_st_arithmetic<EigMat>* =
nullptr>
75 return a.unaryExpr([](
const auto& scal) {
return value_of(scal); });
77 std::forward<EigMat>(M));
80template <
typename EigMat, require_eigen_sparse_base_t<EigMat>* =
nullptr,
81 require_not_st_arithmetic<EigMat>* =
nullptr>
85 promote_scalar_t<scalar_t, plain_type_t<EigMat>> ret(M_ref.rows(),
87 ret.reserve(M_ref.nonZeros());
88 for (
int k = 0; k < M_ref.outerSize(); ++k) {
89 for (
typename std::decay_t<EigMat>::InnerIterator it(M_ref, k); it; ++it) {
90 ret.insert(it.row(), it.col()) =
value_of(it.valueRef());
96template <
typename EigMat, require_eigen_sparse_base_t<EigMat>* =
nullptr,
97 require_st_arithmetic<EigMat>* =
nullptr>
99 return std::forward<EigMat>(M);
require_not_t< std::is_arithmetic< std::decay_t< T > > > require_not_arithmetic_t
Require type does not satisfy std::is_arithmetic.
require_t< is_complex< std::decay_t< T > > > require_complex_t
Require type satisfies is_complex.
typename partials_type< T >::type partials_type_t
Helper alias for accessing the partial type.
typename value_type< T >::type value_type_t
Helper function for accessing underlying type.
auto make_holder(const F &func, Args &&... args)
Constructs an expression from given arguments using given functor.
T value_of(const fvar< T > &v)
Return the value of the specified variable.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
typename plain_type< T >::type plain_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...