R/add.column.R

Defines functions add.column

Documented in add.column

add.column <- function(lprec, x, indices) {
  if (missing(indices)) {
    if (length(x) != dim(lprec)[1]) {
      stop(
        "the length of ",
        sQuote("x"),
        " is not equal to the number of ",
        "constraints in the model"
      )
    }

    epsel <- .Call(RlpSolve_get_epsel, lprec)
    indices <- which(abs(x) > epsel)
    x <- x[indices]
  }

  if (length(x) != length(indices)) {
    stop(sQuote("x"), " and ", sQuote("indices"), " are not the same length")
  }

  .Call(RlpSolve_add_columnex, lprec, as.double(x), as.integer(indices))

  invisible()
}

Try the lpSolveAPI package in your browser

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

lpSolveAPI documentation built on Feb. 13, 2026, 5:10 p.m.