Stan Math Library  2.12.0
reverse mode automatic differentiation
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 
5 #include <cmath>
6 
7 namespace stan {
8  namespace math {
9 
22  template <typename T>
23  inline
24  T corr_constrain(const T x) {
25  return tanh(x);
26  }
27 
40  template <typename T>
41  inline
42  T corr_constrain(const T x, T& lp) {
43  T tanh_x = tanh(x);
44  lp += log1m(tanh_x * tanh_x);
45  return tanh_x;
46  }
47 
48  }
49 
50 }
51 
52 #endif
fvar< T > tanh(const fvar< T > &x)
Definition: tanh.hpp:12
fvar< T > log1m(const fvar< T > &x)
Definition: log1m.hpp:15
T corr_constrain(const T x)
Return the result of transforming the specified scalar to have a valid correlation value between -1 a...

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