slope 6.5.4
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
23{
24public:
28 Clusters() = default;
29
34 Clusters(const Eigen::VectorXd& beta);
35
40 std::size_t size() { return c.size(); }
41
48 std::vector<int>::iterator begin(const int i);
49
56 std::vector<int>::iterator end(const int i);
57
64 std::vector<int>::const_iterator cbegin(const int i) const;
65
72 std::vector<int>::const_iterator cend(const int i) const;
73
79 int cluster_size(const int i) const;
80
86 int pointer(const int i) const;
87
92 int size() const;
93
99 double coeff(const int i) const;
100
111 void setCoeff(const int i, const double x);
112
117 const std::vector<double>& coeffs() const;
118
123 const std::vector<int>& indices() const;
124
129 const std::vector<int>& pointers() const;
130
137 void update(const int old_index, const int new_index, const double c_new);
138
143 void update(const Eigen::VectorXd& beta);
144
149 std::vector<std::vector<int>> getClusters() const;
150
151private:
152 std::vector<double> c;
153 std::vector<int> c_ind;
154 std::vector<int>
155 c_ptr;
156 int p;
163 void reorder(const int old_index, const int new_index);
164
170 void merge(const int old_index, const int new_index);
171};
172
182Eigen::SparseMatrix<int>
183patternMatrix(const Eigen::VectorXd& beta);
184
185} // namespace slope
Representation of the nonzero clusters in SLOPE.
Definition clusters.h:23
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 stored nonzero clusters.
Definition clusters.h:40
const std::vector< int > & indices() const
Returns the feature indices of all stored nonzero 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 the coefficients of all stored nonzero clusters.
int size() const
Returns the number of stored nonzero clusters.
const std::vector< int > & pointers() const
Returns the pointers of all stored nonzero 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.