Automatic Differentiation
 
Loading...
Searching...
No Matches
zero_adjoints.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_CORE_ZERO_ADJOINTS_HPP
2#define STAN_MATH_REV_CORE_ZERO_ADJOINTS_HPP
3
6#include <vector>
7
8namespace stan {
9namespace math {
10
14inline void zero_adjoints() noexcept {}
15
26template <typename T, require_st_arithmetic<T>* = nullptr>
27inline void zero_adjoints(T& x) noexcept {}
28
39inline void zero_adjoints(var& x) { x.adj() = 0; }
40
51template <typename EigMat,
53inline void zero_adjoints(EigMat& x) {
54 for (size_t i = 0; i < x.size(); ++i)
55 x.coeffRef(i).adj() = 0;
56}
57
68template <typename StdVec,
70inline void zero_adjoints(StdVec& x) {
71 for (size_t i = 0; i < x.size(); ++i) {
72 zero_adjoints(x[i]);
73 }
74}
75
76} // namespace math
77} // namespace stan
78#endif
require_t< container_type_check_base< is_eigen, value_type_t, TypeCheck, Check... > > require_eigen_vt
Require type satisfies is_eigen.
Definition is_eigen.hpp:155
require_t< container_type_check_base< is_std_vector, scalar_type_t, TypeCheck, Check... > > require_std_vector_st
Require type satisfies is_std_vector.
void zero_adjoints() noexcept
End of recursion for set_zero_adjoints.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...