All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
owens_t.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_FWD_SCAL_FUN_OWENS_T_HPP
#define STAN_MATH_FWD_SCAL_FUN_OWENS_T_HPP
#include <stan/math/fwd/core.hpp>
#include <stan/math/prim/scal/fun/constants.hpp>
#include <stan/math/prim/scal/fun/owens_t.hpp>
#include <stan/math/prim/scal/fun/square.hpp>
#include <cmath>
namespace stan {
namespace math {
template <typename T>
inline fvar<T> owens_t(const fvar<T>& x1, const fvar<T>& x2) {
using stan::math::owens_t;
using stan::math::pi;
using stan::math::INV_SQRT_2;
using stan::math::INV_SQRT_TWO_PI;
using stan::math::square;
using std::exp;
using ::erf;
T neg_x1_sq_div_2 = -square(x1.val_) * 0.5;
T one_p_x2_sq = 1.0 + square(x2.val_);
return fvar<T>(owens_t(x1.val_, x2.val_),
- x1.d_
* (erf(x2.val_ * x1.val_ * INV_SQRT_2)
* exp(neg_x1_sq_div_2) * INV_SQRT_TWO_PI * 0.5)
+ x2.d_ * exp(neg_x1_sq_div_2 * one_p_x2_sq)
/ (one_p_x2_sq * 2.0 * pi()));
}
template <typename T>
inline fvar<T> owens_t(const double x1, const fvar<T>& x2) {
using stan::math::owens_t;
using stan::math::pi;
using stan::math::square;
using std::exp;
T neg_x1_sq_div_2 = -square(x1) * 0.5;
T one_p_x2_sq = 1.0 + square(x2.val_);
return fvar<T>(owens_t(x1, x2.val_),
x2.d_ * exp(neg_x1_sq_div_2 * one_p_x2_sq)
/ (one_p_x2_sq * 2.0 * pi()));
}
template <typename T>
inline fvar<T> owens_t(const fvar<T>& x1, const double x2) {
using stan::math::owens_t;
using stan::math::pi;
using stan::math::square;
using stan::math::INV_SQRT_2;
using stan::math::INV_SQRT_TWO_PI;
using std::exp;
using ::erf;
T neg_x1_sq_div_2 = -square(x1.val_) * 0.5;
return fvar<T>(owens_t(x1.val_, x2),
-x1.d_ * (erf(x2 * x1.val_ * INV_SQRT_2)
* exp(neg_x1_sq_div_2)
* INV_SQRT_TWO_PI * 0.5));
}
}
}
#endif
stan::math::INV_SQRT_TWO_PI
const double INV_SQRT_TWO_PI
Definition: constants.hpp:166
core.hpp
stan::math::fvar::d_
T d_
Definition: fvar.hpp:15
square.hpp
stan::math::erf
fvar< T > erf(const fvar< T > &x)
Definition: erf.hpp:14
stan::math::square
fvar< T > square(const fvar< T > &x)
Definition: square.hpp:15
stan::math::owens_t
fvar< T > owens_t(const fvar< T > &x1, const fvar< T > &x2)
Definition: owens_t.hpp:14
stan::math::fvar::val_
T val_
Definition: fvar.hpp:14
stan::math::INV_SQRT_2
const double INV_SQRT_2
The value of 1 over the square root of 2, .
Definition: constants.hpp:27
stan::math::exp
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
owens_t.hpp
constants.hpp
stan::math::pi
double pi()
Return the value of pi.
Definition: constants.hpp:86
stan::math::fvar
Definition: fvar.hpp:13

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