Skip to content
Snippets Groups Projects
Commit c184c8a9 authored by Florian Gerber's avatar Florian Gerber
Browse files

.

parent de6bdb03
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#' \enumerate{ #' \enumerate{
#' \item supports long vectors, i.e., vectors with more than \code{2^31-1} elements #' \item supports long vectors, i.e., vectors with more than \code{2^31-1} elements
#' \item does the necessary castings to expose the R representation of "64-bit integers" (numeric vectors) #' \item does the necessary castings to expose the R representation of "64-bit integers" (numeric vectors)
#' to 64-bit integers arguments of the compiled function. The latter are int64_t in C code and integer (kind = 8) in Fortran code #' to 64-bit integer arguments of the compiled function. The latter are int64_t in C code and integer (kind = 8) in Fortran code
#' \item provides a mechanism the control duplication of the R objects exposed to the compiled code #' \item provides a mechanism the control duplication of the R objects exposed to the compiled code
#' \item checks if the provided R objects are of the expected types and coerces them if necessary #' \item checks if the provided R objects are of the expected types and coerces them if necessary
#' } #' }
...@@ -13,11 +13,11 @@ ...@@ -13,11 +13,11 @@
#' \code{SIGNATURE} specifies the types of the arguments of the compiled function. #' \code{SIGNATURE} specifies the types of the arguments of the compiled function.
#' \code{INTENT} indicates whether the compiled function "reads", "writes", #' \code{INTENT} indicates whether the compiled function "reads", "writes",
#' or "read and writes" to the R objects passed to the compiled function. #' or "read and writes" to the R objects passed to the compiled function.
#' This is then used to duplicate R objects if and only if necessary. #' This information is then used to duplicate R objects if and only if necessary.
#' #'
#' @param .NAME character vector of length 1. Name of the compiled function to be called. #' @param .NAME character vector of length 1. Name of the compiled function to be called.
#' @param SIGNATURE character vector of the same length as the number of arguments of the compiled function. #' @param SIGNATURE character vector of the same length as the number of arguments of the compiled function.
#' Accepted strings are \code{"double"}, \code{"integer"}, \code{"int64"}. #' Accepted strings are \code{"double"}, \code{"integer"}, and \code{"int64"}.
#' They describe the signature of each argument of the compiled function. #' They describe the signature of each argument of the compiled function.
#' @param ... arguments passed to the compiled function. One R object for each argument. Up to 65 arguments are supported. #' @param ... arguments passed to the compiled function. One R object for each argument. Up to 65 arguments are supported.
#' @param INTENT character vector of the same length as the number of arguments of the compiled function. #' @param INTENT character vector of the same length as the number of arguments of the compiled function.
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
#' ## output[0] = input[index[0] - 1]; #' ## output[0] = input[index[0] - 1];
#' ## } #' ## }
#' ## #' ##
#' ## We can use .C64() to call it from R: #' ## We can use .C64() to call get_c() from R:
#' .C64("get_c", SIGNATURE = c("double", "integer", "double"), #' .C64("get_c", SIGNATURE = c("double", "integer", "double"),
#' input = 1:10, index = 9, output = double(1))$output #' input = 1:10, index = 9, output = double(1))$output
#' #'
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
#' ## output[0] = input[index[0] - 1]; #' ## output[0] = input[index[0] - 1];
#' ## } #' ## }
#' #'
#' ## Now, we can use .C64() to call the function from R. #' ## Now, we can use .C64() to call get64_c() from R.
#' .C64("get64_c", SIGNATURE = c("double", "int64", "double"), #' .C64("get64_c", SIGNATURE = c("double", "int64", "double"),
#' input = x_long, index = 2^31, output = double(1))$output #' input = x_long, index = 2^31, output = double(1))$output
#' ## Note that 2^31 is of type double and .C64() casts it into an #' ## Note that 2^31 is of type double and .C64() casts it into an
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
\item{.NAME}{character vector of length 1. Name of the compiled function to be called.} \item{.NAME}{character vector of length 1. Name of the compiled function to be called.}
\item{SIGNATURE}{character vector of the same length as the number of arguments of the compiled function. \item{SIGNATURE}{character vector of the same length as the number of arguments of the compiled function.
Accepted strings are \code{"double"}, \code{"integer"}, \code{"int64"}. Accepted strings are \code{"double"}, \code{"integer"}, and \code{"int64"}.
They describe the signature of each argument of the compiled function.} They describe the signature of each argument of the compiled function.}
\item{...}{arguments passed to the compiled function. One R object for each argument. Up to 65 arguments are supported.} \item{...}{arguments passed to the compiled function. One R object for each argument. Up to 65 arguments are supported.}
...@@ -57,7 +57,7 @@ The objects of the list reflect the changes made by the compiled C or Fortran fu ...@@ -57,7 +57,7 @@ The objects of the list reflect the changes made by the compiled C or Fortran fu
\enumerate{ \enumerate{
\item supports long vectors, i.e., vectors with more than \code{2^31-1} elements \item supports long vectors, i.e., vectors with more than \code{2^31-1} elements
\item does the necessary castings to expose the R representation of "64-bit integers" (numeric vectors) \item does the necessary castings to expose the R representation of "64-bit integers" (numeric vectors)
to 64-bit integers arguments of the compiled function. The latter are int64_t in C code and integer (kind = 8) in Fortran code to 64-bit integer arguments of the compiled function. The latter are int64_t in C code and integer (kind = 8) in Fortran code
\item provides a mechanism the control duplication of the R objects exposed to the compiled code \item provides a mechanism the control duplication of the R objects exposed to the compiled code
\item checks if the provided R objects are of the expected types and coerces them if necessary \item checks if the provided R objects are of the expected types and coerces them if necessary
} }
...@@ -65,7 +65,7 @@ Compared to \code{\link{.C}}, \code{.C64} has the additional arguments \code{SIG ...@@ -65,7 +65,7 @@ Compared to \code{\link{.C}}, \code{.C64} has the additional arguments \code{SIG
\code{SIGNATURE} specifies the types of the arguments of the compiled function. \code{SIGNATURE} specifies the types of the arguments of the compiled function.
\code{INTENT} indicates whether the compiled function "reads", "writes", \code{INTENT} indicates whether the compiled function "reads", "writes",
or "read and writes" to the R objects passed to the compiled function. or "read and writes" to the R objects passed to the compiled function.
This is then used to duplicate R objects if and only if necessary. This information is then used to duplicate R objects if and only if necessary.
} }
\examples{ \examples{
## Consider the following C function, which is included ## Consider the following C function, which is included
...@@ -74,7 +74,7 @@ This is then used to duplicate R objects if and only if necessary. ...@@ -74,7 +74,7 @@ This is then used to duplicate R objects if and only if necessary.
## output[0] = input[index[0] - 1]; ## output[0] = input[index[0] - 1];
## } ## }
## ##
## We can use .C64() to call it from R: ## We can use .C64() to call get_c() from R:
.C64("get_c", SIGNATURE = c("double", "integer", "double"), .C64("get_c", SIGNATURE = c("double", "integer", "double"),
input = 1:10, index = 9, output = double(1))$output input = 1:10, index = 9, output = double(1))$output
...@@ -94,7 +94,7 @@ x_long[9] <- 9; x_long[2^31] <- -1 ...@@ -94,7 +94,7 @@ x_long[9] <- 9; x_long[2^31] <- -1
## output[0] = input[index[0] - 1]; ## output[0] = input[index[0] - 1];
## } ## }
## Now, we can use .C64() to call the function from R. ## Now, we can use .C64() to call get64_c() from R.
.C64("get64_c", SIGNATURE = c("double", "int64", "double"), .C64("get64_c", SIGNATURE = c("double", "int64", "double"),
input = x_long, index = 2^31, output = double(1))$output input = x_long, index = 2^31, output = double(1))$output
## Note that 2^31 is of type double and .C64() casts it into an ## Note that 2^31 is of type double and .C64() casts it into an
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment