Automatic Differentiation
 
Loading...
Searching...
No Matches
operator_addition.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_CORE_OPERATOR_ADDITION_HPP
2#define STAN_MATH_PRIM_CORE_OPERATOR_ADDITION_HPP
3
6#include <complex>
7
8namespace stan {
9namespace math {
10
11namespace internal {
22template <typename U, typename V>
23inline complex_return_t<U, V> complex_add(const U& lhs, const V& rhs) {
25 y += rhs;
26 return y;
27}
28} // namespace internal
29
39template <typename U, typename V, require_all_stan_scalar_t<U, V>* = nullptr>
40inline complex_return_t<U, V> operator+(const std::complex<U>& x,
41 const std::complex<V>& y) {
42 return internal::complex_add(x, y);
43}
44
54template <typename U, typename V, require_all_stan_scalar_t<U, V>* = nullptr>
55inline complex_return_t<U, V> operator+(const std::complex<U>& x, const V& y) {
56 return internal::complex_add(x, y);
57}
58
68template <typename U, typename V, require_all_stan_scalar_t<U, V>* = nullptr>
69inline complex_return_t<U, V> operator+(const U& x, const std::complex<V>& y) {
70 return internal::complex_add(x, y);
71}
72
73} // namespace math
74} // namespace stan
75
76#endif
std::complex< real_return_t< Ts... > > complex_return_t
Convenience type to calculate the complex return type, which wraps std::complex around the return typ...
complex_return_t< U, V > complex_add(const U &lhs, const V &rhs)
Return the sum of the specified arguments.
fvar< T > operator+(const fvar< T > &x1, const fvar< T > &x2)
Return the sum of the specified forward mode addends.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...