9#include <Eigen/SparseCore>
14#include <unordered_set>
37sort(T& v,
const bool descending =
false)
40 std::sort(v.data(), v.data() + v.size(), std::greater<double>());
42 std::sort(v.data(), v.data() + v.size(), std::less<double>());
63 for (
int i = 0; i < x.size(); i++) {
93 vector<int> idx(v.size());
94 iota(idx.begin(), idx.end(), 0);
97 sort(idx.begin(), idx.end(), [&v](
int i,
int j) { return v[i] > v[j]; });
99 sort(idx.begin(), idx.end(), [&v](
int i,
int j) { return v[i] < v[j]; });
118permute(T& values,
const std::vector<int>& ind)
123 T out(values.size());
128 for (
int i = 0; i < values.size(); ++i)
129 out[i] = std::move(values[ind[i]]);
134 values = std::move(out);
154 T out(values.size());
156 for (
int i = 0; i < values.size(); ++i)
157 out[ind[i]] = std::move(values[i]);
159 values = std::move(out);
176move_elements(std::vector<T>& v,
const int from,
const int to,
const int size)
179 std::rotate(v.begin() + to, v.begin() + from, v.begin() + from + size);
181 std::rotate(v.begin() + from, v.begin() + from + size, v.begin() + to + 1);
199 const std::set<std::string>& valid_options,
200 const std::string& parameter_name);
214subset(
const Eigen::MatrixXd& x,
const std::vector<int>& indices);
228Eigen::SparseMatrix<double>
229subset(
const Eigen::SparseMatrix<double>& x,
const std::vector<int>& indices);
242subsetCols(
const Eigen::MatrixXd& x,
const std::vector<int>& indices);
256Eigen::SparseMatrix<double>
257subsetCols(
const Eigen::SparseMatrix<double>& x,
258 const std::vector<int>& indices);
271inline std::unordered_set<double>
274 std::unordered_set<double>
unique;
275 for (Eigen::Index j = 0; j < x.cols(); j++) {
276 for (Eigen::Index i = 0; i < x.rows(); i++) {
Namespace containing SLOPE regression implementation.
Eigen::MatrixXd subsetCols(const Eigen::MatrixXd &x, const std::vector< int > &indices)
Extract specified columns from a dense matrix.
std::unordered_set< double > unique(const Eigen::MatrixXd &x)
Create a set of unique values from an Eigen matrix.
void move_elements(std::vector< T > &v, const int from, const int to, const int size)
std::vector< int > which(const T &x)
void validateOption(const std::string &value, const std::set< std::string > &valid_options, const std::string ¶meter_name)
Validates if a given value exists in a set of valid options.
Eigen::MatrixXd subset(const Eigen::MatrixXd &x, const std::vector< int > &indices)
Extract a subset of rows from an Eigen matrix.
std::vector< int > sortIndex(T &v, const bool descending=false)
void permute(T &values, const std::vector< int > &ind)
void sort(T &v, const bool descending=false)
void inversePermute(T &values, const std::vector< int > &ind)