This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
julia_function <- function(func_name, pkg_name = "Main", | |
env = emptyenv()){ | |
fname <- paste0(pkg_name, ".", func_name) | |
force(fname) | |
f <- function(..., | |
need_return = c("R", "Julia", "None"), | |
show_value = FALSE){ | |
if (!isTRUE(env$initialized)) { | |
env$setup() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(autodiffr) | |
ad_setup() # to ensure it is established | |
ores <- function(x){ | |
x # Function will be the parameters. ofn is sum of squares | |
} | |
ores <- ad.variant(ores) | |
ofn <- function(x){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dll_file <- system("/home/rolf/Desktop/Julia/julia-d386e40c17/bin/julia -e \'print(Libdl.dlpath(\"libjulia\"))\'", intern = TRUE) | |
JuliaCall:::juliacall_initialize(dll_file) | |
JuliaCall:::juliacall_cmd('print("1\n")') | |
JuliaCall:::juliacall_cmd("using RCall") | |
JuliaCall:::juliacall_cmd(" | |
function transfer_list(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dll_file <- system("julia -e \'print(Libdl.dlpath(\"libjulia\"))\'", intern = TRUE) | |
JuliaCall:::juliacall_initialize(dll_file) | |
JuliaCall:::juliacall_cmd('print("1\n")') | |
JuliaCall:::juliacall_cmd("using RCall") | |
JuliaCall:::juliacall_cmd(" | |
function transfer_list(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dll_file <- system("julia -e \'print(Libdl.dlpath(\"libjulia\"))\'", intern = TRUE) | |
JuliaCall:::juliacall_initialize(dll_file) | |
JuliaCall:::juliacall_cmd('print("1\n")') | |
JuliaCall:::juliacall_cmd("using RCall") | |
JuliaCall:::juliacall_cmd(" | |
function transfer_list(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dll_file <- system("julia -e \'print(Libdl.dlpath(\"libjulia\"))\'", intern = TRUE) | |
JuliaCall:::juliacall_initialize(dll_file) | |
JuliaCall:::juliacall_cmd('print("1\n")') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(JuliaCall) | |
julia_setup() | |
julia_library("ForwardDiff") | |
f <- function(x) sum(x^2L) | |
julia_assign("ff", f) | |
julia_command("g = x -> ForwardDiff.gradient(ff, x);") | |
julia_command("g([2.0])") | |
## 1-element Array{Float64,1}: | |
## 4.0 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fRunge = function(x) 1 / (1 + (5*x)^2) | |
library(JuliaCall) | |
julia_setup() | |
julia_install_package_if_needed("Remez") | |
julia_library("Remez") | |
## the following works for me with the latest version of JuliaCall | |
julia_call('R"fRunge"', 0) | |
## and this should also work |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.julia <- new.env(parent = emptyenv()) | |
julia <- new.env(parent = .julia) | |
.julia$bin_dir <- | |
system("julia -E 'println(JULIA_HOME)'", intern = TRUE)[1] | |
.julia$dll_file <- | |
system("julia -E 'println(Libdl.dllist()[1])'", intern = TRUE)[1] | |
.julia$dll <- dyn.load(.julia$dll_file, FALSE, TRUE) | |
.julia$include_dir <- |