| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

hypot.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_FWD_SCAL_FUN_HYPOT_HPP
2 #define STAN_MATH_FWD_SCAL_FUN_HYPOT_HPP
3
4 #include <math.h>
5 #include <stan/math/fwd/core.hpp>
6 #include <stan/math/prim/scal/fun/inv.hpp>
7 #include <cmath>
8
9 namespace stan {
10 namespace math {
11
12 template <typename T>
13 inline fvar<T> hypot(const fvar<T>& x1, const fvar<T>& x2) {
14 using ::hypot;
15 using std::sqrt;
16 T u = hypot(x1.val_, x2.val_);
17 return fvar<T>(u, (x1.d_ * x1.val_ + x2.d_ * x2.val_) * inv(u));
18 }
19
20 template <typename T>
21 inline fvar<T> hypot(const fvar<T>& x1, const double x2) {
22 using ::hypot;
23 using std::sqrt;
24 T u = hypot(x1.val_, x2);
25 return fvar<T>(u, (x1.d_ * x1.val_) * inv(u));
26 }
27
28 template <typename T>
29 inline fvar<T> hypot(const double x1, const fvar<T>& x2) {
30 using ::hypot;
31 using std::sqrt;
32 T u = hypot(x1, x2.val_);
33 return fvar<T>(u, (x2.d_ * x2.val_) * inv(u));
34 }
35
36 }
37 }
38 #endif
core.hpp
stan::math::fvar::d_
T d_
Definition: fvar.hpp:14
stan::math::hypot
fvar< T > hypot(const fvar< T > &x1, const fvar< T > &x2)
Definition: hypot.hpp:13
stan::math::sqrt
fvar< T > sqrt(const fvar< T > &x)
Definition: sqrt.hpp:14
stan
Definition: log_sum_exp.hpp:8
stan::math::fvar::val_
T val_
Definition: fvar.hpp:13
inv.hpp
stan::math::fvar
Definition: fvar.hpp:12
stan::math::inv
fvar< T > inv(const fvar< T > &x)
Definition: inv.hpp:14
stan::math::hypot
var hypot(double a, const var &b)
Returns the length of the hypoteneuse of a right triangle with sides of the specified lengths (C99)...
Definition: hypot.hpp:116

[ Stan Home Page ] © 2011–2016, Stan Development Team.