All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
atan2.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_FWD_SCAL_FUN_ATAN2_HPP
#define STAN_MATH_FWD_SCAL_FUN_ATAN2_HPP
#include <stan/math/fwd/core.hpp>
#include <stan/math/prim/scal/fun/square.hpp>
#include <cmath>
namespace stan {
namespace math {
template <typename T>
inline fvar<T> atan2(const fvar<T>& x1, const fvar<T>& x2) {
using std::atan2;
using stan::math::square;
return fvar<T>(atan2(x1.val_, x2.val_),
(x1.d_ * x2.val_ - x1.val_ * x2.d_) /
(square(x2.val_) + square(x1.val_)));
}
template <typename T>
inline fvar<T> atan2(const double x1, const fvar<T>& x2) {
using std::atan2;
using stan::math::square;
return fvar<T>(atan2(x1, x2.val_),
(-x1 * x2.d_) / (square(x1) + square(x2.val_)));
}
template <typename T>
inline fvar<T> atan2(const fvar<T>& x1, const double x2) {
using std::atan2;
using stan::math::square;
return fvar<T>(atan2(x1.val_, x2),
(x1.d_ * x2) / (square(x2) + square(x1.val_)));
}
}
}
#endif
core.hpp
stan::math::fvar::d_
T d_
Definition: fvar.hpp:15
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–2015, Stan Development Team.