calljulia: Function that executes julia code

Description Usage Arguments Details Value See Also Examples

Description

calljulia lets you run julia code from R.

Usage

1
2
calljulia(julia.code, inputs = list(), output.names = NULL,
  delete.temp = TRUE, norun = FALSE, julia.call = "julia")

Arguments

julia.code

a string of julia code to be run. The names of variables used in this string should match those in the inputs argument.

inputs

List containing all variables that need to be passed to julia. The names of the elements of the list should match the names used in julia.code. All variables must be numeric (e.g. matrices, vectors, scalars)

output.names

Array of names of all variables that should be returned from julia. The names should match those used in julia.code. All variables must be numeric (no strings).

delete.temp

Default TRUE. Indicates whether the temporary files that are created should be deleted.

norun

Default FALSE. Mostly for debugging purposes. Returns the command that would be run in julia without it actually opening julia.

julia.call

How julia can be invoked through the system command. Default: "julia". In OS X this might be something like "/Applications/Julia-0.5.app/Contents/Resources/julia/bin/julia". However, this argument does not need to be provided if ~/.profile (for OSX) has the line export PATH=/Applications/Julia-0.5.app/Contents/Resources/julia/bin:$PATH where "0.5" would be replaced with whatever version of Julia you have.

Details

This function writes the inputs to temporary files (which are deleted unless delete.temp is set to FALSE). Next, a file of julia code is produced (named doit.jl and saved in the working directory). Next, this julia code is run by invoking julia from the command line. Finally, the outputs are saved to file and read back into R.

Value

Returns the following:

outputs

List containing all variables that were listed in output.names with the values they have after julia.code was executed in Julia

command

the string that is run on the command line.

See Also

callconvex callconvex.varyparams

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
set.seed(1)
x  <- matrix(rnorm(1000), 20, 50)
# change this next line based on where julia is located:
julia <- "/Applications/Julia-0.3.3.app/Contents/Resources/julia/bin/julia"
jl <- calljulia("y = x + a; z = y - 2", inputs=list(x = x, a = 10),
   output.names=c("y", "z"), julia.call = julia)
range(jl$y - x)

## End(Not run)

jacobbien/convexjulia documentation built on May 18, 2019, 8:01 a.m.