Stan
1.3
probability, sampling & optimization
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerator
Friends
Macros
Pages
src
stan
agrad
rev
fabs.hpp
Go to the documentation of this file.
1
#ifndef __STAN__AGRAD__REV__FABS_HPP__
2
#define __STAN__AGRAD__REV__FABS_HPP__
3
4
#include <
stan/agrad/rev/var.hpp
>
5
#include <
stan/agrad/rev/vari.hpp
>
6
#include <
stan/agrad/rev/operator_unary_negative.hpp
>
7
8
namespace
stan {
9
namespace
agrad {
10
27
inline
var
fabs
(
const
var& a) {
28
// cut-and-paste from abs()
29
if
(a.val() > 0.0)
30
return
a;
31
if
(a.val() < 0.0)
32
return
var(
new
neg_vari(a.vi_));
33
// FIXME: is this right? breaks connection to a
34
return
var(
new
vari(0.0));
35
}
36
37
}
38
}
39
#endif
[
Stan Home Page
]
© 2011–2013, Stan Development Team.