Stan
2.5.0
probability, sampling & optimization
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
stan
agrad
fwd
functions
hypot.hpp
Go to the documentation of this file.
1
#ifndef STAN__AGRAD__FWD__FUNCTIONS__HYPOT_HPP
2
#define STAN__AGRAD__FWD__FUNCTIONS__HYPOT_HPP
3
4
#include <
stan/agrad/fwd/fvar.hpp
>
5
#include <
stan/meta/traits.hpp
>
6
#include <
stan/math/functions/inv.hpp
>
7
#include <math.h>
8
9
namespace
stan {
10
11
namespace
agrad {
12
13
template
<
typename
T>
14
inline
15
fvar<T>
16
hypot
(
const
fvar<T>
& x1,
const
fvar<T>
& x2) {
17
using ::hypot
;
18
using ::sqrt
;
19
using
stan::math::inv
;
20
T u =
hypot
(x1.
val_
, x2.
val_
);
21
return
fvar<T>
(u, (x1.
d_
* x1.
val_
+ x2.
d_
* x2.
val_
) *
inv
(u));
22
}
23
24
template
<
typename
T>
25
inline
26
fvar<T>
27
hypot
(
const
fvar<T>
& x1,
const
double
x2) {
28
using ::hypot
;
29
using ::sqrt
;
30
using
stan::math::inv
;
31
T u =
hypot
(x1.
val_
, x2);
32
return
fvar<T>
(u, (x1.
d_
* x1.
val_
) *
inv
(u));
33
}
34
35
template
<
typename
T>
36
inline
37
fvar<T>
38
hypot
(
const
double
x1,
const
fvar<T>
& x2) {
39
using ::hypot
;
40
using ::sqrt
;
41
using
stan::math::inv
;
42
T u =
hypot
(x1, x2.
val_
);
43
return
fvar<T>
(u, (x2.
d_
* x2.
val_
) *
inv
(u));
44
}
45
46
}
47
}
48
#endif
stan::math::inv
boost::math::tools::promote_args< T >::type inv(const T x)
Definition:
inv.hpp:12
stan::agrad::hypot
var hypot(const double &a, const stan::agrad::var &b)
Returns the length of the hypoteneuse of a right triangle with sides of the specified lengths (C99)...
Definition:
hypot.hpp:119
stan::agrad::fvar
Definition:
fvar.hpp:13
stan::agrad::hypot
fvar< T > hypot(const fvar< T > &x1, const fvar< T > &x2)
Definition:
hypot.hpp:16
traits.hpp
stan::agrad::inv
fvar< T > inv(const fvar< T > &x)
Definition:
inv.hpp:15
inv.hpp
stan::agrad::sqrt
fvar< T > sqrt(const fvar< T > &x)
Definition:
sqrt.hpp:15
fvar.hpp
stan::agrad::fvar::d_
T d_
Definition:
fvar.hpp:16
stan::agrad::fvar::val_
T val_
Definition:
fvar.hpp:15
[
Stan Home Page
]
© 2011–2014, Stan Development Team.