Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fmod.hpp
Go to the documentation of this file.
1 #ifndef STAN__AGRAD__FWD__FUNCTIONS__FMOD_HPP
2 #define STAN__AGRAD__FWD__FUNCTIONS__FMOD_HPP
3 
5 #include <stan/meta/traits.hpp>
8 
9 namespace stan {
10 
11  namespace agrad {
12 
13  template <typename T>
14  inline
15  fvar<T>
16  fmod(const fvar<T>& x1, const fvar<T>& x2) {
17  using std::fmod;
18  using std::floor;
19  return fvar<T>(fmod(x1.val_, x2.val_),
20  x1.d_ - x2.d_ * floor(x1.val_ / x2.val_));
21  }
22 
23  template <typename T>
24  inline
25  fvar<T>
26  fmod(const fvar<T>& x1, const double x2) {
27  using std::fmod;
30  || boost::math::isnan(x2)))
32  else
33  return fvar<T>(fmod(x1.val_, x2), x1.d_ / x2);
34  }
35 
36  template <typename T>
37  inline
38  fvar<T>
39  fmod(const double x1, const fvar<T>& x2) {
40  using std::fmod;
41  using std::floor;
42  return fvar<T>(fmod(x1, x2.val_), -x2.d_ * floor(x1 / x2.val_));
43  }
44  }
45 }
46 #endif
bool isnan(const stan::agrad::var &v)
Checks if the given number is NaN.
const double NOT_A_NUMBER
(Quiet) not-a-number value.
Definition: constants.hpp:53
fvar< T > floor(const fvar< T > &x)
Definition: floor.hpp:15
var fmod(const double a, const var &b)
Return the floating point remainder after dividing the first scalar by the second variable (cmath)...
Definition: fmod.hpp:139
T value_of(const fvar< T > &v)
Return the value of the specified variable.
Definition: value_of.hpp:16
double value_of(const T x)
Return the value of the specified scalar argument converted to a double value.
Definition: value_of.hpp:24
#define unlikely(x)
Definition: likely.hpp:9
fvar< T > fmod(const fvar< T > &x1, const fvar< T > &x2)
Definition: fmod.hpp:16

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