Automatic Differentiation
 
Loading...
Searching...
No Matches
fma.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_FMA_HPP
2#define STAN_MATH_PRIM_FUN_FMA_HPP
3
6#include <cmath>
7
8namespace stan {
9namespace math {
10
24template <typename T1, typename T2, typename T3,
25 require_all_arithmetic_t<T1, T2, T3>* = nullptr>
26inline double fma(T1 x, T2 y, T3 z) {
27 using std::fma;
28 return fma(x, y, z);
29}
30
31template <typename T1, typename T2, typename T3,
34inline auto fma(T1&& x, T2&& y, T3&& z) {
36 check_matching_dims("fma", "x", x, "y", y);
37 }
39 check_matching_dims("fma", "x", x, "z", z);
41 check_matching_dims("fma", "y", y, "z", z);
42 }
43 return make_holder(
44 [](auto&& x, auto&& y, auto&& z) {
47 .matrix();
48 },
49 std::forward<T1>(x), std::forward<T2>(y), std::forward<T3>(z));
50}
51
52} // namespace math
53} // namespace stan
54#endif
require_any_t< is_matrix< std::decay_t< Types > >... > require_any_matrix_t
Require any of the types satisfy is_matrix.
Definition is_matrix.hpp:43
require_not_t< is_var< std::decay_t< T > > > require_not_var_t
Require type does not satisfy is_var.
Definition is_var.hpp:29
T as_array_or_scalar(T &&v)
Returns specified input value.
auto make_holder(const F &func, Args &&... args)
Constructs an expression from given arguments using given functor.
Definition holder.hpp:352
void check_matching_dims(const char *function, const char *name1, const T1 &y1, const char *name2, const T2 &y2)
Check if the two containers have the same dimensions.
fvar< return_type_t< T1, T2, T3 > > fma(const fvar< T1 > &x1, const fvar< T2 > &x2, const fvar< T3 > &x3)
The fused multiply-add operation (C99).
Definition fma.hpp:60
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Check if a type is derived from Eigen::EigenBase or is a var_value whose value_type is derived from E...
Definition is_matrix.hpp:18