1 #ifndef STAN_MATH_REV_SCAL_FUN_HYPOT_HPP 2 #define STAN_MATH_REV_SCAL_FUN_HYPOT_HPP 11 class hypot_vv_vari :
public op_vv_vari {
13 hypot_vv_vari(vari* avi, vari* bvi) :
14 op_vv_vari(
hypot(avi->val_, bvi->val_), avi, bvi) {
17 avi_->adj_ += adj_ * avi_->val_ / val_;
18 bvi_->adj_ += adj_ * bvi_->val_ / val_;
22 class hypot_vd_vari :
public op_v_vari {
24 hypot_vd_vari(vari* avi,
double b) :
25 op_v_vari(
hypot(avi->val_, b), avi) {
28 avi_->adj_ += adj_ * avi_->val_ / val_;
48 return var(
new hypot_vv_vari(a.
vi_, b.
vi_));
64 return var(
new hypot_vd_vari(a.
vi_, b));
107 return var(
new hypot_vd_vari(b.
vi_, a));
fvar< T > hypot(const fvar< T > &x1, const fvar< T > &x2)
Return the length of the hypoteneuse of a right triangle with opposite and adjacent side lengths give...
Independent (input) and dependent (output) variables for gradients.
vari * vi_
Pointer to the implementation of this variable.