Automatic Differentiation
 
Loading...
Searching...
No Matches
adjoint_of.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_FUN_ADJOINT_OF_HPP
2#define STAN_MATH_REV_FUN_ADJOINT_OF_HPP
3
5
6namespace stan {
7namespace math {
8
9namespace internal {
11 template <typename T>
13 return *this;
14 }
15 template <typename T>
17 throw std::runtime_error(
18 "internal::nonexisting_adjoint::operator+= should never be called! "
19 "Please file a bug report. rev/fun/adjoint_of.hpp line "
20 + std::to_string(__LINE__));
21 }
22 template <typename T>
24 throw std::runtime_error(
25 "internal::nonexisting_adjoint::operator-= should never be called! "
26 "Please file a bug report. rev/fun/adjoint_of.hpp line "
27 + std::to_string(__LINE__));
28 }
29};
30} // namespace internal
31
38template <typename T, require_var_t<T>* = nullptr>
39inline auto& adjoint_of(const T& x) noexcept {
40 return x.adj();
41}
42
51template <typename T, require_not_var_t<T>* = nullptr>
53 return {};
54}
55
56} // namespace math
57} // namespace stan
58
59#endif // ADJOINT_OF_HPP
auto & adjoint_of(const T &x) noexcept
Returns a reference to a variable's adjoint.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
nonexisting_adjoint operator+(const T &)
nonexisting_adjoint operator-=(T) const
nonexisting_adjoint operator+=(T) const