| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

cbrt.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_SCAL_FUN_CBRT_HPP
2 #define STAN_MATH_REV_SCAL_FUN_CBRT_HPP
3
4 #include <math.h>
5 #include <stan/math/rev/core.hpp>
6
7 #ifdef _MSC_VER
8 #include <boost/math/special_functions/cbrt.hpp>
9 using boost::math::cbrt;
10 #endif
11
12 namespace stan {
13 namespace math {
14
15 namespace {
16 class cbrt_vari : public op_v_vari {
17 public:
18 explicit cbrt_vari(vari* avi) :
19 op_v_vari(::cbrt(avi->val_), avi) {
20 }
21 void chain() {
22 avi_->adj_ += adj_ / (3.0 * val_ * val_);
23 }
24 };
25 }
26
55 inline var cbrt(const var& a) {
56 return var(new cbrt_vari(a.vi_));
57 }
58
59 }
60 }
61 #endif
core.hpp
stan
Definition: log_sum_exp.hpp:8
stan::math::cbrt
fvar< T > cbrt(const fvar< T > &x)
Definition: cbrt.hpp:14
stan::math::var
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:30
stan::math::var::vi_
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:42
stan::math::cbrt
var cbrt(const var &a)
Returns the cube root of the specified variable (C99).
Definition: cbrt.hpp:55

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