fma.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_FWD_SCAL_FUN_FMA_HPP
#define STAN_MATH_FWD_SCAL_FUN_FMA_HPP
#include <stan/math/fwd/core.hpp>
#include <stan/math/prim/scal/fun/fma.hpp>
#include <stan/math/prim/scal/meta/return_type.hpp>
namespace stan {
namespace math {
template <typename T1, typename T2, typename T3>
inline
fvar<typename stan::return_type<T1, T2, T3>::type>
fma(const fvar<T1>& x1, const fvar<T2>& x2, const fvar<T3>& x3) {
return fvar<typename stan::return_type<T1, T2, T3>::type>
(fma(x1.val_, x2.val_, x3.val_),
x1.d_ * x2.val_ + x2.d_ * x1.val_ + x3.d_);
}
template <typename T1, typename T2, typename T3>
inline
fvar<typename stan::return_type<T1, T2, T3>::type>
fma(const T1& x1, const fvar<T2>& x2, const fvar<T3>& x3) {
return fvar<typename stan::return_type<T1, T2, T3>::type>
(fma(x1, x2.val_, x3.val_), x2.d_ * x1 + x3.d_);
}
template <typename T1, typename T2, typename T3>
inline
fvar<typename stan::return_type<T1, T2, T3>::type>
fma(const fvar<T1>& x1, const T2& x2, const fvar<T3>& x3) {
return fvar<typename stan::return_type<T1, T2, T3>::type>
(fma(x1.val_, x2, x3.val_), x1.d_ * x2 + x3.d_);
}
template <typename T1, typename T2, typename T3>
inline
fvar<typename stan::return_type<T1, T2, T3>::type>
fma(const fvar<T1>& x1, const fvar<T2>& x2, const T3& x3) {
return fvar<typename stan::return_type<T1, T2, T3>::type>
(fma(x1.val_, x2.val_, x3), x1.d_ * x2.val_ + x2.d_ * x1.val_);
}
template <typename T1, typename T2, typename T3>
inline
fvar<typename stan::return_type<T1, T2, T3>::type>
fma(const T1& x1, const T2& x2, const fvar<T3>& x3) {
return fvar<typename stan::return_type<T1, T2, T3>::type>
(fma(x1, x2, x3.val_), x3.d_);
}
template <typename T1, typename T2, typename T3>
inline
fvar<typename stan::return_type<T1, T2, T3>::type>
fma(const fvar<T1>& x1, const T2& x2, const T3& x3) {
return fvar<typename stan::return_type<T1, T2, T3>::type>
(fma(x1.val_, x2, x3), x1.d_ * x2);
}
template <typename T1, typename T2, typename T3>
inline
fvar<typename stan::return_type<T1, T2, T3>::type>
fma(const T1& x1, const fvar<T2>& x2, const T3& x3) {
return fvar<typename stan::return_type<T1, T2, T3>::type>
(fma(x1, x2.val_, x3), x2.d_ * x1);
}
}
}
#endif
core.hpp
stan::math::fvar::d_
T d_
Definition: fvar.hpp:16
stan
Definition: log_sum_exp.hpp:8
return_type.hpp
stan::math::fvar::val_
T val_
Definition: fvar.hpp:15
stan::math::fma
fvar< typename stan::return_type< T1, T2, T3 >::type > fma(const fvar< T1 > &x1, const fvar< T2 > &x2, const fvar< T3 > &x3)
The fused multiply-add operation (C99).
Definition: fma.hpp:61
fma.hpp
stan::math::fvar
Definition: fvar.hpp:14

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