- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试基于包 QUIC
在 R 中使用 C 代码.不幸的是,我无法让我自己的本地版本的包工作。我从 CRAN 下载了包源考试。在 src
文件夹我找到了所需的 QUIC.cpp 代码( A github page contains it here for reference )和一个没有扩展名的 Makevars 文件,其中包含以下两行:
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
PKG_CXXFLAGS = -DLANG_R
R CMD SHLIB QUIC.cpp
在终端中(没有产生警告或错误),然后我用
dyn.load(QUIC.so)
加载到 R 中.当我尝试运行相应的
QUIC
时在 R 中使用我创建的函数
.so
文件我收到一条错误消息:
Error: BLAS/LAPACK routine 'DPOTRF' gave error code -4
dpotrf
call 执行 choleksy 分解,错误不是因为缺乏正定性或任何“理论”。 . .我不知道如何解决这个问题,也找不到任何有用的在线信息。
QUIC
中完成的包,我没有更改任何代码。当我执行
library(QUIC)
时,所需的功能完美运行并从那里使用它。我想最终更改他们的 C 代码,因为我认为
QUIC
方法可以扩展,但首先我需要得到
QUIC
以这种方式工作!
> Sys.info()
sysname
"Darwin"
release
"16.7.0"
version
"Darwin Kernel Version 16.7.0; root:xnu-3789.73.8~1/RELEASE_X86_64"
nodename
"MacBook-Pro.local"
machine
"x86_64"
> R.Version()
$platform
[1] "x86_64-apple-darwin15.6.0"
$arch
[1] "x86_64"
$os
[1] "darwin15.6.0"
$system
[1] "x86_64, darwin15.6.0"
$`svn rev`
[1] "74626"
$version.string
[1] "R version 3.5.0 (2018-04-23)"
$nickname
[1] "Joy in Playing"
n <- 15
rho <- 0.2
S <- diag(n)
# library(QUIC); QUIC(S,rho) works fine. Now copying the setup for QUIC and trying with .so file:
path = NULL; tol = 1e-04; msg = 1; maxIter = 1000; X.init = NULL; W.init = NULL
if (is.null(path)) {
npath <- 1
} else {npath <- length(path)}
if (!is.matrix(rho) && length(rho) != 1 && length(rho) !=
n) {
stop("Wrong number of elements in rho")
}
if (is.vector(rho)) {
rho <- matrix(sqrt(rho)) %*% sqrt(rho)
}
if (length(rho) == 1) {
rho <- matrix(rho, ncol = n, nrow = n)
}
if (is.null(path)) {
if (is.null(X.init)) {
X <- diag(n)
W <- diag(n)
} else {
X <- X.init
W <- W.init }
} else {
if (is.null(X.init)) {
X <- array(diag(n), c(n, n, npath))
W <- array(diag(n), c(n, n, npath))
} else {
X <- array(0, c(n, n, npath))
W <- array(0, c(n, n, npath))
X[, , 1] <- X.init
W[, , 1] <- W.init
}
}
opt <- matrix(0, ncol = npath, nrow = 1)
cputime <- matrix(0, ncol = npath, nrow = 1)
iter <- matrix(0, ncol = npath, nrow = 1)
dGap <- matrix(0, ncol = npath, nrow = 1)
if (is.null(path)) {
job <- "d"
} else {job <- "p"}
storage.mode(job) <- "character"
storage.mode(S) <- "double"
storage.mode(rho) <- "double"
storage.mode(npath) <- "integer"
storage.mode(path) <- "double"
storage.mode(tol) <- "double"
storage.mode(msg) <- "integer"
storage.mode(maxIter) <- "integer"
storage.mode(X) <- "double"
storage.mode(W) <- "double"
storage.mode(opt) <- "double"
storage.mode(cputime) <- "double"
storage.mode(iter) <- "integer"
storage.mode(dGap) <- "double"
dyn.load(".../QUIC.so")
tmp <- .C("QUICR", job, n, S, rho, npath, path, tol, msg,
maxIter, X = X, W = W, opt = opt, cputime = cputime,
iter = iter, dGap = dGap)
#Error: BLAS/LAPACK routine 'DPOTRF' gave error code -4
最佳答案
问题是,在原来的QUIC.r
函数,行:
n <- nrow(S)
n
storage.mode
的
integer
.但是,在您的代码中,您分配:
n <- 15
n
storage.mode
的
double
.
storage.mode(n) <- "integer"
关于c - 在预先存在的 R 包中模仿 C 的用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51850295/
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 6年前关闭。 Improve this qu
我有实体: @Entity @Table(name = "CARDS") public class Card { @ManyToOne @JoinColumn(name = "PERSON_I
我正在尝试计算二维多边形的表面法线。我正在使用 OpenGL wiki 中的 Newell 方法来计算表面法线。 https://www.opengl.org/wiki/Calculating_a_S
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 关闭 7 年前。 Improve
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 9 年前。 Improve this
我这里有以下 XML: Visa, Mastercard, , , , 0, Discover, American Express siteonly, Buyer Pay
即将发生的 Google 政策变更迫使我们实现一个对话框,以通知欧盟用户有关 Cookie/设备标识符用于广告和分析的情况。我只想向欧盟用户显示此对话框。我不想使用额外的权限(例如 android.p
本文分享自华为云社区《华为大咖说 | 企业应用AI大模型的“道、法、术” ——道:认知篇》,作者:华为云PaaS服务小智。 本期核心观点 上车:AGI是未来5~10年内,每个人都无法回避的技
我有一个与酒精相关的网站,需要先验证年龄,然后才能让他们进入该网站。我使用 HttpModule 来执行此操作,该模块检查 cookie,如果未设置,我会将它们重定向到验证页面。我验证他们的年龄并存储
在欧盟,我们有一项法律,要求网页请求存储 cookie 的许可。我们大多数人都了解 cookie 并同意它们,但仍然被迫在任何地方明确接受它们。所以我计划编写这个附加组件(ff & chrome),它
以下在 C 和/或 C++ 中是否合法? void fn(); inline void fn() { /*Do something here*/ } 让我担心的是,第一个声明看起来暗示函数将被定义
我是一名优秀的程序员,十分优秀!