R/RcppExports.R

# This file was generated by Rcpp::compileAttributes
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' @useDynLib apg
#' @importFrom Rcpp sourceCpp
NULL

#' Gradient of the ranking logistic regression risk.
#'
#' Computes the gradient of the ranking logistic regression error: \deqn{f(x) = 1/|comp|
#' sum_{(i,j)\in comp} ( log(1 + exp(- x' * (A_j - A_i) )} for a given design matrix
#' \code{A} and a set of pairs \eqn{(i,j)\in P} where the j-th sample is larger than the i-th sample.
#'
#' @param x A p-dimensional vector where the gradient is computed.
#' @param opts List of parameters, which must include: \itemize{ \item \code{A},
#'   a n*p design matrix \item \code{comp}, a list of length n, where the i-th entry is a vector containing the indices of the samples j which are larger than sample i.}
#'
#' @return The gradient of the function \eqn{f(x) = 1/|comp|
#' sum_{(i,j)\in comp} ( log(1 + exp(- x' * (A_j - A_i) )}, which is: \deqn{f'(x) = 1/|comp| sum_{(i,j)\in comp} (A_j - A_i) / (1 + exp( x' * ( A_i - A_j) )}
#'
#' @export
#' @examples grad.rankinglogistic(c(1,3,-2), list(A=diag(3), comp=list(as.integer(c(2,3)),as.integer(3),integer(length=0))))
grad.rankinglogistic <- function(x, opts) {
    .Call('apg_grad_ranking_logistic', PACKAGE = 'apg', x, opts)
}
jpvert/apg documentation built on May 19, 2019, 11:51 p.m.