Stan
2.5.0
probability, sampling & optimization
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
stan
agrad
fwd
functions
abs.hpp
Go to the documentation of this file.
1
#ifndef STAN__AGRAD__FWD__FUNCTIONS__ABS_HPP
2
#define STAN__AGRAD__FWD__FUNCTIONS__ABS_HPP
3
4
#include <
stan/agrad/fwd/functions/value_of.hpp
>
5
#include <
stan/agrad/fwd/fvar.hpp
>
6
#include <
stan/meta/traits.hpp
>
7
#include <
stan/math/constants.hpp
>
8
#include <
stan/math/functions/abs.hpp
>
9
#include <
stan/math/functions/value_of.hpp
>
10
#include <
stan/meta/likely.hpp
>
11
12
namespace
stan {
13
14
namespace
agrad {
15
16
template
<
typename
T>
17
inline
18
fvar<T>
19
abs
(
const
fvar<T>
& x) {
20
using
stan::math::abs
;
21
using
stan::math::value_of
;
22
if
(x.
val_
> 0.0)
23
return
x;
24
else
if
(x.
val_
< 0.0)
25
return
fvar<T>
(-x.
val_
, -x.
d_
);
26
else
if
(x.
val_
== 0.0)
27
return
fvar<T>
(0, 0);
28
else
// if (unlikely(boost::math::isnan(value_of(x.val_))))
29
return
fvar<T>
(
abs
(x.
val_
),
stan::math::NOT_A_NUMBER
);
30
}
31
}
32
}
33
#endif
stan::math::NOT_A_NUMBER
const double NOT_A_NUMBER
(Quiet) not-a-number value.
Definition:
constants.hpp:53
stan::agrad::fvar
Definition:
fvar.hpp:13
traits.hpp
stan::math::value_of
double value_of(const T x)
Return the value of the specified scalar argument converted to a double value.
Definition:
value_of.hpp:24
value_of.hpp
fvar.hpp
stan::agrad::abs
fvar< T > abs(const fvar< T > &x)
Definition:
abs.hpp:19
likely.hpp
stan::math::abs
double abs(double x)
Return floating-point absolute value.
Definition:
abs.hpp:19
abs.hpp
value_of.hpp
stan::agrad::fvar::d_
T d_
Definition:
fvar.hpp:16
constants.hpp
stan::agrad::fvar::val_
T val_
Definition:
fvar.hpp:15
[
Stan Home Page
]
© 2011–2014, Stan Development Team.