Comments (7)
@ivan-krukov After enabling ARMA_USE_SUPERLU
, you also need to pass the -lsuperlu
option to R.
#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
using namespace Rcpp ;
using namespace arma;
// [[Rcpp::export]]
void test () {
sp_mat A = sprandu<sp_mat>(1000, 1000, 0.1);
vec b = randu<vec>(1000);
mat B = randu<mat>(1000, 5);
vec x = spsolve(A, b); // solve one system
mat X = spsolve(A, B); // solve several systems
bool status = spsolve(x, A, b); // use default solver
if(status == false) { cout << "no solution" << endl; }
spsolve(x, A, b, "lapack"); // use LAPACK solver
spsolve(x, A, b, "superlu"); // use SuperLU solver
}
In R:
> Sys.setenv("PKG_LIBS"="-lsuperlu")
> Rcpp::sourceCpp("test.cpp")
If you didn't pass -lsuperlu
, you might get some errors like undefined symbol: set_default_options
.
from rcpparmadillo.
I wrote this up as a new piece on the Rcpp Gallery.
from rcpparmadillo.
Good question. I am not sure.
Context, as you may know: RcppArmadillo takes a plain copy, no cmake, no options. Works great with basic BLAS and LAPACK which we get from R.
Extensions are harder. We are learning that now with MLPACK (over here) which uses linking against external Boost (as it needs serialization) and Armadillo (as that is how it is build).
You could try something narrower and half way. Ie define the required tokens in your source file (or src/Makevars
), then load RcppArmadillo to have them take effect. Then you "only" need to make sure you supply SUPERLU itself.
There are a few people interested in better sparse support, maybe time to discuss on rcpp-devel, or here.
from rcpparmadillo.
Just checked, and Conrad's documentation leans the same way:
ARMA_USE_SUPERLU
Enable use of SuperLU, which is used byspsolve()
for finding the solutions of sparse systems; you will need to link with the superlu library, for example-lsuperlu
Caveat: Armadillo 6.x requires SuperLU 4.3, while Armadillo 7.x requires SuperLU 5.2
from rcpparmadillo.
Perfect, was just thinking I should write an Rcpp Gallery post along those line.
The default libsuperlu-dev on Ubuntu is currenty behind, the one in Debian is good enough so easy enough to test in a Docker container, or a locally rebuilt packager for superlu.
from rcpparmadillo.
It should all be headers ... until the call to superlu is made at which point object code is needed.
Not any different from when LAPACK is called, which get for free from R which is why it seems so seamless.
from rcpparmadillo.
Just checked everything works, no need to recompile RcppArmadillo
.
This is excellent. Thank you!
from rcpparmadillo.
Related Issues (20)
- Is `ARMA_64BIT_WORD` supported in RcppArmadillo? HOT 4
- NaN output from arma::uvec compared to arma::vec HOT 4
- Planning to potentially (re)move some legacy internal header files
- Deprecating old stderr stream setting code in packages using RcppArmadillo HOT 12
- Fails to compile vs HOT 3
- Question about SIMD Optimization HOT 3
- package compilation failure HOT 20
- Two failures in test_cube.R on PowerPC HOT 33
- Armadillo 12.0.0 regressions HOT 2
- `RCPP_ARMADILLO_RETURN_ANYVEC_AS_VECTOR` in an R package? HOT 2
- using namespace arma; HOT 1
- Issue on call by reference with a NA matrix HOT 1
- Update indMatrix->arma::SpMat and pMatrix->arma::SpMat for Matrix 1.5-5 HOT 2
- install issue HOT 3
- [DOCS] - Review DESCRIPTION's Date HOT 2
- Failed to install RcppArmadillo on Linux Hyper Cluster HOT 4
- compilation on fedora39 raise error: cannot run C++ compiled programs HOT 6
- Install issue HOT 10
- Platform dependent output for sample()? HOT 9
- RcppArmadillo not available for R 4.3.2 + compilation errors HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rcpparmadillo.