![]() |
slope 6.2.1
|
Namespace containing SLOPE regression implementation. More...
Namespaces | |
| namespace | constants |
| Namespace containing constants used in the slope library. | |
Classes | |
| class | Accuracy |
| Classification Accuracy scoring metric. More... | |
| class | AUC |
| Area Under the ROC Curve (AUC-ROC) scoring metric. More... | |
| class | Clusters |
| Representation of the clusters in SLOPE. More... | |
| struct | CvConfig |
| Configuration settings for cross-validation. More... | |
| struct | CvResult |
| Contains overall results from a cross-validation process. More... | |
| class | Deviance |
| Deviance scoring metric. More... | |
| class | Folds |
| Manages data partitioning for cross-validation. More... | |
| struct | GridResult |
| Stores cross-validation results for a specific set of hyperparameters. More... | |
| class | Hybrid |
| Hybrid CD-PGD solver for SLOPE. More... | |
| class | Logistic |
| The Logistic class represents a logistic loss function. More... | |
| class | Loss |
| Loss function interface. More... | |
| class | MAE |
| Mean Absolute Error (MAE) scoring metric. More... | |
| class | MaximizeScore |
| Scoring metric that aims to maximize the score value. More... | |
| class | MinimizeScore |
| Scoring metric that aims to minimize the score value. More... | |
| class | MisClass |
| Misclassification Rate scoring metric. More... | |
| class | MSE |
| Mean Squared Error (MSE) scoring metric. More... | |
| class | Multinomial |
| The Multinomial class represents a multinomial logistic regression loss function. More... | |
| class | NoScreening |
| No screening rule - uses all variables. More... | |
| class | PGD |
| Proximal Gradient Descent solver for SLOPE optimization. More... | |
| class | Poisson |
| The Poisson class represents a Poisson regression loss function. More... | |
| class | Quadratic |
| Implementation of the Quadratic loss function. More... | |
| class | Score |
| Base class for scoring metrics used in regularized generalized linear regression. More... | |
| class | ScreeningRule |
| Base class for screening rules in SLOPE. More... | |
| class | Slope |
| The SLOPE model. More... | |
| class | SlopeFit |
| A class representing the results of SLOPE (Sorted L1 Penalized Estimation) fitting. More... | |
| class | SlopePath |
| Container class for SLOPE regression solution paths. More... | |
| class | SolverBase |
| Abstract base class for SLOPE optimization solvers. More... | |
| class | SortedL1Norm |
| Class representing the Sorted L1 Norm. More... | |
| class | StrongScreening |
| Implements strong screening rules for SLOPE. More... | |
| class | Threads |
| Manages OpenMP thread settings across libslope. More... | |
| class | Timer |
| Timer class for measuring elapsed time with high resolution. More... | |
| struct | Warning |
| Structure representing a warning with its code and message. More... | |
| class | WarningLogger |
| Thread-safe warning logger for tracking runtime warnings. More... | |
Enumerations | |
| enum class | JitNormalization { None = 0 , Center = 1 , Scale = 2 , Both = 3 } |
| Enums to control predictor standardization behavior. More... | |
| enum class | WarningCode { GENERIC_WARNING , DEPRECATED_FEATURE , MAXIT_REACHED , LINE_SEARCH_FAILED } |
| Standard warning codes used throughout the slope library. More... | |
Functions | |
| Eigen::SparseMatrix< int > | patternMatrix (const Eigen::VectorXd &beta) |
| Returns the cluster pattern as a sparse matrix. | |
| template<typename T > | |
| CvResult | crossValidate (Slope model, Eigen::EigenBase< T > &x, const Eigen::MatrixXd &y_in, const CvConfig &config=CvConfig()) |
| Performs cross-validation on a SLOPE model to select optimal hyperparameters. | |
| template<typename MatrixType > | |
| 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. | |
| template<typename T > | |
| double | estimateNoise (Eigen::EigenBase< T > &x, Eigen::MatrixXd &y, const bool fit_intercept) |
| Estimates noise (standard error) in a linear model using OLS residuals. | |
| std::string | warningCodeToString (WarningCode code) |
| Convert a warning code to its string representation. | |
| std::unique_ptr< Loss > | setupLoss (const std::string &loss) |
| Factory function to create the appropriate loss function based on the distribution family. | |
| template<typename T > | |
| int | sign (T val) |
| Returns the sign of a given value. | |
| template<typename T > | |
| Eigen::ArrayXd | cumSum (const T &x, const bool leading_zero=false) |
| template<typename T > | |
| T | sigmoid (const T &x) |
| template<typename T > | |
| T | logit (const T &x) |
| template<typename T > | |
| T | clamp (const T &x, const T &lo, const T &hi) |
| Eigen::VectorXd | logSumExp (const Eigen::MatrixXd &a) |
| Eigen::MatrixXd | softmax (const Eigen::MatrixXd &x) |
| template<typename T > | |
| Eigen::MatrixXd | linearPredictor (const T &x, const std::vector< int > &active_set, const Eigen::VectorXd &beta0, const Eigen::VectorXd &beta, const Eigen::VectorXd &x_centers, const Eigen::VectorXd &x_scales, const JitNormalization jit_normalization, const bool intercept) |
| template<typename T > | |
| 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) |
| template<typename T > | |
| 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) |
| std::vector< int > | setUnion (const std::vector< int > &a, const std::vector< int > &b) |
| Computes the union of two sorted integer vectors. | |
| std::vector< int > | setDiff (const std::vector< int > &a, const std::vector< int > &b) |
| Computes the set difference of two sorted integer vectors. | |
| template<typename T > | |
| int | whichMax (const T &x) |
| Returns the index of the maximum element in a container. | |
| template<typename T > | |
| int | whichMin (const T &x) |
| Returns the index of the minimum element in a container. | |
| template<typename T , typename Comparator > | |
| int | whichBest (const T &x, const Comparator &comp) |
| Returns the index of the minimum element in a container. | |
| Eigen::ArrayXd | geomSpace (const double start, const double end, const int n) |
| Creates an array of n numbers in geometric progression from start to end. | |
| template<typename T > | |
| Eigen::VectorXd | l1Norms (const T &x) |
| Computes the L1 (Manhattan) norms for each column of a matrix. | |
| template<typename T > | |
| Eigen::VectorXd | l2Norms (const Eigen::SparseMatrixBase< T > &x) |
| Computes the L2 (Euclidean) norms for each column of a sparse matrix. | |
| template<typename T > | |
| Eigen::VectorXd | l2Norms (const Eigen::MatrixBase< T > &x) |
| Computes the L2 (Euclidean) norms for each column of a dense matrix. | |
| template<typename T > | |
| Eigen::VectorXd | maxAbs (const Eigen::SparseMatrixBase< T > &x) |
| Computes the maximum absolute value for each column of a matrix. | |
| template<typename T > | |
| Eigen::VectorXd | maxAbs (const Eigen::MatrixBase< T > &x) |
| Computes the maximum absolute value for each column of a dense matrix. | |
| template<typename T > | |
| Eigen::VectorXd | means (const Eigen::SparseMatrixBase< T > &x) |
| Computes the arithmetic mean for each column of a sparse matrix. | |
| template<typename T > | |
| Eigen::VectorXd | means (const Eigen::MatrixBase< T > &x) |
| Computes the arithmetic mean for each column of a dense matrix. | |
| template<typename T > | |
| Eigen::VectorXd | stdDevs (const Eigen::SparseMatrixBase< T > &x) |
| Computes the standard deviation for each column of a matrix. | |
| template<typename T > | |
| Eigen::VectorXd | stdDevs (const Eigen::MatrixBase< T > &x) |
| Computes the standard deviation for each column of a matrix. | |
| template<typename T > | |
| Eigen::VectorXd | ranges (const Eigen::SparseMatrixBase< T > &x) |
| Computes the range (max - min) for each column of a matrix. | |
| template<typename T > | |
| Eigen::VectorXd | ranges (const Eigen::MatrixBase< T > &x) |
| Computes the range (max - min) for each column of a dense matrix. | |
| template<typename T > | |
| Eigen::VectorXd | mins (const Eigen::SparseMatrixBase< T > &x) |
| Computes the minimum value for each column of a sparse matrix. | |
| template<typename T > | |
| Eigen::VectorXd | mins (const Eigen::MatrixBase< T > &x) |
| Computes the minimum value for each column of a dense matrix. | |
| template<typename T > | |
| Eigen::VectorXd | clusterGradient (Eigen::VectorXd &beta, Eigen::MatrixXd &residual, Clusters &clusters, const T &x, const Eigen::MatrixXd &w, const Eigen::VectorXd &x_centers, const Eigen::VectorXd &x_scales, const JitNormalization jit_normalization) |
| template<typename T > | |
| void | computeCenters (Eigen::VectorXd &x_centers, const T &x, const std::string &type) |
| template<typename T > | |
| void | computeScales (Eigen::VectorXd &x_scales, const T &x, const std::string &type) |
| template<typename T > | |
| JitNormalization | normalize (Eigen::MatrixBase< T > &x, Eigen::VectorXd &x_centers, Eigen::VectorXd &x_scales, const std::string ¢ering_type, const std::string &scaling_type, const bool modify_x) |
| template<typename T > | |
| JitNormalization | normalize (Eigen::SparseMatrixBase< T > &x, Eigen::VectorXd &x_centers, Eigen::VectorXd &x_scales, const std::string ¢ering_type, const std::string &scaling_type, const bool) |
| std::tuple< Eigen::VectorXd, Eigen::MatrixXd > | rescaleCoefficients (const Eigen::VectorXd &beta0, const Eigen::SparseMatrix< double > &beta, const Eigen::VectorXd &x_centers, const Eigen::VectorXd &x_scales, const bool intercept) |
| Rescales the coefficients using the given parameters. | |
| Eigen::ArrayXd | lambdaSequence (const int p, const double q, const std::string &type, const int n=-1, const double theta1=1.0, const double theta2=1.0) |
| Eigen::ArrayXd | regularizationPath (const Eigen::ArrayXd &alpha_in, const int path_length, double alpha_min_ratio, const double alpha_max) |
| double | binaryRocAuc (const Eigen::VectorXd &scores, const Eigen::VectorXd &labels) |
| double | rocAuc (const Eigen::MatrixXd &scores, const Eigen::MatrixXd &labels) |
| std::vector< int > | activeSet (const Eigen::VectorXd &beta) |
| Identifies previously active variables. | |
| std::vector< int > | strongSet (const Eigen::VectorXd &gradient_prev, const Eigen::ArrayXd &lambda, const Eigen::ArrayXd &lambda_prev) |
| Determines the strong set using sequential strong rules. | |
| std::unique_ptr< ScreeningRule > | createScreeningRule (const std::string &screening_type) |
| Creates a screening rule based on the provided type. | |
| bool | defaultInterruptChecker () |
| Default no-op interrupt checker. | |
| template<typename T > | |
| std::pair< double, double > | computeGradientAndHessian (const T &x, const int ind, const Eigen::MatrixXd &w, const Eigen::MatrixXd &residual, const Eigen::VectorXd &x_centers, const Eigen::VectorXd &x_scales, const double s, const JitNormalization jit_normalization, const int n) |
| template<typename T > | |
| std::pair< double, double > | computeClusterGradientAndHessian (const Eigen::MatrixBase< T > &x, const int c_ind, const std::vector< int > &s, const Clusters &clusters, const Eigen::MatrixXd &w, const Eigen::MatrixXd &residual, const Eigen::VectorXd &x_centers, const Eigen::VectorXd &x_scales, const JitNormalization jit_normalization) |
| template<typename T > | |
| std::pair< double, double > | computeClusterGradientAndHessian (const Eigen::SparseMatrixBase< T > &x, const int c_ind, const std::vector< int > &s, const Clusters &clusters, const Eigen::MatrixXd &w, const Eigen::MatrixXd &residual, const Eigen::VectorXd &x_centers, const Eigen::VectorXd &x_scales, const JitNormalization jit_normalization) |
| template<typename T > | |
| double | coordinateDescent (Eigen::VectorXd &beta0, Eigen::VectorXd &beta, Eigen::MatrixXd &residual, Clusters &clusters, const Eigen::ArrayXd &lambda_cumsum, const T &x, const Eigen::MatrixXd &w, const Eigen::VectorXd &x_centers, const Eigen::VectorXd &x_scales, const bool intercept, const JitNormalization jit_normalization, const bool update_clusters, std::mt19937 &rng, const std::string &cd_type="cyclical") |
| std::unique_ptr< SolverBase > | setupSolver (const std::string &solver_type, const std::string &loss, JitNormalization jit_normalization, bool intercept, bool update_clusters, int cd_iterations, const std::string &cd_type, std::optional< int > random_seed=std::nullopt) |
| Factory function to create and configure a SLOPE solver. | |
| std::tuple< double, int > | slopeThreshold (const double x, const int j, const Eigen::ArrayXd &lambda_cumsum, const Clusters &clusters) |
| template<typename Derived > | |
| Eigen::Index | nonZeros (const Eigen::SparseMatrixBase< Derived > &x) |
| template<typename Derived > | |
| Eigen::Index | nonZeros (const Eigen::DenseBase< Derived > &x) |
| template<typename T > | |
| void | sort (T &v, const bool descending=false) |
| template<typename T > | |
| std::vector< int > | which (const T &x) |
| template<typename T > | |
| std::vector< int > | sortIndex (T &v, const bool descending=false) |
| template<typename T > | |
| void | permute (T &values, const std::vector< int > &ind) |
| template<typename T > | |
| void | inversePermute (T &values, const std::vector< int > &ind) |
| template<typename T > | |
| void | move_elements (std::vector< T > &v, const int from, const int to, const int size) |
| 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. | |
| template<typename T > | |
| T | subset (const Eigen::EigenBase< T > &x, const std::vector< int > &indices) |
| Extract a subset of rows from an Eigen matrix. | |
| template<typename T > | |
| Eigen::MatrixBase< T >::PlainObject | subset (const Eigen::DenseBase< T > &x, const std::vector< int > &indices) |
| Extract a subset of rows from an Eigen matrix. | |
| template<typename T > | |
| T | subset (const Eigen::SparseMatrixBase< T > &x, const std::vector< int > &indices) |
| Extract a subset of rows from a sparse Eigen matrix. | |
| template<typename T > | |
| T | subsetCols (const Eigen::MatrixBase< T > &x, const std::vector< int > &indices) |
| Extract specified columns from a dense matrix. | |
| template<typename T > | |
| T | subsetCols (const Eigen::SparseMatrixBase< T > &x, const std::vector< int > &indices) |
| std::unordered_set< double > | unique (const Eigen::MatrixXd &x) |
| Create a set of unique values from an Eigen matrix. | |
Namespace containing SLOPE regression implementation.
|
strong |
Enums to control predictor standardization behavior.
| Enumerator | |
|---|---|
| None | No JIT normalization. |
| Center | Center JIT. |
| Scale | Scale JIT. |
| Both | Both. |
Definition at line 12 of file jit_normalization.h.
|
strong |
Standard warning codes used throughout the slope library.
These enum values represent the various types of warnings that can be generated during computational operations.
| std::vector< int > slope::activeSet | ( | const Eigen::VectorXd & | beta | ) |
Identifies previously active variables.
| beta | Current coefficient matrix |
| double slope::binaryRocAuc | ( | const Eigen::VectorXd & | scores, |
| const Eigen::VectorXd & | labels | ||
| ) |
Computes the Area Under the ROC Curve (AUC-ROC) for binary classification.
| scores | Vector of prediction scores/probabilities for each sample |
| labels | Vector of true binary labels (0 or 1) |
Both input vectors must have the same length. The function calculates how well the scores discriminate between the positive and negative classes.
| T slope::clamp | ( | const T & | x, |
| const T & | lo, | ||
| const T & | hi | ||
| ) |
| Eigen::VectorXd slope::clusterGradient | ( | Eigen::VectorXd & | beta, |
| Eigen::MatrixXd & | residual, | ||
| Clusters & | clusters, | ||
| const T & | x, | ||
| const Eigen::MatrixXd & | w, | ||
| const Eigen::VectorXd & | x_centers, | ||
| const Eigen::VectorXd & | x_scales, | ||
| const JitNormalization | jit_normalization | ||
| ) |
Computes the gradient for clustered variables.
This function calculates the gradient of the loss function with respect to the clustered coefficients, taking into account the cluster structure where multiple variables may have the same coefficient magnitude.
| beta | Current coefficient vector (modified in-place) |
| residual | Current residual matrix (modified in-place) |
| clusters | Cluster information object containing variable groupings |
| x | Input feature matrix |
| w | Weight matrix for observations |
| x_centers | Vector of feature centers (means) for normalization |
| x_scales | Vector of feature scales (standard deviations) for normalization |
| jit_normalization | Normalization strategy applied to features |
| void slope::computeCenters | ( | Eigen::VectorXd & | x_centers, |
| const T & | x, | ||
| const std::string & | type | ||
| ) |
Compute centers.
There are two supported centering types:
| T | The type of the input matrix. |
| x_centers | A vector where the computed or provided centers will be stored. |
| x | The input matrix. |
| type | A string specifying the normalization type ("none", "manual", or "standardization"). |
| std::invalid_argument | if the provided manual centers or scales have invalid dimensions or contain non-finite values. |
Definition at line 33 of file normalize.h.
| std::pair< double, double > slope::computeClusterGradientAndHessian | ( | const Eigen::MatrixBase< T > & | x, |
| const int | c_ind, | ||
| const std::vector< int > & | s, | ||
| const Clusters & | clusters, | ||
| const Eigen::MatrixXd & | w, | ||
| const Eigen::MatrixXd & | residual, | ||
| const Eigen::VectorXd & | x_centers, | ||
| const Eigen::VectorXd & | x_scales, | ||
| const JitNormalization | jit_normalization | ||
| ) |
Computes the gradient and Hessian for a cluster of variables in coordinate descent.
This function handles the case when multiple variables are in the same cluster (have the same coefficient magnitude), calculating the combined gradient and Hessian needed for the coordinate descent update.
| x | Input matrix |
| c_ind | Cluster index |
| s | Vector of signs for each variable in the cluster |
| clusters | The cluster information object |
| w | Weights |
| residual | Residual vector |
| x_centers | Vector of feature centers (means) |
| x_scales | Vector of feature scales (standard deviations) |
| jit_normalization | Normalization strategy (Both, Center, Scale, or None) |
Definition at line 127 of file hybrid_cd.h.
| std::pair< double, double > slope::computeClusterGradientAndHessian | ( | const Eigen::SparseMatrixBase< T > & | x, |
| const int | c_ind, | ||
| const std::vector< int > & | s, | ||
| const Clusters & | clusters, | ||
| const Eigen::MatrixXd & | w, | ||
| const Eigen::MatrixXd & | residual, | ||
| const Eigen::VectorXd & | x_centers, | ||
| const Eigen::VectorXd & | x_scales, | ||
| const JitNormalization | jit_normalization | ||
| ) |
Computes the gradient and Hessian for a cluster of variables in coordinate descent (sparse matrix version).
This overloaded version handles sparse input matrices, optimizing the computation for this data structure.
| x | Input sparse matrix |
| c_ind | Cluster index |
| s | Vector of signs for each variable in the cluster |
| clusters | The cluster information object |
| w | Vector of weights |
| residual | Residual vector |
| x_centers | Vector of feature centers (means) |
| x_scales | Vector of feature scales (standard deviations) |
| jit_normalization | Normalization strategy (Both, Center, Scale, or None) |
Definition at line 207 of file hybrid_cd.h.
| double slope::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.
| MatrixType | The type of the design matrix |
| beta | Current coefficient vector |
| residual | Residual matrix (y - prediction) |
| loss | Pointer to the loss function object |
| sl1_norm | Sorted L1 norm object |
| lambda | Vector of penalty parameters |
| x | Design matrix |
| y | Response matrix |
| x_centers | Vector of feature means for centering |
| x_scales | Vector of feature scales for normalization |
| jit_normalization | Just-in-time normalization settings |
| intercept | Boolean indicating if intercept is included in the model |
This function computes the dual objective value for the SLOPE optimization problem. It handles both cases with and without intercept terms, applying appropriate normalization and gradient computations.
Definition at line 41 of file diagnostics.h.
| std::pair< double, double > slope::computeGradientAndHessian | ( | const T & | x, |
| const int | ind, | ||
| const Eigen::MatrixXd & | w, | ||
| const Eigen::MatrixXd & | residual, | ||
| const Eigen::VectorXd & | x_centers, | ||
| const Eigen::VectorXd & | x_scales, | ||
| const double | s, | ||
| const JitNormalization | jit_normalization, | ||
| const int | n | ||
| ) |
Computes the gradient and Hessian for coordinate descent optimization with different normalization strategies.
| T | Matrix type (expected to support col() operations like Eigen matrices) |
| x | Input matrix |
| ind | Column index to compute derivatives for |
| w | Vector of weights |
| residual | Residual vector |
| x_centers | Vector of feature centers (means) |
| x_scales | Vector of feature scales (standard deviations) |
| s | Step size parameter |
| jit_normalization | Normalization strategy (Both, Center, Scale, or None) |
| n | Number of samples |
Definition at line 43 of file hybrid_cd.h.
| void slope::computeScales | ( | Eigen::VectorXd & | x_scales, |
| const T & | x, | ||
| const std::string & | type | ||
| ) |
Compute scales
There are two supported scaling types:
| T | The type of the input matrix. |
| x | The input matrix. |
| x_scales | A vector where the computed or provided scales will be stored. |
| type | A string specifying the normalization type ("none", "manual", or "standardization"). |
| std::invalid_argument | if the provided manual centers or scales have invalid dimensions or contain non-finite values. |
Definition at line 74 of file normalize.h.
| double slope::coordinateDescent | ( | Eigen::VectorXd & | beta0, |
| Eigen::VectorXd & | beta, | ||
| Eigen::MatrixXd & | residual, | ||
| Clusters & | clusters, | ||
| const Eigen::ArrayXd & | lambda_cumsum, | ||
| const T & | x, | ||
| const Eigen::MatrixXd & | w, | ||
| const Eigen::VectorXd & | x_centers, | ||
| const Eigen::VectorXd & | x_scales, | ||
| const bool | intercept, | ||
| const JitNormalization | jit_normalization, | ||
| const bool | update_clusters, | ||
| std::mt19937 & | rng, | ||
| const std::string & | cd_type = "cyclical" |
||
| ) |
Coordinate Descent Step
This function takes a coordinate descent step in the hybrid CD/PGD algorithm for SLOPE.
| T | The type of the design matrix. This can be either a dense or sparse. |
| beta0 | The intercept |
| beta | The coefficients |
| residual | The residual vector |
| clusters | The cluster information, stored in a Cluster object. |
| lambda_cumsum | Cumulative sum of the lambda sequence. |
| x | The design matrix |
| w | Working weights |
| x_centers | The center values of the data matrix columns |
| x_scales | The scale values of the data matrix columns |
| intercept | Shuold an intervept be fit? |
| jit_normalization | Type o fJIT normalization. |
| rng | Random number generator for shuffling indices in permuted CD. |
| update_clusters | Flag indicating whether to update the clusters after each uupdate. |
| cd_type | Type of coordinate descent to use ("cyclical" or "permuted") |
Definition at line 332 of file hybrid_cd.h.
| std::unique_ptr< ScreeningRule > slope::createScreeningRule | ( | const std::string & | screening_type | ) |
Creates a screening rule based on the provided type.
| screening_type | Type of screening rule to create ("none" or "strong") |
| CvResult slope::crossValidate | ( | Slope | model, |
| Eigen::EigenBase< T > & | x, | ||
| const Eigen::MatrixXd & | y_in, | ||
| const CvConfig & | config = CvConfig() |
||
| ) |
Performs cross-validation on a SLOPE model to select optimal hyperparameters.
| T | Type of design matrix (supports both dense and sparse matrices) |
| model | The SLOPE model to be cross-validated |
| x | The design matrix containing predictors |
| y_in | The response matrix |
| config | Configuration parameters for cross-validation (optional) |
This function implements k-fold cross-validation for SLOPE models, evaluating model performance across a grid of hyperparameters. For each hyperparameter combination, the function:
The function supports parallel processing with OpenMP when available.
| Eigen::ArrayXd slope::cumSum | ( | const T & | x, |
| const bool | leading_zero = false |
||
| ) |
Calculates the cumulative sum of the elements in the input array.
| T | The type of the input array. |
| x | The input array. |
| leading_zero | If true, the output array will have an additional leading |
|
inline |
| double slope::estimateNoise | ( | Eigen::EigenBase< T > & | x, |
| Eigen::MatrixXd & | y, | ||
| const bool | fit_intercept | ||
| ) |
Estimates noise (standard error) in a linear model using OLS residuals.
Calculates the standard error of the residuals from an Ordinary Least Squares (OLS) regression. This is computed as sqrt(sum(residuals²) / (n - p + intercept_term)), where n is the number of observations and p is the number of predictors.
| MatrixType | The type of matrix used to store the design matrix |
| x | Design matrix with n observations and p predictors |
| y | Response matrix |
| fit_intercept | Whether to include an intercept term in the model |
Definition at line 29 of file estimate_alpha.h.
| Eigen::ArrayXd slope::geomSpace | ( | const double | start, |
| const double | end, | ||
| const int | n | ||
| ) |
Creates an array of n numbers in geometric progression from start to end.
| start | The starting value of the sequence |
| end | The final value of the sequence |
| n | The number of points to generate |
| std::invalid_argument | If start or end is zero, or if n < 1 |
| void slope::inversePermute | ( | T & | values, |
| const std::vector< int > & | ind | ||
| ) |
Inverse permutes the elements of a container based on the given indices.
This function takes a container of values and a vector of indices and rearranges the elements of the container according to the indices. The resulting container will have the elements in the order specified by the indices.
| T | The type of the container. |
| values | The container of values to be permuted. |
| ind | The vector of indices specifying the new order of the elements. |
< The resulting container after permutation.
| Eigen::VectorXd slope::l1Norms | ( | const T & | x | ) |
Computes the L1 (Manhattan) norms for each column of a matrix.
| T | Matrix type (must support cols(), col() operations, compatible with Eigen) |
| x | Input matrix whose column L1 norms are to be computed |
For each column j in matrix x, computes the L1 norm:
\[ \|x_j\|_1 = \sum_{i} |x_{ij}| \]
where x_{ij} represents the i-th element of the j-th column.
| Eigen::VectorXd slope::l2Norms | ( | const Eigen::MatrixBase< T > & | x | ) |
Computes the L2 (Euclidean) norms for each column of a dense matrix.
| x | Input dense matrix whose column L2 norms are to be computed |
For each column j in matrix x, computes the L2 norm:
\[ \|x_j\|_2 = \sqrt{\sum_{i} x_{ij}^2} \]
where x_{ij} represents the i-th element of the j-th column.
| Eigen::VectorXd slope::l2Norms | ( | const Eigen::SparseMatrixBase< T > & | x | ) |
Computes the L2 (Euclidean) norms for each column of a sparse matrix.
| x | Input sparse matrix whose column L2 norms are to be computed |
For each column j in matrix x, computes the L2 norm:
\[ \|x_j\|_2 = \sqrt{\sum_{i} x_{ij}^2} \]
where x_{ij} represents the i-th element of the j-th column.
| Eigen::ArrayXd slope::lambdaSequence | ( | const int | p, |
| const double | q, | ||
| const std::string & | type, | ||
| const int | n = -1, |
||
| const double | theta1 = 1.0, |
||
| const double | theta2 = 1.0 |
||
| ) |
Generates a sequence of regularization weights for the sorted L1 norm.
| p | The number of lambda values to generate (number of features) |
| q | The false discovery rate (FDR) level or quantile value (in (0, 1)) |
| type | The type of sequence to generate:
|
| n | Number of observations (only used for gaussian type) |
| theta1 | First parameter for OSCAR weights (default: 1.0) |
| theta2 | Second parameter for OSCAR weights (default: 1.0) |
| Eigen::MatrixXd slope::linearPredictor | ( | const T & | x, |
| const std::vector< int > & | active_set, | ||
| const Eigen::VectorXd & | beta0, | ||
| const Eigen::VectorXd & | beta, | ||
| const Eigen::VectorXd & | x_centers, | ||
| const Eigen::VectorXd & | x_scales, | ||
| const JitNormalization | jit_normalization, | ||
| const bool | intercept | ||
| ) |
Computes the gradient of the loss with respect to \(\beta\).
| T | The type of the input matrix. |
| x | The input matrix. |
| active_set | Indicies for active set |
| beta0 | Intercept |
| beta | Coefficients |
| x_centers | The vector of center values for each column of x. |
| x_scales | The vector of scale values for each column of x. |
| jit_normalization | Type of JIT normalization. |
| intercept | Whether to fit an intercept. |
| T slope::logit | ( | const T & | x | ) |
| Eigen::VectorXd slope::logSumExp | ( | const Eigen::MatrixXd & | a | ) |
LogSumExp
| a | A matrix |
| Eigen::VectorXd slope::maxAbs | ( | const Eigen::MatrixBase< T > & | x | ) |
Computes the maximum absolute value for each column of a dense matrix.
| x | Input dense matrix whose column-wise maximum absolute values are to be computed |
For each column j in matrix x, computes:
\[ \max_{i} |x_{ij}| \]
where x_{ij} represents the i-th element of the j-th column.
| Eigen::VectorXd slope::maxAbs | ( | const Eigen::SparseMatrixBase< T > & | x | ) |
Computes the maximum absolute value for each column of a matrix.
| x | Input matrix to compute column-wise maximum absolute values |
For each column j in matrix x, computes:
\[ \max_{i} |x_{ij}| \]
where x_{ij} represents the i-th element of the j-th column.
| Eigen::VectorXd slope::means | ( | const Eigen::MatrixBase< T > & | x | ) |
Computes the arithmetic mean for each column of a dense matrix.
| x | Input dense matrix whose column means are to be computed |
For each column j in matrix x, computes the mean:
\[ \bar{x}_j = \frac{1}{n}\sum_{i} x_{ij} \]
where n is the number of rows in the matrix and x_{ij} represents the i-th element of the j-th column.
| Eigen::VectorXd slope::means | ( | const Eigen::SparseMatrixBase< T > & | x | ) |
Computes the arithmetic mean for each column of a sparse matrix.
| x | Input sparse matrix whose column means are to be computed |
For each column j in matrix x, computes the mean:
\[ \bar{x}_j = \frac{1}{n}\sum_{i} x_{ij} \]
where n is the number of rows in the matrix and x_{ij} represents the i-th element of the j-th column.
| Eigen::VectorXd slope::mins | ( | const Eigen::MatrixBase< T > & | x | ) |
Computes the minimum value for each column of a dense matrix.
| x | Input dense matrix whose column minimums are to be computed |
For each column j in matrix x, computes:
\[ \min_{i}(x_{ij}) \]
where x_{ij} represents the i-th element of the j-th column.
Uses Eigen's built-in column-wise operations for efficient computation on dense matrices.
| Eigen::VectorXd slope::mins | ( | const Eigen::SparseMatrixBase< T > & | x | ) |
Computes the minimum value for each column of a sparse matrix.
| x | Input sparse matrix whose column minimums are to be computed |
For each column j in matrix x, computes:
\[ \min_{i}(x_{ij}) \]
where x_{ij} represents the i-th element of the j-th column.
| void slope::move_elements | ( | std::vector< T > & | v, |
| const int | from, | ||
| const int | to, | ||
| const int | size | ||
| ) |
Moves a range of elements within a vector.
This function moves a range of elements within a vector from one position to another. The elements are moved in a way that the order is preserved.
| T | The type of elements in the vector. |
| v | The vector containing the elements. |
| from | The starting index of the range to be moved. |
| to | The ending index of the range to be moved. |
| size | The size of the range to be moved. |
| Eigen::Index slope::nonZeros | ( | const Eigen::DenseBase< Derived > & | x | ) |
| Eigen::Index slope::nonZeros | ( | const Eigen::SparseMatrixBase< Derived > & | x | ) |
Count non-zero elements in a matrix.
Helper function for Eigen matrices since nonZeros() was removed from dense matrices in Eigen 5.0.0, but still exists for sparse matrices.
| x | Sparse matrix |
| JitNormalization slope::normalize | ( | Eigen::MatrixBase< T > & | x, |
| Eigen::VectorXd & | x_centers, | ||
| Eigen::VectorXd & | x_scales, | ||
| const std::string & | centering_type, | ||
| const std::string & | scaling_type, | ||
| const bool | modify_x | ||
| ) |
Normalize a dense matrix by centering and scaling.
The function computes column centers and scaling factors based on the specified normalization type ("none", "manual", or "standardization"). If modify_x is true, the normalization is applied directly to the input matrix.
| x | The dense input matrix to be normalized. |
| x_centers | A vector that will hold the column centers. It will be resized to match the number of columns. |
| x_scales | A vector that will hold the column scaling factors. It will be resized to match the number of columns. |
| centering_type | A string specifying the normalization type ("none", "manual", or "standardization"). |
| scaling_type | A string specifying the normalization type ("none", "manual", or "standardization"). |
| modify_x | If true, modifies x in-place; otherwise, x remains unchanged (centers/scales are still computed). |
Definition at line 123 of file normalize.h.
| JitNormalization slope::normalize | ( | Eigen::SparseMatrixBase< T > & | x, |
| Eigen::VectorXd & | x_centers, | ||
| Eigen::VectorXd & | x_scales, | ||
| const std::string & | centering_type, | ||
| const std::string & | scaling_type, | ||
| const bool | |||
| ) |
Normalize a sparse matrix by scaling only.
To preserve sparsity, centering is not applied. The scaling factors for each column are computed according to the specified normalization type ("none", "manual", or "standardization"). If modify_x is true, the scaling is applied directly to the input matrix.
| x | The sparse input matrix to be normalized. |
| x_centers | A vector that will hold the column centers. For sparse matrices, centering is typically skipped; this parameter is maintained for consistency. |
| x_scales | A vector that will hold the column scaling factors. It will be resized to match the number of columns. |
| centering_type | A string specifying the normalization type ("none", "manual", or "standardization"). |
| scaling_type | A string specifying the normalization type ("none", "manual", or "standardization"). |
Definition at line 199 of file normalize.h.
| void slope::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 | ||
| ) |
Computes the gradient of the loss with respect to \(\beta\).
| T | The type of the input matrix. |
| gradient | The residual vector. |
| x | The input matrix. |
| offset | Gradient offset |
| active_set | Indices for the active_set |
| x_centers | The vector of center values for each column of x. |
| x_scales | The vector of scale values for each column of x. |
| jit_normalization | Type of JIT normalization just-in-time. |
| Eigen::SparseMatrix< int > slope::patternMatrix | ( | const Eigen::VectorXd & | beta | ) |
Returns the cluster pattern as a sparse matrix.
| beta | The beta vector used to create the clusters |
| void slope::permute | ( | T & | values, |
| const std::vector< int > & | ind | ||
| ) |
Permutes the elements of a container according to the given indices.
This function takes a container of values and permutes its elements according to the given indices. The indices specify the new order of the elements in the container.
| T | The type of the container. |
| values | The container of values to be permuted. |
| ind | The vector of indices specifying the new order of the elements. |
The container to store the permuted values.
Permute the values according to the given indices.
Assign the permuted values back to the original container.
| Eigen::VectorXd slope::ranges | ( | const Eigen::MatrixBase< T > & | x | ) |
Computes the range (max - min) for each column of a dense matrix.
| x | Input dense matrix whose column ranges are to be computed |
For each column j in matrix x, computes:
\[ range_j = \max_{i}(x_{ij}) - \min_{i}(x_{ij}) \]
where x_{ij} represents the i-th element of the j-th column.
Uses Eigen's efficient colwise() operations to compute maximum and minimum values for each column simultaneously.
| Eigen::VectorXd slope::ranges | ( | const Eigen::SparseMatrixBase< T > & | x | ) |
Computes the range (max - min) for each column of a matrix.
| x | Input matrix whose column ranges are to be computed |
For each column j in matrix x, computes:
\[ range_j = \max_{i}(x_{ij}) - \min_{i}(x_{ij}) \]
where x_{ij} represents the i-th element of the j-th column.
| Eigen::ArrayXd slope::regularizationPath | ( | const Eigen::ArrayXd & | alpha_in, |
| const int | path_length, | ||
| double | alpha_min_ratio, | ||
| const double | alpha_max | ||
| ) |
Computes a sequence of regularization weights for the SLOPE path.
| alpha_in | Alpha sequence, of length zero if automatic. |
| path_length | Length of path. |
| alpha_min_ratio | Ratio of minimum to maximum alpha |
| alpha_max | Value of alpha as which the model is completely sparse |
| std::tuple< Eigen::VectorXd, Eigen::MatrixXd > slope::rescaleCoefficients | ( | const Eigen::VectorXd & | beta0, |
| const Eigen::SparseMatrix< double > & | beta, | ||
| const Eigen::VectorXd & | x_centers, | ||
| const Eigen::VectorXd & | x_scales, | ||
| const bool | intercept | ||
| ) |
Rescales the coefficients using the given parameters.
This function rescales the coefficients by dividing each coefficient by the corresponding scale factor and subtracting the product of the center and the coefficient from the intercept.
| beta0 | The intercept coefficient. |
| beta | The vector of coefficients. |
| x_centers | The vector of center values. |
| x_scales | The vector of scale factors. |
| intercept | Should an intercept be fit? |
beta, x_centers, and x_scales must have the same size. beta will be modified in-place.| double slope::rocAuc | ( | const Eigen::MatrixXd & | scores, |
| const Eigen::MatrixXd & | labels | ||
| ) |
Computes the Area Under the ROC Curve (AUC-ROC) for binary and multi-class classification.
| scores | Matrix of prediction scores/probabilities (samples x classes) |
| labels | Matrix of true labels in one-hot encoded format (samples x classes) |
For binary classification, this reduces to standard binary AUC-ROC. For multi-class, computes one-vs-rest AUC-ROC for each class and averages. Both input matrices must have the same dimensions.
| std::vector< int > slope::setDiff | ( | const std::vector< int > & | a, |
| const std::vector< int > & | b | ||
| ) |
Computes the set difference of two sorted integer vectors.
| a | First sorted vector of integers (set to subtract from) |
| b | Second sorted vector of integers (set to subtract) |
Returns A \ B = {x ∈ A | x ∉ B}
| std::vector< int > slope::setUnion | ( | const std::vector< int > & | a, |
| const std::vector< int > & | b | ||
| ) |
Computes the union of two sorted integer vectors.
| a | First sorted vector of integers |
| b | Second sorted vector of integers |
| std::unique_ptr< Loss > slope::setupLoss | ( | const std::string & | loss | ) |
Factory function to create the appropriate loss function based on the distribution family.
This function creates and returns an loss function object based on the specified statistical distribution family. The supported families are:
| loss | A string specifying the loss type ("logistic", "poisson", "multinomial", or "quadratic") |
| std::unique_ptr< SolverBase > slope::setupSolver | ( | const std::string & | solver_type, |
| const std::string & | loss, | ||
| JitNormalization | jit_normalization, | ||
| bool | intercept, | ||
| bool | update_clusters, | ||
| int | cd_iterations, | ||
| const std::string & | cd_type, | ||
| std::optional< int > | random_seed = std::nullopt |
||
| ) |
Factory function to create and configure a SLOPE solver.
Creates a solver object based on the specified type and parameters. The solver implements the Sorted L1 Penalized Estimation (SLOPE) algorithm with various configurations possible.
| solver_type | Type of solver to use (e.g., "pgd", "admm") |
| loss | Loss type |
| jit_normalization | Type of JIT normalization |
| intercept | Whether to fit an intercept term |
| update_clusters | Whether to update cluster assignments during optimization (Hybrid solver) |
| cd_iterations | Frequency of proximal gradient descent updates (Hybrid solver) |
| cd_type | Type of coordinate descent to use ("cyclical" or "permuted") |
| random_seed | Optional random seed for reproducibility |
| T slope::sigmoid | ( | const T & | x | ) |
| int slope::sign | ( | T | val | ) |
Returns the sign of a given value.
This function determines the sign of the input value by comparing it to zero. It returns -1 if the value is negative, 0 if the value is zero, and 1 if the value is positive.
| T | The type of the input value. |
| val | The value for which the sign needs to be determined. |
| std::tuple< double, int > slope::slopeThreshold | ( | const double | x, |
| const int | j, | ||
| const Eigen::ArrayXd & | lambda_cumsum, | ||
| const Clusters & | clusters | ||
| ) |
Calculates slope thresholding for a given input
This function calculates the slope threshold for a given x and j, using the provided lambdas and clusters. This is used in the coordinate descent update step.
| x | The value of x. |
| j | The value of j. |
| lambda_cumsum | Cumulative sum of the lambda sequence. |
| clusters | The clusters object. |
| Eigen::MatrixXd slope::softmax | ( | const Eigen::MatrixXd & | x | ) |
Softmax
Computes the softmax function for the given input matrix.
| x | A matrix |
| void slope::sort | ( | T & | v, |
| const bool | descending = false |
||
| ) |
Sorts the elements in a container in ascending or descending order.
This function sorts the elements in the container v in either ascending or descending order, depending on the value of the descending parameter.
| T | The type of the container. |
| v | The container to be sorted. |
| descending | Flag indicating whether to sort in descending order (default is ascending order). |
< and > operators.| std::vector< int > slope::sortIndex | ( | T & | v, |
| const bool | descending = false |
||
| ) |
Sorts the elements of a vector and returns the indices of the sorted elements.
This function sorts the elements of a vector in ascending or descending order and returns the indices of the sorted elements. The sorting is done using the std::sort function from the C++ standard library.
| T | The type of the vector elements. |
| v | The vector to be sorted. |
| descending | Flag indicating whether to sort in descending order. Default is false. |
| Eigen::VectorXd slope::stdDevs | ( | const Eigen::MatrixBase< T > & | x | ) |
Computes the standard deviation for each column of a matrix.
| x | Input matrix whose column standard deviations are to be computed |
For each column j in matrix x, computes the standard deviation:
\[ \sigma_j = \sqrt{\frac{1}{n}\sum_{i} (x_{ij} - \bar{x}_j)^2} \]
where n is the number of rows, x_{ij} represents the i-th element of the j-th column, and \(\bar{x}_j\) is the mean of column j.
| Eigen::VectorXd slope::stdDevs | ( | const Eigen::SparseMatrixBase< T > & | x | ) |
Computes the standard deviation for each column of a matrix.
| x | Input matrix whose column standard deviations are to be computed |
For each column j in matrix x, computes the standard deviation:
\[ \sigma_j = \sqrt{\frac{1}{n}\sum_{i} (x_{ij} - \bar{x}_j)^2} \]
where n is the number of rows, x_{ij} represents the i-th element of the j-th column, and \(\bar{x}_j\) is the mean of column j.
| std::vector< int > slope::strongSet | ( | const Eigen::VectorXd & | gradient_prev, |
| const Eigen::ArrayXd & | lambda, | ||
| const Eigen::ArrayXd & | lambda_prev | ||
| ) |
Determines the strong set using sequential strong rules.
| gradient_prev | Gradient from previous solution |
| lambda | Current lambda sequence |
| lambda_prev | Previous lambda sequence |
| Eigen::MatrixBase< T >::PlainObject slope::subset | ( | const Eigen::DenseBase< T > & | x, |
| const std::vector< int > & | indices | ||
| ) |
Extract a subset of rows from an Eigen matrix.
| x | The input matrix to extract rows from |
| indices | A vector of row indices to extract |
This function creates a new matrix containing only the rows specified in the indices vector, preserving their order. The number of columns remains the same.
| T slope::subset | ( | const Eigen::EigenBase< T > & | x, |
| const std::vector< int > & | indices | ||
| ) |
Extract a subset of rows from an Eigen matrix.
| x | The input matrix to extract rows from |
| indices | A vector of row indices to extract |
This function creates a new matrix containing only the rows specified in the indices vector, preserving their order. The number of columns remains the same.
| T slope::subset | ( | const Eigen::SparseMatrixBase< T > & | x, |
| const std::vector< int > & | indices | ||
| ) |
Extract a subset of rows from a sparse Eigen matrix.
| x | The input sparse matrix to extract rows from |
| indices | A vector of row indices to extract |
This function creates a new sparse matrix containing only the rows specified in the indices vector, preserving their order. The number of columns remains the same. The sparsity structure is maintained in the extracted rows.
| T slope::subsetCols | ( | const Eigen::MatrixBase< T > & | x, |
| const std::vector< int > & | indices | ||
| ) |
Extract specified columns from a dense matrix.
Creates a new matrix containing only the columns specified in the indices vector.
| MatrixType | The type of matrix (supports both Eigen::MatrixXd and Eigen::Map<>) |
| x | Input matrix |
| indices | Vector of column indices to extract (0-based) |
| T slope::subsetCols | ( | const Eigen::SparseMatrixBase< T > & | x, |
| const std::vector< int > & | indices | ||
| ) |
Extracts selected columns from a sparse matrix.
Creates a new sparse matrix containing only the columns specified by the indices vector. The resulting matrix preserves the sparsity structure and maintains the original row ordering.
| x | Input sparse matrix |
| indices | Vector of column indices to extract (0-based) |
|
inline |
Create a set of unique values from an Eigen matrix.
| x | The input matrix to extract unique values from |
This function iterates through all elements of the input matrix and collects all unique values into an unordered set. The order of elements in the returned set is not guaranteed.
| void slope::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 | ||
| ) |
Computes the gradient of the loss with respect to \(\beta\).
| T | The type of the input matrix. |
| gradient | The gradient vector. |
| x | The input matrix. |
| residual | The residual matrix. |
| active_set | The indices for the active set. |
| x_centers | The vector of center values for each column of x. |
| x_scales | The vector of scale values for each column of x. |
| w | Working weights |
| jit_normalization | Type of JIT normalization just-in-time. |
| void slope::validateOption | ( | const std::string & | value, |
| const std::set< std::string > & | valid_options, | ||
| const std::string & | parameter_name | ||
| ) |
Validates if a given value exists in a set of valid options.
Throws an informative error if the value is not found in the valid options, listing all valid possibilities in the error message.
| value | The value to validate |
| valid_options | Set of valid options |
| parameter_name | Name of the parameter being validated (used in error message). |
| std::invalid_argument | If value is not in valid_options |
| std::string slope::warningCodeToString | ( | WarningCode | code | ) |
Convert a warning code to its string representation.
| code | The warning code to convert |
| std::vector< int > slope::which | ( | const T & | x | ) |
Returns indices of true values in a boolean container.
| T | Container type supporting size() and operator[] (e.g., std::vector<bool>, std::array<bool>) |
| x | Input container with boolean-convertible values |
Example: std::vector<bool> v = {true, false, true, false, true}; auto indices = which(v); // returns {0, 2, 4}
| int slope::whichBest | ( | const T & | x, |
| const Comparator & | comp | ||
| ) |
Returns the index of the minimum element in a container.
| T | Container type that supports iterators and std::min_element |
| x | Container whose maximum element's index is to be found |
| comp | Comparator that returns true if the first argument is worse than the second argument |
Uses std::max_element to find the iterator to the maximum element, then converts to index position using std::distance. For containers with multiple maximum elements, returns the first occurrence.
| int slope::whichMax | ( | const T & | x | ) |
Returns the index of the maximum element in a container.
| T | Container type that supports iterators and std::max_element |
| x | Container whose maximum element's index is to be found |
Uses std::max_element to find the iterator to the maximum element, then converts to index position using std::distance. For containers with multiple maximum elements, returns the first occurrence.
| int slope::whichMin | ( | const T & | x | ) |
Returns the index of the minimum element in a container.
| T | Container type that supports iterators and std::min_element |
| x | Container whose maximum element's index is to be found |
Uses std::max_element to find the iterator to the maximum element, then converts to index position using std::distance. For containers with multiple maximum elements, returns the first occurrence.