view R/rdyncall/R/utils_float.R @ 0:0cfcc391201f

initial from svn dyncall-1745
author Daniel Adler
date Thu, 19 Mar 2015 22:26:28 +0100
parents
children
line wrap: on
line source

# Package: rdyncall
# File: R/utils_float.R
# Description: Support for C float vectors in R

as.floatraw <- function(x) 
{
  x <- .Call("r_as_floatraw", as.numeric(x), PACKAGE="rdyncall")
  class(x) <- "floatraw"
  x
}

floatraw2numeric <- function(x) 
{
  stopifnot(is.raw(x))
  stopifnot(class(x) == "floatraw")
  stopifnot(length(x) >= 4)
  .Call("r_floatraw2numeric", x, PACKAGE="rdyncall")
}

floatraw <- function(n)
{
  x <- raw(n*4)
  class(x) <- "floatraw"
  x
}