Stan Math Library
2.14.0
reverse mode automatic differentiation
stan
math
fwd
scal
fun
atan2.hpp
Go to the documentation of this file.
1
#ifndef STAN_MATH_FWD_SCAL_FUN_ATAN2_HPP
2
#define STAN_MATH_FWD_SCAL_FUN_ATAN2_HPP
3
4
#include <
stan/math/fwd/core.hpp
>
5
#include <
stan/math/prim/scal/fun/square.hpp
>
6
#include <cmath>
7
8
namespace
stan
{
9
namespace
math {
10
11
template
<
typename
T>
12
inline
fvar<T>
atan2
(
const
fvar<T>
& x1,
const
fvar<T>
& x2) {
13
using
std::atan2
;
14
return
fvar<T>
(
atan2
(x1.
val_
, x2.
val_
),
15
(x1.
d_
* x2.
val_
- x1.
val_
* x2.
d_
) /
16
(
square
(x2.
val_
) +
square
(x1.
val_
)));
17
}
18
19
template
<
typename
T>
20
inline
fvar<T>
atan2
(
double
x1,
const
fvar<T>
& x2) {
21
using
std::atan2
;
22
return
fvar<T>
(
atan2
(x1, x2.
val_
),
23
(-x1 * x2.
d_
) / (
square
(x1) +
square
(x2.
val_
)));
24
}
25
26
template
<
typename
T>
27
inline
fvar<T>
atan2
(
const
fvar<T>
& x1,
double
x2) {
28
using
std::atan2
;
29
return
fvar<T>
(
atan2
(x1.
val_
, x2),
30
(x1.
d_
* x2) / (
square
(x2) +
square
(x1.
val_
)));
31
}
32
33
}
34
}
35
#endif
core.hpp
stan::math::fvar::d_
T d_
Definition:
fvar.hpp:16
stan
Definition:
log_sum_exp.hpp:8
stan::math::atan2
fvar< T > atan2(const fvar< T > &x1, const fvar< T > &x2)
Definition:
atan2.hpp:12
square.hpp
stan::math::square
fvar< T > square(const fvar< T > &x)
Definition:
square.hpp:14
stan::math::fvar::val_
T val_
Definition:
fvar.hpp:15
stan::math::atan2
var atan2(double a, const var &b)
Return the principal value of the arc tangent, in radians, of the first scalar divided by the second ...
Definition:
atan2.hpp:119
stan::math::fvar
Definition:
fvar.hpp:14
[
Stan Home Page
]
© 2011–2016, Stan Development Team.