R/mat2triplet.R

Defines functions mat2triplet

Documented in mat2triplet

#'Auxiliary function needed by reconcile_thiefnonneg
#'@param x \code{matrix}
#'@param uniqT \code{logical}
#'@export
mat2triplet <- function(x, uniqT = FALSE) {
  T <- as(x, "TsparseMatrix")
  if(uniqT && anyDuplicatedT(T)) T <- .uniqTsparse(T)
  if(is(T, "nsparseMatrix"))
    list(i = T@i + 1L, j = T@j + 1L)
  else list(i = T@i + 1L, j = T@j + 1L, x = T@x)
}
nicholasjclark/mvforecast documentation built on Dec. 22, 2021, 2:11 a.m.