Stan Math Library: stan/math/fwd/scal/fun/atan2.hpp Source File

| Stan Math Library 2.10.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 using stan::math::square;
15 return fvar<T>(atan2(x1.val_, x2.val_),
16 (x1.d_ * x2.val_ - x1.val_ * x2.d_) /
17 (square(x2.val_) + square(x1.val_)));
18 }
19
20 template <typename T>
21 inline fvar<T> atan2(const double x1, const fvar<T>& x2) {
22 using std::atan2;
23 using stan::math::square;
24 return fvar<T>(atan2(x1, x2.val_),
25 (-x1 * x2.d_) / (square(x1) + square(x2.val_)));
26 }
27
28 template <typename T>
29 inline fvar<T> atan2(const fvar<T>& x1, const double x2) {
30 using std::atan2;
31 using stan::math::square;
32 return fvar<T>(atan2(x1.val_, x2),
33 (x1.d_ * x2) / (square(x2) + square(x1.val_)));
34 }
35
36 }
37 }
38 #endif
core.hpp
stan::math::fvar::d_
T d_
Definition: fvar.hpp:15
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:15
stan::math::atan2
var atan2(const 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::val_
T val_
Definition: fvar.hpp:14
stan::math::fvar
Definition: fvar.hpp:13

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