Stan Math Library: stan/math/fwd/mat/fun/sort_desc.hpp Source File

| Stan Math Library 2.10.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

sort_desc.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_FWD_MAT_FUN_SORT_DESC_HPP
2 #define STAN_MATH_FWD_MAT_FUN_SORT_DESC_HPP
3
4 #include <stan/math/fwd/core.hpp>
5 #include <stan/math/prim/mat/fun/Eigen.hpp>
6 #include <algorithm> // std::sort
7 #include <functional> // std::greater
8 #include <vector>
9
10 namespace stan {
11
12 namespace math {
13
14 template <typename T>
15 inline
16 std::vector< fvar<T> >
17 sort_desc(std::vector< fvar<T> > xs) {
18 std::sort(xs.begin(), xs.end(), std::greater< fvar<T> >());
19 return xs;
20 }
21
22 template <typename T, int R, int C>
23 inline
24 typename Eigen::Matrix<fvar<T>, R, C>
25 sort_desc(Eigen::Matrix<fvar<T>, R, C> xs) {
26 std::sort(xs.data(), xs.data()+xs.size(), std::greater< fvar<T> >());
27 return xs;
28 }
29
30 }
31 }
32 #endif
core.hpp
stan::math::sort_desc
std::vector< fvar< T > > sort_desc(std::vector< fvar< T > > xs)
Definition: sort_desc.hpp:17
stan
Definition: log_sum_exp.hpp:8
Eigen.hpp
stan::math::fvar
Definition: fvar.hpp:13

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