slope 6.2.1
Loading...
Searching...
No Matches
clusters.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <Eigen/SparseCore>
9#include <vector>
10
11namespace slope {
12
18{
19public:
23 Clusters() = default;
24
29 Clusters(const Eigen::VectorXd& beta);
30
35 std::size_t size() { return c.size(); }
36
43 std::vector<int>::iterator begin(const int i);
44
51 std::vector<int>::iterator end(const int i);
52
59 std::vector<int>::const_iterator cbegin(const int i) const;
60
67 std::vector<int>::const_iterator cend(const int i) const;
68
74 int cluster_size(const int i) const;
75
81 int pointer(const int i) const;
82
87 int size() const;
88
94 double coeff(const int i) const;
95
101 void setCoeff(const int i, const double x);
102
107 const std::vector<double>& coeffs() const;
108
113 const std::vector<int>& indices() const;
114
119 const std::vector<int>& pointers() const;
120
127 void update(const int old_index, const int new_index, const double c_new);
128
133 void update(const Eigen::VectorXd& beta);
134
139 std::vector<std::vector<int>> getClusters() const;
140
141private:
142 std::vector<double> c;
143 std::vector<int> c_ind;
144 std::vector<int>
145 c_ptr;
146 int p;
153 void reorder(const int old_index, const int new_index);
154
160 void merge(const int old_index, const int new_index);
161};
162
172Eigen::SparseMatrix<int>
173patternMatrix(const Eigen::VectorXd& beta);
174
175} // namespace slope
Representation of the clusters in SLOPE.
Definition clusters.h:18
void update(const int old_index, const int new_index, const double c_new)
Updates the cluster structure when an index is changed.
double coeff(const int i) const
Returns the coefficient of the cluster with the given index.
void update(const Eigen::VectorXd &beta)
Updates the cluster structure with the given beta vector.
std::size_t size()
Returns the number of clusters.
Definition clusters.h:35
const std::vector< int > & indices() const
Returns a vector containing the indices of all clusters.
int cluster_size(const int i) const
Returns the size of the cluster with the given index.
int pointer(const int i) const
Returns the pointer of the cluster with the given index.
std::vector< std::vector< int > > getClusters() const
Returns the clusters as a vector of vectors.
Clusters(const Eigen::VectorXd &beta)
Constructs a Clusters object with the given beta vector.
void setCoeff(const int i, const double x)
Sets the coefficient of the cluster with the given index.
std::vector< int >::iterator begin(const int i)
Returns an iterator pointing to the beginning of the cluster with the given index.
Clusters()=default
Constructs an Clusters object.
std::vector< int >::const_iterator cend(const int i) const
Returns a constant iterator pointing to the end of the cluster with the given index.
std::vector< int >::iterator end(const int i)
Returns an iterator pointing to the end of the cluster with the given index.
const std::vector< double > & coeffs() const
Returns a vector containing the coefficients of all clusters.
int size() const
Returns the number of clusters.
const std::vector< int > & pointers() const
Returns a vector containing the pointers of all clusters.
std::vector< int >::const_iterator cbegin(const int i) const
Returns a constant iterator pointing to the beginning of the cluster with the given index.
Namespace containing SLOPE regression implementation.
Definition clusters.h:11
Eigen::SparseMatrix< int > patternMatrix(const Eigen::VectorXd &beta)
Returns the cluster pattern as a sparse matrix.