Stan  1.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
operator_unary_decrement.hpp
Go to the documentation of this file.
1 #ifndef __STAN__AGRAD__REV__OPERATOR_UNARY_DECREMENT_HPP__
2 #define __STAN__AGRAD__REV__OPERATOR_UNARY_DECREMENT_HPP__
3 
4 #include <stan/agrad/rev/var.hpp>
6 
7 namespace stan {
8  namespace agrad {
9 
10  namespace {
11  class decrement_vari : public op_v_vari {
12  public:
13  decrement_vari(vari* avi) :
14  op_v_vari(avi->val_ - 1.0, avi) {
15  }
16  void chain() {
17  avi_->adj_ += adj_;
18  }
19  };
20  }
21 
35  inline var& operator--(var& a) {
36  a.vi_ = new decrement_vari(a.vi_);
37  return a;
38  }
39 
51  inline var operator--(var& a, int /*dummy*/) {
52  var temp(a);
53  a.vi_ = new decrement_vari(a.vi_);
54  return temp;
55  }
56 
57  }
58 }
59 #endif

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