All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
sort.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_PRIM_MAT_FUN_SORT_HPP
#define STAN_MATH_PRIM_MAT_FUN_SORT_HPP
#include <stan/math/prim/mat/fun/Eigen.hpp>
#include <vector>
#include <algorithm> // std::sort
#include <functional> // std::greater
namespace stan {
namespace math {
template <typename T>
inline typename std::vector<T> sort_asc(std::vector<T> xs) {
std::sort(xs.begin(), xs.end());
return xs;
}
template <typename T>
inline typename std::vector<T> sort_desc(std::vector<T> xs) {
std::sort(xs.begin(), xs.end(), std::greater<T>());
return xs;
}
template <typename T, int R, int C>
inline typename Eigen::Matrix<T, R, C> sort_asc(Eigen::Matrix<T, R, C> xs) {
std::sort(xs.data(), xs.data()+xs.size());
return xs;
}
template <typename T, int R, int C>
inline typename Eigen::Matrix<T, R, C>
sort_desc(Eigen::Matrix<T, R, C> xs) {
std::sort(xs.data(), xs.data()+xs.size(), std::greater<T>());
return xs;
}
}
}
#endif
stan::math::sort_desc
std::vector< fvar< T > > sort_desc(std::vector< fvar< T > > xs)
Definition: sort_desc.hpp:17
Eigen.hpp
stan::math::sort_asc
std::vector< fvar< T > > sort_asc(std::vector< fvar< T > > xs)
Definition: sort_asc.hpp:17

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