Stan Math Library
2.14.0
reverse mode automatic differentiation
stan
math
fwd
scal
fun
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 <
stan/math/fwd/core.hpp
>
5
#include <
stan/math/prim/scal/fun/fma.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
return
fvar<typename stan::return_type<T1, T2, T3>::type
>
63
(
fma
(x1.
val_
, x2.
val_
, x3.
val_
),
64
x1.
d_
* x2.
val_
+ x2.
d_
* x1.
val_
+ x3.
d_
);
65
}
66
70
template
<
typename
T1,
typename
T2,
typename
T3>
71
inline
72
fvar<typename stan::return_type<T1, T2, T3>::type
>
73
fma
(
const
T1& x1,
const
fvar<T2>
& x2,
const
fvar<T3>
& x3) {
74
return
fvar<typename stan::return_type<T1, T2, T3>::type
>
75
(
fma
(x1, x2.
val_
, x3.
val_
), x2.
d_
* x1 + x3.
d_
);
76
}
77
81
template
<
typename
T1,
typename
T2,
typename
T3>
82
inline
83
fvar<typename stan::return_type<T1, T2, T3>::type
>
84
fma
(
const
fvar<T1>
& x1,
const
T2& x2,
const
fvar<T3>
& x3) {
85
return
fvar<typename stan::return_type<T1, T2, T3>::type
>
86
(
fma
(x1.
val_
, x2, x3.
val_
), x1.
d_
* x2 + x3.
d_
);
87
}
88
92
template
<
typename
T1,
typename
T2,
typename
T3>
93
inline
94
fvar<typename stan::return_type<T1, T2, T3>::type
>
95
fma
(
const
fvar<T1>
& x1,
const
fvar<T2>
& x2,
const
T3& x3) {
96
return
fvar<typename stan::return_type<T1, T2, T3>::type
>
97
(
fma
(x1.
val_
, x2.
val_
, x3), x1.
d_
* x2.
val_
+ x2.
d_
* x1.
val_
);
98
}
99
103
template
<
typename
T1,
typename
T2,
typename
T3>
104
inline
105
fvar<typename stan::return_type<T1, T2, T3>::type
>
106
fma
(
const
T1& x1,
const
T2& x2,
const
fvar<T3>
& x3) {
107
return
fvar<typename stan::return_type<T1, T2, T3>::type
>
108
(
fma
(x1, x2, x3.
val_
), x3.
d_
);
109
}
110
114
template
<
typename
T1,
typename
T2,
typename
T3>
115
inline
116
fvar<typename stan::return_type<T1, T2, T3>::type
>
117
fma
(
const
fvar<T1>
& x1,
const
T2& x2,
const
T3& x3) {
118
return
fvar<typename stan::return_type<T1, T2, T3>::type
>
119
(
fma
(x1.
val_
, x2, x3), x1.
d_
* x2);
120
}
121
125
template
<
typename
T1,
typename
T2,
typename
T3>
126
inline
127
fvar<typename stan::return_type<T1, T2, T3>::type
>
128
fma
(
const
T1& x1,
const
fvar<T2>
& x2,
const
T3& x3) {
129
return
fvar<typename stan::return_type<T1, T2, T3>::type
>
130
(
fma
(x1, x2.
val_
, x3), x2.
d_
* x1);
131
}
132
133
}
134
}
135
#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.