R/wrappers_sparse.r

Defines functions csc_to_coo co_sparse

#' @useDynLib coop R_co_sparse
co_sparse <- function(n, a, i, j, index, type, use, inverse)
{
  check.is.flag(inverse)
  
  if (!is.double(a))
    storage.mode(a) <- "double"
  if (!is.integer(i))
    storage.mode(i) <- "integer"
  if (!is.integer(j))
    storage.mode(j) <- "integer"
  
  use <- check_use(use)
  if (use == "everything")
  {}
  else if (use == "all.obs")
  {
    if (anyNA(a))
      stop("missing observations in covar/pcor/cosine")
  }
  ### TODO
  # else if (use == "complete.obs")
  # {
  #   if (anyNA(x))
  #   {
  #     out <- naomit_coo(a, i, j)
  #     a <- out[[1]]
  #     i <- out[[2]]
  #     j <- out[[3]]
  #   }
  # }
  else
    stop("unsupported 'use' method")
  
  .Call(R_co_sparse, as.integer(n), a, i, j, as.integer(index), as.integer(type), as.integer(inverse))
}



#' @useDynLib coop R_csc_to_coo
csc_to_coo <- function(row_ind, col_ptr)
{
  .Call(R_csc_to_coo, row_ind, col_ptr)
}
wrathematics/coop documentation built on Nov. 26, 2021, 8:59 a.m.