R/kmunionclosure.kmdata.R

Defines functions kmunionclosure.kmdata

Documented in kmunionclosure.kmdata

#' @rdname kmunionclosure
#' @export
kmunionclosure.kmdata <- function(x) {
  if (any(x != 1*as.logical(x))) {
    stop(sprintf("%s must be a binary matrix.", dQuote("x")))
  }

  x <- kmbasis(kmfamset(x))

  noi <- as.integer(dim(x)[2])
  nob <- as.integer(dim(x)[1])
  storage.mode(x) <- "integer"
  nos <- as.integer(0)
  result <- .C("constr", noi, nob, t(x), nos, package="kstMatrix")
  nos <- result[[4]][1]
  space <- matrix(1:(noi*nos), ncol=noi, nrow=nos, byrow = TRUE)
  storage.mode(space) <- "integer"
  result2 <- .C("constr_results", space, package="kstMatrix")
  s <- result2[[1]]
  colnames(s) <- colnames(x)
  class(s) <- unique(c("kmspace", "kmstructure", "kmfamset", class(s)))
  s
}

Try the kstMatrix package in your browser

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

kstMatrix documentation built on Feb. 28, 2026, 5:06 p.m.