utilities: printing, reading and writing CFunc objects

Description Usage Arguments Details Value Methods Note Author(s) See Also Examples

Description

writeDynLib saves the DLL and the CFunc or CFuncList object as generated by cfunction; readDynLib loads it.

The print and code methods respectively print the entire object or the code parts.

Usage

1
2

Arguments

x

A CFunc or CFuncList object as created by cfunction to be saved.

file

base name of the file to write the object to or to read from. Two files will be saved, one for the shared object or DLL (extension so or DLL) and one that holds the CFunc or CFuncList specification, without the function address (extension CFunc).

Details

Both the CFunc or CFuncList object and the shared object or DLL are saved, in two files; the first has extension CFunc; the second so or DLL, depending on the operating system used.

When reading, both files are loaded, and the compiled function address added to the object.

Value

Function readDynLib returns a CFunc or CFuncList object.

Methods

Note

Author(s)

Karline Soetaert

See Also

getDynLib

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
x <- as.numeric(1:10)
n <- as.integer(10)

code <- "
      integer i
      do 1 i=1, n(1)
    1 x(i) = x(i)**3
"
cubefn <- cfunction(signature(n="integer", x="numeric"), code, convention=".Fortran")
code(cubefn)

cubefn(n, x)$x

## Not run: 
 fname <- tempfile()
 writeDynLib(cubefn, file = fname)
 # load and assign different name to object
 cfn <- readDynLib(fname)
 print(cfn)
 cfn(2, 1:2)

## End(Not run)

inline documentation built on May 29, 2017, 5:57 p.m.

Search within the inline package
Search all R packages, documentation and source code