Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
floor.hpp
Go to the documentation of this file.
1 #ifndef STAN__AGRAD__REV__FUNCTIONS__FLOOR_HPP
2 #define STAN__AGRAD__REV__FUNCTIONS__FLOOR_HPP
3 
4 #include <math.h>
5 #include <stan/agrad/rev/var.hpp>
7 #include <boost/math/special_functions/fpclassify.hpp>
8 #include <stan/meta/likely.hpp>
9 
10 namespace stan {
11  namespace agrad {
12 
13  namespace {
14  class floor_vari : public op_v_vari {
15  public:
16  floor_vari(vari* avi) :
17  op_v_vari(::floor(avi->val_),avi) {
18  }
19  void chain() {
20  if (unlikely(boost::math::isnan(avi_->val_)))
21  avi_->adj_ = std::numeric_limits<double>::quiet_NaN();
22  }
23  };
24  }
25 
60  inline var floor(const var& a) {
61  return var(new floor_vari(a.vi_));
62  }
63 
64  }
65 }
66 #endif
bool isnan(const stan::agrad::var &v)
Checks if the given number is NaN.
fvar< T > floor(const fvar< T > &x)
Definition: floor.hpp:15
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:40
#define unlikely(x)
Definition: likely.hpp:9
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:27

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