Stan Math Library
2.20.0
reverse mode automatic differentiation
stan
math
prim
scal
fun
corr_constrain.hpp
Go to the documentation of this file.
1
#ifndef STAN_MATH_PRIM_SCAL_FUN_CORR_CONSTRAIN_HPP
2
#define STAN_MATH_PRIM_SCAL_FUN_CORR_CONSTRAIN_HPP
3
4
#include <
stan/math/prim/meta.hpp
>
5
#include <
stan/math/prim/scal/fun/log1m.hpp
>
6
#include <
stan/math/prim/scal/fun/square.hpp
>
7
#include <cmath>
8
9
namespace
stan
{
10
namespace
math {
11
24
template
<
typename
T>
25
inline
T
corr_constrain
(
const
T& x) {
26
return
tanh
(x);
27
}
28
43
template
<
typename
T>
44
inline
T
corr_constrain
(
const
T& x, T& lp) {
45
T tanh_x =
tanh
(x);
46
lp +=
log1m
(
square
(tanh_x));
47
return
tanh_x;
48
}
49
50
}
// namespace math
51
}
// namespace stan
52
#endif
stan
Definition:
log_sum_exp.hpp:8
meta.hpp
square.hpp
stan::math::corr_constrain
T corr_constrain(const T &x)
Return the result of transforming the specified scalar to have a valid correlation value between -1 a...
Definition:
corr_constrain.hpp:25
stan::math::square
fvar< T > square(const fvar< T > &x)
Definition:
square.hpp:12
stan::math::tanh
fvar< T > tanh(const fvar< T > &x)
Definition:
tanh.hpp:11
log1m.hpp
stan::math::log1m
fvar< T > log1m(const fvar< T > &x)
Definition:
log1m.hpp:12
[
Stan Home Page
]
© 2011–2018, Stan Development Team.