0
|
1 # Package: rdyncall
|
|
2 # File: R/utils_float.R
|
|
3 # Description: Support for C float vectors in R
|
|
4
|
|
5 as.floatraw <- function(x)
|
|
6 {
|
|
7 x <- .Call("r_as_floatraw", as.numeric(x), PACKAGE="rdyncall")
|
|
8 class(x) <- "floatraw"
|
|
9 x
|
|
10 }
|
|
11
|
|
12 floatraw2numeric <- function(x)
|
|
13 {
|
|
14 stopifnot(is.raw(x))
|
|
15 stopifnot(class(x) == "floatraw")
|
|
16 stopifnot(length(x) >= 4)
|
|
17 .Call("r_floatraw2numeric", x, PACKAGE="rdyncall")
|
|
18 }
|
|
19
|
|
20 floatraw <- function(n)
|
|
21 {
|
|
22 x <- raw(n*4)
|
|
23 class(x) <- "floatraw"
|
|
24 x
|
|
25 }
|