Automatic Differentiation
 
Loading...
Searching...
No Matches
initialize.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_INITIALIZE_HPP
2#define STAN_MATH_PRIM_FUN_INITIALIZE_HPP
3
6#include <vector>
7#include <type_traits>
8
9namespace stan {
10namespace math {
11
12// initializations called for local variables generate in Stan
13// code; fills in all cells in first arg with second arg
14
15template <typename T, typename V, require_all_stan_scalar_t<T, V>* = nullptr,
16 require_convertible_t<V, T>* = nullptr>
17inline void initialize(T& x, V v) {
18 x = v;
19}
20
21template <typename T, int R, int C, typename V>
22inline void initialize(Eigen::Matrix<T, R, C>& x, const V& v) {
23 x.fill(v);
24}
25
26template <typename T, typename V>
27inline void initialize(std::vector<T>& x, const V& v) {
28 for (size_t i = 0; i < x.size(); ++i) {
29 initialize(x[i], v);
30 }
31}
32
33} // namespace math
34} // namespace stan
35#endif
void initialize(T &x, V v)
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...