| Stan Math Library 2.6.3 probability, sampling & optimization

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
ordered_free.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_ORDERED_FREE_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_ORDERED_FREE_HPP
3
4 #include <stan/math/prim/mat/fun/Eigen.hpp>
5 #include <stan/math/prim/mat/err/check_ordered.hpp>
6 #include <stan/math/prim/mat/meta/index_type.hpp>
7 #include <cmath>
8
9 namespace stan {
10
11 namespace math {
12
26 template <typename T>
27 Eigen::Matrix<T, Eigen::Dynamic, 1>
28 ordered_free(const Eigen::Matrix<T, Eigen::Dynamic, 1>& y) {
29 stan::math::check_ordered("stan::math::ordered_free",
30 "Ordered variable", y);
31 using Eigen::Matrix;
32 using Eigen::Dynamic;
33 using stan::math::index_type;
34 typedef typename index_type<Matrix<T, Dynamic, 1> >::type size_type;
35
36 size_type k = y.size();
37 Matrix<T, Dynamic, 1> x(k);
38 if (k == 0)
39 return x;
40 x[0] = y[0];
41 for (size_type i = 1; i < k; ++i)
42 x[i] = log(y[i] - y[i-1]);
43 return x;
44 }
45
46 }
47
48 }
49
50 #endif
stan::math::ordered_free
Eigen::Matrix< T, Eigen::Dynamic, 1 > ordered_free(const Eigen::Matrix< T, Eigen::Dynamic, 1 > &y)
Return the vector of unconstrained scalars that transform to the specified positive ordered vector...
Definition: ordered_free.hpp:28
stan::math::log
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:15
check_ordered.hpp
stan::math::size_type
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic >::Index size_type
Type for sizes and indexes in an Eigen matrix with double e.
Definition: typedefs.hpp:13
stan::math::index_type
Primary template class for the metaprogram to compute the index type of a container.
Definition: index_type.hpp:19
index_type.hpp
stan::math::check_ordered
bool check_ordered(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, 1 > &y)
Return true if the specified vector is sorted into strictly increasing order.
Definition: check_ordered.hpp:31
Eigen.hpp

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