R/funFiltration.R

Defines functions funFiltration

Documented in funFiltration

funFiltration <- function(FUNvalues, cmplx, sublevel = TRUE) {

  if (!is.numeric(FUNvalues)) {
    stop("FUNvalues should be a vector")
  }

  if (!is.list(cmplx)) {
    stop("cmplx should be a numeric list")
  }
  if (any(unlist(cmplx) <= 0)) {
    stop("each vertex of cmplx should be a positive integer")
  }

  if (!is.logical(sublevel)) {
    stop("sublevel should be logical")
  }

  if (sublevel == FALSE) {
    FUNvalues <- -FUNvalues
  }

  funOut <-
      FunFiltration(FUNvalues = FUNvalues, cmplx = cmplx)

  if (sublevel == TRUE) {
    out <- list(
        "cmplx" = funOut[[1]], "values" = funOut[[2]], "increasing" = sublevel)
  } else {
    out <- list(
        "cmplx" = funOut[[1]], "values" = -funOut[[2]], "increasing" = sublevel)
  }

  return (out)
}

Try the TDA package in your browser

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

TDA documentation built on May 29, 2024, 1:28 a.m.