39template<
typename MatrixType>
42 const Eigen::MatrixXd& residual,
43 const std::unique_ptr<Loss>& loss,
45 const Eigen::ArrayXd& lambda,
47 const Eigen::MatrixXd& y,
48 const Eigen::VectorXd& x_centers,
49 const Eigen::VectorXd& x_scales,
56 Eigen::VectorXd gradient(pm);
58 std::vector<int> full_set(pm);
59 std::iota(full_set.begin(), full_set.end(), 0);
67 Eigen::VectorXd::Ones(n),
70 Eigen::MatrixXd theta = residual;
73 Eigen::VectorXd dual_gradient = gradient;
79 Eigen::VectorXd theta_mean = theta.colwise().mean();
80 theta.rowwise() -= theta_mean.transpose();
92 double dual_norm = sl1_norm.
dualNorm(dual_gradient, lambda);
93 theta.array() /= std::max(1.0, dual_norm);
95 double dual = loss->dual(theta, y, Eigen::VectorXd::Ones(n));
Class representing the Sorted L1 Norm.
double dualNorm(const Eigen::VectorXd &a, const Eigen::ArrayXd &lambda) const
Computes the dual norm of a vector.
Enums to control predictor standardization behavior.
The declartion of the Objctive class and its subclasses, which represent the data-fitting part of the...
Namespace containing SLOPE regression implementation.
JitNormalization
Enums to control predictor standardization behavior.
double computeDual(const Eigen::VectorXd &beta, const Eigen::MatrixXd &residual, const std::unique_ptr< Loss > &loss, const SortedL1Norm &sl1_norm, const Eigen::ArrayXd &lambda, const MatrixType &x, const Eigen::MatrixXd &y, const Eigen::VectorXd &x_centers, const Eigen::VectorXd &x_scales, const JitNormalization &jit_normalization, const bool intercept)
Computes the dual objective function value for SLOPE optimization.
void updateGradient(Eigen::VectorXd &gradient, const T &x, const Eigen::MatrixXd &residual, const std::vector< int > &active_set, const Eigen::VectorXd &x_centers, const Eigen::VectorXd &x_scales, const Eigen::VectorXd &w, const JitNormalization jit_normalization)
void offsetGradient(Eigen::VectorXd &gradient, const T &x, const Eigen::VectorXd &offset, const std::vector< int > &active_set, const Eigen::VectorXd &x_centers, const Eigen::VectorXd &x_scales, const JitNormalization jit_normalization)
The declaration of the SortedL1Norm class.