Stan Math Library  2.6.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
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>
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
fvar< T > atan2(const fvar< T > &x1, const fvar< T > &x2)
Definition: atan2.hpp:12
fvar< T > square(const fvar< T > &x)
Definition: square.hpp:15
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 Home Page ] © 2011–2015, Stan Development Team.