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, require_eigen_vt<is_autodiff, EigMat>* = nullptr>
52inline void zero_adjoints(EigMat& x) {
53 for (size_t i = 0; i < x.size(); ++i)
54 x.coeffRef(i).adj() = 0;
55}
56
67template <typename StdVec,
69inline void zero_adjoints(StdVec& x) {
70 for (size_t i = 0; i < x.size(); ++i) {
71 zero_adjoints(x[i]);
72 }
73}
74
75} // namespace math
76} // namespace stan
77#endif
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 ...