Stan Math Library: stan/math/rev/scal/fun/cbrt.hpp Source File

| Stan Math Library 2.10.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
13 namespace stan {
14 namespace math {
15
16 namespace {
17 class cbrt_vari : public op_v_vari {
18 public:
19 explicit cbrt_vari(vari* avi) :
20 op_v_vari(::cbrt(avi->val_), avi) {
21 }
22 void chain() {
23 avi_->adj_ += adj_ / (3.0 * val_ * val_);
24 }
25 };
26 }
27
56 inline var cbrt(const var& a) {
57 return var(new cbrt_vari(a.vi_));
58 }
59
60 }
61 }
62 #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:31
stan::math::var::vi_
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:43
stan::math::cbrt
var cbrt(const var &a)
Returns the cube root of the specified variable (C99).
Definition: cbrt.hpp:56

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