R/common.R

Defines functions initExpec initW control.hann

Documented in control.hann

## common.R (2024-10-31)

##   Common Code

## Copyright 2024 Emmanuel Paradis

## This file is part of the R-package `hann'.
## See the file ../DESCRIPTION for licensing issues.

.hann.ctrl <-
    list(iterlim = 100L, quiet = FALSE, quasinewton = FALSE,
         fullhessian = FALSE, trace.error = FALSE, wolfe = FALSE,
         target = 0.001, beta = 0.2, mc.cores = 1L)


control.hann <- function(...)
{
    dots <- list(...)
    x <- .hann.ctrl
    if (length(dots)) {
        chk.nms <- names(dots) %in% names(x)
        if (any(!chk.nms)) {
            warning("some control parameter names do not match: they were ignored")
            dots <- dots[chk.nms]
        }
        x[names(dots)] <- dots
    }
    x
}

initW <- function(NROW, NCOL, lower = -1, upper = 1)
{
    W <- runif(NROW * NCOL, lower, upper)
    dim(W) <- c(NROW, NCOL)
    W
}

initExpec <- function(cls, K)
{
    cls <- factor(cls)
    C <- nlevels(cls)
    expec <- matrix(-1L, K, C)
    expec[cbind(1:K, as.integer(cls))] <- 1L
    expec
}

Try the hann package in your browser

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

hann documentation built on Aug. 8, 2025, 7:16 p.m.