Automatic Differentiation
 
Loading...
Searching...
No Matches
subtract.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_SUBTRACT_HPP
2#define STAN_MATH_PRIM_FUN_SUBTRACT_HPP
3
7
8namespace stan {
9namespace math {
10
21template <typename ScalarA, typename ScalarB,
22 require_all_stan_scalar_t<ScalarA, ScalarB>* = nullptr,
23 require_all_not_var_t<ScalarA, ScalarB>* = nullptr>
25 const ScalarB& b) {
26 return a - b;
27}
28
40template <typename Mat1, typename Mat2,
43inline auto subtract(const Mat1& m1, const Mat2& m2) {
44 check_matching_dims("subtract", "m1", m1, "m2", m2);
45 return m1 - m2;
46}
47
58template <typename Scal, typename Mat, require_stan_scalar_t<Scal>* = nullptr,
59 require_eigen_t<Mat>* = nullptr,
60 require_all_not_st_var<Mat, Scal>* = nullptr>
61inline auto subtract(const Scal c, const Mat& m) {
62 return (c - m.array()).matrix();
63}
64
75template <typename Mat, typename Scal, require_eigen_t<Mat>* = nullptr,
76 require_stan_scalar_t<Scal>* = nullptr,
77 require_all_not_st_var<Scal, Mat>* = nullptr>
78inline auto subtract(const Mat& m, const Scal c) {
79 return (m.array() - c).matrix();
80}
81
82} // namespace math
83} // namespace stan
84
85#endif
require_all_t< is_eigen< std::decay_t< Types > >... > require_all_eigen_t
Require all of the types satisfy is_eigen.
Definition is_eigen.hpp:65
subtraction_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > subtract(T_a &&a, T_b &&b)
typename return_type< Ts... >::type return_type_t
Convenience type for the return type of the specified template parameters.
require_all_not_t< is_var< scalar_type_t< std::decay_t< Types > > >... > require_all_not_st_var
Require none of the scalar types satisfy is_var.
Definition is_var.hpp:138
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.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Definition fvar.hpp:9