Stan Math Library
2.15.0
reverse mode automatic differentiation
stan
math
fwd
scal
fun
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 <
stan/math/fwd/core.hpp
>
5
#include <
stan/math/prim/scal/fun/hypot.hpp
>
6
#include <cmath>
7
8
namespace
stan
{
9
namespace
math {
10
24
template
<
typename
T>
25
inline
fvar<T>
hypot
(
const
fvar<T>
& x1,
const
fvar<T>
& x2) {
26
using
std::sqrt
;
27
T u =
hypot
(x1.
val_
, x2.
val_
);
28
return
fvar<T>
(u, (x1.
d_
* x1.
val_
+ x2.
d_
* x2.
val_
) / u);
29
}
30
44
template
<
typename
T>
45
inline
fvar<T>
hypot
(
const
fvar<T>
& x1,
double
x2) {
46
using
std::sqrt
;
47
T u =
hypot
(x1.
val_
, x2);
48
return
fvar<T>
(u, (x1.
d_
* x1.
val_
) / u);
49
}
50
64
template
<
typename
T>
65
inline
fvar<T>
hypot
(
double
x1,
const
fvar<T>
& x2) {
66
using
std::sqrt
;
67
T u =
hypot
(x1, x2.
val_
);
68
return
fvar<T>
(u, (x2.
d_
* x2.
val_
) / u);
69
}
70
71
}
72
}
73
#endif
core.hpp
stan::math::fvar::d_
T d_
Definition:
fvar.hpp:16
stan::math::hypot
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...
Definition:
hypot.hpp:25
stan::math::sqrt
fvar< T > sqrt(const fvar< T > &x)
Definition:
sqrt.hpp:14
stan
Definition:
log_sum_exp.hpp:8
hypot.hpp
stan::math::fvar::val_
T val_
Definition:
fvar.hpp:15
stan::math::fvar
Definition:
fvar.hpp:14
[
Stan Home Page
]
© 2011–2016, Stan Development Team.