9 const Eigen::ArrayXd& lambda)
const
11 assert(lambda.size() == beta.size() &&
12 "Coefficient and lambda sizes must agree");
14 Eigen::ArrayXd beta_abs = beta.array().abs();
16 return (beta_abs * lambda).sum();
21 const Eigen::ArrayXd& lambda)
const
24 using namespace Eigen;
26 assert(lambda.size() == beta.size() &&
27 "Coefficient and lambda sizes must agree");
29 ArrayXd beta_sign = beta.array().sign();
30 VectorXd beta_copy = beta.array().abs();
35 int p = beta_copy.size();
44 for (
int i = 0; i < p; i++) {
47 s(k) = beta_copy(i) - lambda(i);
50 while ((k > 0) && (w(k - 1) <= w(k))) {
54 w(k) = s(k) / (i - idx_i(k) + 1.0);
59 for (
int j = 0; j < k; j++) {
60 double d = std::max(w(j), 0.0);
61 for (
int i = idx_i(j); i <= idx_j(j); i++) {
68 beta_copy.array() *= beta_sign;
75 const Eigen::ArrayXd& lambda)
const
77 Eigen::ArrayXd abs_gradient = gradient.cwiseAbs();
78 sort(abs_gradient,
true);
80 assert(lambda.size() == gradient.size() &&
81 "Gradient and lambda sizes must agree");
87 return (
cumSum(abs_gradient) / 1e-6).maxCoeff();
90 return (
cumSum(abs_gradient) / (
cumSum(lambda))).maxCoeff();
double eval(const Eigen::VectorXd &beta, const Eigen::ArrayXd &lambda) const
Evaluates the Sorted L1 Norm.
double dualNorm(const Eigen::VectorXd &a, const Eigen::ArrayXd &lambda) const
Computes the dual norm of a vector.
Eigen::MatrixXd prox(const Eigen::VectorXd &beta, const Eigen::ArrayXd &lambda) const
Computes the proximal operator of the Sorted L1 Norm.
Mathematical support functions for the slope package.
Namespace containing SLOPE regression implementation.
Eigen::ArrayXd cumSum(const T &x)
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)
The declaration of the SortedL1Norm class.
Various utility functions.