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

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