- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试通过 RcppArmadillo 使用来自 Armadillo ( http://arma.sourceforge.net/docs.html#spsolve )的 SparseLU 求解器:
#define ARMA_USE_SUPERLU
// [Rcpp::depends(RcppArmadillo)]
#include <RcppArmadillo.h>
// [[Rcpp::export]]
arma::vec sp_solver(arma::sp_mat K, arma::vec x) {
arma::superlu_opts opts;
opts.symmetric = true;
arma::vec res;
arma::spsolve(res, K, x, "superlu", opts);
return res;
}
/*** R
library(Matrix)
K <- sparseMatrix(i = c(1, 2, 1), j = c(1, 2, 2), x = c(1, 1, 0.5), symmetric = TRUE)
x <- runif(2)
sp_solver(K, x)
*/
undefined reference to 'superlu_free'
.
最佳答案
RcppArmadillo 非常方便,我自己一直在使用它。因为所有 Rcpp* 代码都将从 R 调用,所以我们可以假设存在一些功能。
这包括 LAPACK 和 BLAS,并解释了为什么即使 Armadillo 文档明确指出您需要 LAPACK 和 BLAS,我们也可以“不链接”地使用 RcppArmadillo。为什么?好吧,因为 R 已经有了 LAPACK 和 BLAS。
(顺便说一句,当且仅当 R 是用它自己的 LAPACK 子集构建的,因为某些复杂的值例程不可用时,这会导致相当多的早期问题。Baptiste 受到了很大的打击,因为他的包需要(编辑)这些。多年来,Brian Ripley 在将那些缺失的例程添加到 R 的 LAPACK 中最有帮助。当 R 使用外部 LAPACK 和 BLAS 构建时,从来没有出现过问题,这在我维护的 Debian/Ubuntu 包中很常见。)
在这里你想要 SuperLU。这是可选的,您的工作是确保将其链接起来。简而言之,它不仅仅是神奇地工作。并且很难自动化,因为它涉及链接,这使我们无法轻松控制平台相关性和安装要求。
但是这个问题并不新鲜,实际上还有an entire Rcpp Gallery post关于这个话题。
编辑:使用适合我系统的那篇文章的单行代码,您的代码也可以正常工作(一旦我更正了 Rcpp::depends
以获得它需要的双括号:
R> Sys.setenv("PKG_LIBS"="-lsuperlu")
R> sourceCpp("answer.cpp")
R> library(Matrix)
R> K <- sparseMatrix(i = c(1, 2, 1), j = c(1, 2, 2), x = c(1, 1, 0.5), symmetric = TRUE)
R> x <- runif(2)
R> sp_solver(K, x)
[,1]
[1,] 0.264929
[2,] 0.546050
R>
#define ARMA_USE_SUPERLU
// [[Rcpp::depends(RcppArmadillo)]]
#include <RcppArmadillo.h>
// [[Rcpp::export]]
arma::vec sp_solver(arma::sp_mat K, arma::vec x) {
arma::superlu_opts opts;
opts.symmetric = true;
arma::vec res;
arma::spsolve(res, K, x, "superlu", opts);
return res;
}
/*** R
library(Matrix)
K <- sparseMatrix(i = c(1, 2, 1), j = c(1, 2, 2), x = c(1, 1, 0.5), symmetric = TRUE)
x <- runif(2)
sp_solver(K, x)
*/
关于r - 在 RcppArmadillo 中使用 SuperLU 稀疏求解器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60911356/
对于一个项目,我需要使用 armadillo 提供的稀疏求解器,它似乎是 SuperLU 的包装器,我目前遇到一个问题。 您可能还会说我无法访问我计算机上的根目录。 这是一个最小的例子: #inclu
我正在创建一个 FEA 程序,我正在处理 290-96 千平方或 27-90 亿个元素的矩阵。这些矩阵在很大程度上是稀疏的,所以我使用 SuperLU 来解决它们。我已经能够成功地使用 SuperLU
在将第 3 方 C++ 库编译并添加到 XCode 时,我是个新手……这就是问题所在。我有依赖于 3 个库的 .cpp 文件。 OpenCV-本征-SuperLU。到目前为止,我认为我设法正确添加了
我正在尝试通过 RcppArmadillo 使用来自 Armadillo ( http://arma.sourceforge.net/docs.html#spsolve )的 SparseLU 求解器
我想在使用 spsolve() 时比较 SuperLu 的稀疏求解器和使用 LaPack 的密集版本的速度在 Armadillo 。因此我写了这个程序: #include "stdafx.h" #in
使用 scipy.sparse.linalg.spilu ,我计算了一个非常大的稀疏矩阵的不完全 LU 分解。由于这个过程很耗时,我想保存计算出的 LU 分解。该函数返回 scipy.sparse.l
我们有一个 HPC 环境,其中包含大多数包的多个版本,这导致我们设计了一种家庭式的方式来将包安装在独特的位置,并使用环境模块让程序员/研究人员能够识别他们正在使用的库版本当他们构建程序、运行程序或两者
我正在尝试安装最新版本的 Armadillo (6.500.5) http://arma.sourceforge.net/在 Ubuntu 14.04.3 LTS 上。 我需要求解稀疏线性系统的能力,
我是一名优秀的程序员,十分优秀!