| Stan Math Library 2.6.3 probability, sampling & optimization

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
fma.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_FWD_SCAL_FUN_FMA_HPP
2 #define STAN_MATH_FWD_SCAL_FUN_FMA_HPP
3
4 #include <math.h>
5 #include <stan/math/fwd/core.hpp>
6 #include <stan/math/prim/scal/meta/return_type.hpp>
7
8 namespace stan {
9 namespace math {
10
58 template <typename T1, typename T2, typename T3>
59 inline
60 fvar<typename stan::return_type<T1, T2, T3>::type>
61 fma(const fvar<T1>& x1, const fvar<T2>& x2, const fvar<T3>& x3) {
62 using ::fma;
63 return fvar<typename stan::return_type<T1, T2, T3>::type>
64 (fma(x1.val_, x2.val_, x3.val_),
65 x1.d_ * x2.val_ + x2.d_ * x1.val_ + x3.d_);
66 }
67
71 template <typename T1, typename T2, typename T3>
72 inline
73 fvar<typename stan::return_type<T1, T2, T3>::type>
74 fma(const T1& x1, const fvar<T2>& x2, const fvar<T3>& x3) {
75 using ::fma;
76 return fvar<typename stan::return_type<T1, T2, T3>::type>
77 (fma(x1, x2.val_, x3.val_), x2.d_ * x1 + x3.d_);
78 }
79
83 template <typename T1, typename T2, typename T3>
84 inline
85 fvar<typename stan::return_type<T1, T2, T3>::type>
86 fma(const fvar<T1>& x1, const T2& x2, const fvar<T3>& x3) {
87 using ::fma;
88 return fvar<typename stan::return_type<T1, T2, T3>::type>
89 (fma(x1.val_, x2, x3.val_), x1.d_ * x2 + x3.d_);
90 }
91
95 template <typename T1, typename T2, typename T3>
96 inline
97 fvar<typename stan::return_type<T1, T2, T3>::type>
98 fma(const fvar<T1>& x1, const fvar<T2>& x2, const T3& x3) {
99 using ::fma;
100 return fvar<typename stan::return_type<T1, T2, T3>::type>
101 (fma(x1.val_, x2.val_, x3), x1.d_ * x2.val_ + x2.d_ * x1.val_);
102 }
103
107 template <typename T1, typename T2, typename T3>
108 inline
109 fvar<typename stan::return_type<T1, T2, T3>::type>
110 fma(const T1& x1, const T2& x2, const fvar<T3>& x3) {
111 using ::fma;
112 return fvar<typename stan::return_type<T1, T2, T3>::type>
113 (fma(x1, x2, x3.val_), x3.d_);
114 }
115
119 template <typename T1, typename T2, typename T3>
120 inline
121 fvar<typename stan::return_type<T1, T2, T3>::type>
122 fma(const fvar<T1>& x1, const T2& x2, const T3& x3) {
123 using ::fma;
124 return fvar<typename stan::return_type<T1, T2, T3>::type>
125 (fma(x1.val_, x2, x3), x1.d_ * x2);
126 }
127
131 template <typename T1, typename T2, typename T3>
132 inline
133 fvar<typename stan::return_type<T1, T2, T3>::type>
134 fma(const T1& x1, const fvar<T2>& x2, const T3& x3) {
135 using ::fma;
136 return fvar<typename stan::return_type<T1, T2, T3>::type>
137 (fma(x1, x2.val_, x3), x2.d_ * x1);
138 }
139
140 }
141 }
142 #endif
core.hpp
stan::math::fvar::d_
T d_
Definition: fvar.hpp:15
return_type.hpp
stan::math::fvar::val_
T val_
Definition: fvar.hpp:14
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
stan::math::fma
var fma(const double &a, const stan::math::var &b, const stan::math::var &c)
The fused multiply-add function for a value and two variables (C99).
Definition: fma.hpp:273
stan::math::fvar
Definition: fvar.hpp:13

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