Stan  1.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
square.hpp
Go to the documentation of this file.
1 #ifndef __STAN__AGRAD__REV__SQUARE_HPP__
2 #define __STAN__AGRAD__REV__SQUARE_HPP__
3 
4 #include <stan/agrad/rev/var.hpp>
6 
7 namespace stan {
8  namespace agrad {
9 
10  namespace {
11  class square_vari : public op_v_vari {
12  public:
13  square_vari(vari* avi) :
14  op_v_vari(avi->val_ * avi->val_,avi) {
15  }
16  void chain() {
17  avi_->adj_ += adj_ * 2.0 * avi_->val_;
18  }
19  };
20  }
21 
31  inline var square(const var& x) {
32  return var(new square_vari(x.vi_));
33  }
34 
35  }
36 }
37 #endif

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