1 #ifndef STAN_MATH_PRIM_FUN_FMOD_HPP
2 #define STAN_MATH_PRIM_FUN_FMOD_HPP
3
4 #include <stan/math/prim/meta.hpp>
5 #include <stan/math/prim/functor/apply_scalar_binary.hpp>
6 #include <cmath>
7
8 namespace stan {
9 namespace math {
10
11 /**
12 * Enables the vectorised application of the fmod function,
13 * when the first and/or second arguments are containers.
14 *
15 * @tparam T1 type of first input
16 * @tparam T2 type of second input
17 * @param a First input
18 * @param b Second input
19 * @return fmod function applied to the two inputs.
20 */
21 template <typename T1, typename T2, require_any_container_t<T1, T2>* = nullptr>
fmod(const T1 & a,const T2 & b)22 inline auto fmod(const T1& a, const T2& b) {
23 return apply_scalar_binary(a, b, [&](const auto& c, const auto& d) {
24 using std::fmod;
25 return fmod(c, d);
26 });
27 }
28
29 } // namespace math
30 } // namespace stan
31 #endif
32