Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ copysign() [2/3]

template<typename T , typename U >
T stan::math::copysign ( const T &  x,
const U &  y 
)
inline

Return the negation of the first argument if the first and second argument have different signs, otherwise return a copy of the first argument.

For the sake of this function, zero is considered positive. This function uses negation rather than literally copying signs to preserve derivatives.

Overload of std::copysign from cmath for argument-dependent lookup.

Template Parameters
Ttype of first argument
Utype of second argument
Parameters
[in]xfirst complex argument
[in]ysecond complex argument
Returns
copy of the first argument, negated if necessary to match the sign of the second argument

Definition at line 30 of file copysign.hpp.