R/compute_g.R

Defines functions compute_g

Documented in compute_g

#compute composite loss function cfun(z), where z is the value computed from convex function dfun
compute_g <- function(z, cfun, s, delta=0.0001){
    if(is.null(s)) s <- assign_s(cfun, z) else check_s(cfun, dfun=1, s) #for now forget about dfun
    if(cfun==6)
           if(s > 1) delta <- (s-1)/2 else
           if(s==1) delta <- 0 else{
             if(is.null(delta)) stop("delta must be provided")
             if(delta <= 0) stop("delta must be positive")
           }
    n <- length(z)
    .Fortran("compute_g",
             cfun=as.integer(cfun),
             n=as.integer(n),
             z=as.double(z),
             s=as.double(s),
             delta=as.double(delta),
             gval=as.double(rep(0, n)),
             PACKAGE="mpath")$gval
}

Try the mpath package in your browser

Any scripts or data that you put into this service are public.

mpath documentation built on June 28, 2024, 1:06 a.m.