R/as.matrix.r

Defines functions as.matrix.fmlmat

Documented in as.matrix.fmlmat

#' as.matrix
#' 
#' Convert an 'fmlmat' object to an R object.
#' 
#' @details
#' The conversion does not produce a copy of the data. It is merely a shallow
#' S4 wrapper around the fmlr object.
#' @param ...
#' Ignored.
#' 
#' @param x
#' An object of class 'fmlmat'.
#' 
#' @export
as.matrix.fmlmat = function(x, ...)
{
  x = DATA(x)
  
  if (is_cpumat(x) || is_cpuvec(x))
    x$to_robj()
  else if (is_gpumat(x) || is_gpuvec(x))
  {
    if (is_gpumat(x))
      ret = cpumat()
    else
      ret = cpuvec()
    
    gpu2cpu(x, ret)
    ret$to_robj()
  }
  else if (is_mpimat(x))
  {
    ret = cpumat()
    mpi2cpu(x, ret)
    ret$to_robj()
  }
}
fml-fam/craze documentation built on June 6, 2020, 2:05 p.m.