英文:
Error with 'XRJulia' when passing a large matrix
问题
似乎 R 软件包 JuliaConnectoR 和 JuliaCall 在最新的 Julia (v1.9.1) 中遇到了一些问题。
好的,这不是我的问题。然后我尝试使用 XRJulia 软件包。
当我尝试对一个3x3矩阵求逆时,它运行正常:
library(XRJulia)
A <- toeplitz(3:1)
B <- juliaEval("inv(%s)", A)
juliaGet(B)
# [,1] [,2] [,3]
# [1,] 0.625 -0.5 0.125
# [2,] -0.5 1 -0.5
# [3,] 0.125 -0.5 0.625
但是当我尝试对一个1000x1000矩阵求逆时,我得到错误 '\U' used without hex digits in character string:
set.seed(9392927)
N <- 1e3L
A <- matrix(rpois(N^2L, lambda = 10), N)
B <- juliaEval("inv(%s)", A)
# Error: '\U' used without hex digits in character string (<text>:1:24)
你知道是为什么以及如何解决吗?
英文:
It seems that the R packages JuliaConnectoR and JuliaCall have some problems with the latest Julia (v1.9.1).
Well, this is not my question. I try then to use the XRJulia package.
When I try to inverse a 3x3 matrix, it works fine:
library(XRJulia)
A <- toeplitz(3:1)
B <- juliaEval("inv(%s)", A)
juliaGet(B)
# [,1] [,2] [,3]
# [1,] 0.625 -0.5 0.125
# [2,] -0.5 1 -0.5
# [3,] 0.125 -0.5 0.625
But when I try to inverse a 1000x1000 matrix, I get the error '\U' used without hex digits in character string:
set.seed(9392927)
N <- 1e3L
A <- matrix(rpois(N^2L, lambda = 10), N)
B <- juliaEval("inv(%s)", A)
# Error: '\U' used without hex digits in character string (<text>:1:24)
Would you know why and how to do?
答案1
得分: 1
我认为 JuliaConnectoR 在 Julia 1.9.1 中没有问题,因为以下代码在 R 4.3.1 和 Julia 1.9.1 上都可以正常工作,没有问题:
library(JuliaConnectoR)
juliaSetupOk()
## [1] TRUE
set.seed(9392927); N <- 1e3L
A <- matrix(rpois(N^2L, lambda = 10), N)
system.time(Ainv <- juliaCall("inv", A))
## user system elapsed
## 1.693 4.097 6.150
只是值得一提的是,在纯粹的 Julia 中,对一个 1000x1000 的整数矩阵进行求逆大约需要 0.05-0.10 秒(在我的计算机上),所以大部分运行时间都是集成两个系统的开销。
英文:
I don't think JuliaConnectoR has problems with Julia 1.9.1 as
the following lines work with R 4.3.1 and Julia 1.9.1 w/o problems:
library(JuliaConnectoR)
juliaSetupOk()
## [1] TRUE
set.seed(9392927); N <- 1e3L
A <- matrix(rpois(N^2L, lambda = 10), N)
system.time(Ainv <- juliaCall("inv", A))
## user system elapsed
## 1.693 4.097 6.150
Just to mention: in pure Julia, inverting a 1000x1000-matrix of integers takes about 0.05-0.10 seconds (on my computer), so most of the runtime is overhead of integrating the two systems.
答案2
得分: 0
我找到了,需要设置一个选项:
juliaOptions(largeObject = 10000000L)
但矩阵求逆非常慢。
英文:
I've found, one has to set an option:
juliaOptions(largeObject = 10000000L)
But the matrix inversion is incredibly slow.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论